常用的ansible命令,備忘。

公司主營(yíng)業(yè)務(wù):網(wǎng)站設(shè)計(jì)制作、成都網(wǎng)站建設(shè)、移動(dòng)網(wǎng)站開(kāi)發(fā)等業(yè)務(wù)。幫助企業(yè)客戶真正實(shí)現(xiàn)互聯(lián)網(wǎng)宣傳,提高企業(yè)的競(jìng)爭(zhēng)能力。創(chuàng)新互聯(lián)公司是一支青春激揚(yáng)、勤奮敬業(yè)、活力青春激揚(yáng)、勤奮敬業(yè)、活力澎湃、和諧高效的團(tuán)隊(duì)。公司秉承以“開(kāi)放、自由、嚴(yán)謹(jǐn)、自律”為核心的企業(yè)文化,感謝他們對(duì)我們的高要求,感謝他們從不同領(lǐng)域給我們帶來(lái)的挑戰(zhàn),讓我們激情的團(tuán)隊(duì)有機(jī)會(huì)用頭腦與智慧不斷的給客戶帶來(lái)驚喜。創(chuàng)新互聯(lián)公司推出韶山免費(fèi)做網(wǎng)站回饋大家。
一、修改/etc/ansible/hosts文件,將需要操作的主機(jī)添加進(jìn)去:
vi /etc/ansible/hosts
[ywbhost]
192.16.1.[29:52] ansible_ssh_uer="root" ansible_ssh_pass="xxxxxx"
二、執(zhí)行shell命令:
ansible ywbhost -m shell -a "/tmp/setDNS.sh"
三、復(fù)制文件
復(fù)制文件到遠(yuǎn)端主機(jī)copy:
ansible ywbhost -m copy -a "src=/etc/ansible/ywb/setdns.sh dest=/tmp/setdns.sh mode=755"
從遠(yuǎn)端主機(jī)拷貝文件到本機(jī),fetch:
ansible ywbhost -m fetch -a "src=/tmp/setdns.sh dest=/tmp/setdns.sh mode=755"
四、文本操作:
1、在文末添加一行
ansible ywbhost -m lineinfile -a "dest=/etc/chrony.conf line='server 192.168.1.33 iburst'"
2、替換一行
ansible all -m lineinfile -a "dest=/root/test.txt regexp='bbb' line='bbbbbbb'"
3、在某一行前面插入一行:
ansible all -m lineinfile -a "dest=/root/test.txt insertbefore='aa(.*)' line='eeee'"
4、在某一行后面插入一行,insertafter
ansible all -m lineinfile -a "dest=/root/test.txt insertafter='aa(.*)' line='eeee'"
5、刪除某一行:
ansible all -m lineinfile -a "dest=/root/test.txt regexp='aa(.*)' state=absent"
6、替換或添加某一行:ansible all -m lineinfile -a "dest=/root/test.txt regexp='he(.*)' line='lllll' state=present"
本文標(biāo)題:ansible相關(guān)命令備忘
文章來(lái)源:http://chinadenli.net/article20/jhpojo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站收錄、網(wǎng)站制作、移動(dòng)網(wǎng)站建設(shè)、全網(wǎng)營(yíng)銷(xiāo)推廣、品牌網(wǎng)站設(shè)計(jì)、App開(kāi)發(fā)
聲明:本網(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í)需注明來(lái)源: 創(chuàng)新互聯(lián)