日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

ansible(自动化运维中)——ansible常用模块

發(fā)布時間:2023/12/19 编程问答 57 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ansible(自动化运维中)——ansible常用模块 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

shell模塊

#幫助 ansible-doc shell #獲取主機名 ansible webserver -m shell -a 'hostname' -o #指定線程數(shù)(默認線程數(shù)是5) ansible webserver -m shell -a 'hostname' -o -f 2 #部署apache ansible host2 -m shell -a 'yum -y install httpd' -o #查詢系統(tǒng)負載 ansible host3 -m shell -a 'uptime' -o

復(fù)制模塊

#幫助 ansible-doc copy #將ansible/tmp/1.txt文件復(fù)制到webserver主機組的/tmp下并重命名為2.txt,并設(shè)置屬主為root,數(shù)組為bin,賦予777權(quán)限 ansible webserver -m copy -a 'src=/tmp/1.txt dest=/tmp/2.txt owner=root group=bin mode=777' #'backup=yes'如果文件發(fā)生更改,會將之前的備份 ansible webserver -m copy -a 'src=/tmp/1.txt dest=/tmp/2.txt owner=root group=bin mode=777 backup=yes'

用戶模塊

#幫助 ansible-doc user #創(chuàng)建用戶 ansible webserver -m user -a 'name=pengge state=present' #將密碼加密 echo '512050951' | openssl passwd -1 -stdin #修改密碼 ansible webserver -m user -a 'name=qianfeng password="$1$XVzsJMDr$5wI4oUaQ.emxap6s.N272."' #修改shell ansible webserver -m user -a 'name=qianfeng shell=/sbin/nologin append=yes' #刪除用戶 ansible webserver -m user -a 'name=qianfeng state=absent'

yum模塊

#幫助 ansible-doc yum #升級host1所有包 ansible host1 -m yum -a 'name="*" state=latest' #host2安裝http ansible host2 -m yum -a 'name="httpd" state=latest'

服務(wù)模塊

#幫助 ansible-doc service #啟動httpd ansible host2 -m service -a 'name=httpd state=started' #開機啟動httpd ansible host2 -m service -a 'name=httpd state=started enabled=yes' #停止httpd ansible host2 -m service -a 'name=httpd state=stopped' #重啟httpd ansible host2 -m service -a 'name=httpd state=restarted' #開機禁止啟動 ansible host2 -m service -a 'name=httpd state=started enabled=no'

file模塊

#幫助 ansible-doc file #在host1創(chuàng)建路徑為/tmp/1.txt,并且賦予777權(quán)限的文件 ansible host1 -m file -a 'path=/tmp/1.txt mode=777 state=touch' #在host1創(chuàng)建在/tmp/下的目錄catalog,并賦予777權(quán)限 ansible host -m file -a 'path=/tmp/catalog mode=777 state=touch'

收集模塊

#幫助 ansible-doc setup #查詢host3所有信息 ansible host3 -m setup #查詢host3的ipv4地址 ansible host3 -m setup -a 'filter=ansible_all_ipv4_addresses' 創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎勵來咯,堅持創(chuàng)作打卡瓜分現(xiàn)金大獎

總結(jié)

以上是生活随笔為你收集整理的ansible(自动化运维中)——ansible常用模块的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。