婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > 在alpine鏡像中添加ansible服務的方法

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

熱門標簽:云會外呼系統 廈門營銷外呼系統平臺 申請400電話價格多少 安陽ai電銷機器人軟件 智能電話機器人坐席 外呼系統的經營范圍 柳州市機器人外呼系統報價 涪陵商都400電話開通辦理 外呼系統不彈窗

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

添加步驟

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

Dockerfile

在Dockerfile中添加上面的語句:

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

使用鏡像

拉取鏡像

大概103M左右

[root@occluster ~]# docker pull liumiaocn/ansible
Using default tag: latest
Trying to pull repository docker.io/liumiaocn/ansible ... 
latest: Pulling from docker.io/liumiaocn/ansible
ff3a5c916c92: Already exists 
42a81541f983: Pull complete 
86602ac17bcb: Pull complete 
73cb14e49a3f: Pull complete 
bdfcad59d746: Pull complete 
455ffeaa5bf1: Pull complete 
dff32643cfa5: Pull complete 
Digest: sha256:46284f3d3b9e3880f9b65fa6b1fb225b19bc88222badf74aa85936aabc24090f
Status: Downloaded newer image for docker.io/liumiaocn/ansible:latest
[root@occluster ~]# 
[root@occluster ~]# docker images |grep ansible
docker.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 --version
ansible 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 installed
expr: warning: '^ERROR: ': using '^' as the first character
of 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 keys
root@192.168.163.172's password: 
Number of key(s) added: 1
Now 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 hostname
occluster
/ #

ansible動作確認

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

總結

以上就是這篇文章的全部內容了,希望本文的內容對大家的學習或者工作具有一定的參考學習價值,謝謝大家對腳本之家的支持。如果你想了解更多相關內容請查看下面相關鏈接

標簽:巴中 蕪湖 撫順 孝感 南充 福州 晉城 綏化

巨人網絡通訊聲明:本文標題《在alpine鏡像中添加ansible服務的方法》,本文關鍵詞  在,alpine,鏡像,中,添加,ansible,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《在alpine鏡像中添加ansible服務的方法》相關的同類信息!
  • 本頁收集關于在alpine鏡像中添加ansible服務的方法的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 锦屏县| 恩平市| 长丰县| 建水县| 吉安市| 洪洞县| 通山县| 徐水县| 台湾省| 垣曲县| 乌鲁木齐市| 即墨市| 彰化市| 竹溪县| 无锡市| 台湾省| 潍坊市| 布拖县| 威远县| 怀远县| 本溪市| 阳泉市| 彰武县| 龙游县| 都兰县| 岳普湖县| 澄迈县| 信丰县| 徐汇区| 宁强县| 当阳市| 陈巴尔虎旗| 蓬莱市| 大洼县| 蚌埠市| 天津市| 浦北县| 新津县| 太白县| 涿鹿县| 托里县|