本篇文章給大家分享的是有關(guān)怎么在alpine鏡像中添加ansible服務(wù),小編覺得挺實(shí)用的,因此分享給大家學(xué)習(xí),希望大家閱讀完這篇文章后可以有所收獲,話不多說,跟著小編一起來看看吧。
創(chuàng)新互聯(lián)專業(yè)網(wǎng)站制作、成都網(wǎng)站建設(shè),集網(wǎng)站策劃、網(wǎng)站設(shè)計(jì)、網(wǎng)站制作于一體,網(wǎng)站seo、網(wǎng)站優(yōu)化、網(wǎng)站營銷、軟文發(fā)布平臺(tái)等專業(yè)人才根據(jù)搜索規(guī)律編程設(shè)計(jì),讓網(wǎng)站在運(yùn)行后,在搜索中有好的表現(xiàn),專業(yè)設(shè)計(jì)制作為您帶來效益的網(wǎng)站!讓網(wǎng)站建設(shè)為您創(chuàng)造效益。添加步驟
在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 ~]#
使用
進(jìn)行版本確認(rèn)
[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] / #
與宿主機(jī)(192.168.163.172)進(jìn)行溝通,事先設(shè)定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通路確認(rèn)
/ # ssh 192.168.163.172 hostname occluster / #
ansible動(dòng)作確認(rèn)
/ # 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服務(wù),小編相信有部分知識(shí)點(diǎn)可能是我們?nèi)粘9ぷ鲿?huì)見到或用到的。希望你能通過這篇文章學(xué)到更多知識(shí)。更多詳情敬請(qǐng)關(guān)注創(chuàng)新互聯(lián)成都網(wǎng)站設(shè)計(jì)公司行業(yè)資訊頻道。
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。
文章標(biāo)題:怎么在alpine鏡像中添加ansible服務(wù)-創(chuàng)新互聯(lián)
URL地址:http://muchs.cn/article36/idspg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站維護(hù)、網(wǎng)頁設(shè)計(jì)公司、網(wǎng)站設(shè)計(jì)、Google、移動(dòng)網(wǎng)站建設(shè)、響應(yīng)式網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容