国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 服務器 > Web服務器 > 正文

在alpine鏡像中添加ansible服務的方法

2024-09-01 13:56:19
字體:
來源:轉載
供稿:網(wǎng)友

使用apk add ansible即可在alpine鏡像中添加ansible服務。

添加步驟

在alpine中使用ansible需要如下幾步

alpine,鏡像,ansible

Dockerfile

在Dockerfile中添加上面的語句:

#update apk for installRUN apk update#install ansible and opensshRUN apk add ansible openssh#init ansible hosts fileRUN mkdir -p /etc/ansibleRUN echo "localhost" >/etc/ansible/hosts#init rsa ssh key pairRUN ssh-keygen -t rsa -P "" -f ~/.ssh/id_rsa#delete cache files RUN rm -rf /var/cache/apk/*

使用鏡像

拉取鏡像

大概103M左右

[root@occluster ~]# docker pull liumiaocn/ansibleUsing default tag: latestTrying to pull repository docker.io/liumiaocn/ansible ... latest: Pulling from docker.io/liumiaocn/ansibleff3a5c916c92: Already exists 42a81541f983: Pull complete 86602ac17bcb: Pull complete 73cb14e49a3f: Pull complete bdfcad59d746: Pull complete 455ffeaa5bf1: Pull complete dff32643cfa5: Pull complete Digest: sha256:46284f3d3b9e3880f9b65fa6b1fb225b19bc88222badf74aa85936aabc24090fStatus: Downloaded newer image for docker.io/liumiaocn/ansible:latest[root@occluster ~]# [root@occluster ~]# docker images |grep ansibledocker.io/liumiaocn/ansible         latest       8a5cfdf8243f    Less than a second ago  103 MB[root@occluster ~]#

使用

進行版本確認

[root@occluster ~]# docker run -it --name ansible liumiaocn/ansible sh/ # ansible --versionansible 2.4.1.0 config file = None configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules'] ansible python module location = /usr/lib/python2.7/site-packages/ansible executable location = /usr/bin/ansible python version = 2.7.14 (default, Dec 14 2017, 15:51:29) [GCC 6.4.0]/ #

與宿主機(192.168.163.172)進行溝通,事先設定ssh通路,可以使用ssh-copy-id

/ # ssh-copy-id 192.168.163.172/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"The authenticity of host '192.168.163.172 (192.168.163.172)' can't be established.ECDSA key fingerprint is SHA256:uh84Xw56LhiCXb1b0uFbX/CoFhkqHGZjtmLwl3qkTOY.Are you sure you want to continue connecting (yes/no)? yes/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installedexpr: warning: '^ERROR: ': using '^' as the first characterof a basic regular expression is not portable; it is ignored/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keysroot@192.168.163.172's password: Number of key(s) added: 1Now try logging into the machine, with:  "ssh '192.168.163.172'"and check to make sure that only the key(s) you wanted were added./ #

ssh通路確認

/ # ssh 192.168.163.172 hostnameoccluster/ #

ansible動作確認

/ # echo "192.168.163.172" >>/etc/ansible/hosts/ # ansible 192.168.163.172 -m ping192.168.163.172 | SUCCESS => {  "changed": false,   "failed": false,   "ping": "pong"}/ #

總結

以上就是這篇文章的全部內容了,希望本文的內容對大家的學習或者工作具有一定的參考學習價值,謝謝大家對VEVB武林網(wǎng)的支持。


注:相關教程知識閱讀請移步到服務器教程頻道。
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 安西县| 西贡区| 长春市| 阿图什市| 喜德县| 陆良县| 湘阴县| 东明县| 巴林左旗| 揭阳市| 霍城县| 湖州市| 陇西县| 封开县| 辽阳县| 顺义区| 陵川县| 朔州市| 固阳县| 萨迦县| 闽清县| 正镶白旗| 保亭| 敦煌市| 邳州市| 天柱县| 西丰县| 池州市| 廉江市| 伊吾县| 恩施市| 腾冲县| 巩留县| 崇阳县| 福建省| 玉树县| 黑河市| 始兴县| 潮安县| 蓝田县| 锦屏县|