ansible(自动化运维中)——ansible常用模块
生活随笔
收集整理的這篇文章主要介紹了
ansible(自动化运维中)——ansible常用模块
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
shell模塊
#幫助 ansible-doc shell #獲取主機名 ansible webserver -m shell -a 'hostname' -o #指定線程數(默認線程數是5) ansible webserver -m shell -a 'hostname' -o -f 2 #部署apache ansible host2 -m shell -a 'yum -y install httpd' -o #查詢系統負載 ansible host3 -m shell -a 'uptime' -o復制模塊
#幫助 ansible-doc copy #將ansible/tmp/1.txt文件復制到webserver主機組的/tmp下并重命名為2.txt,并設置屬主為root,數組為bin,賦予777權限 ansible webserver -m copy -a 'src=/tmp/1.txt dest=/tmp/2.txt owner=root group=bin mode=777' #'backup=yes'如果文件發生更改,會將之前的備份 ansible webserver -m copy -a 'src=/tmp/1.txt dest=/tmp/2.txt owner=root group=bin mode=777 backup=yes'用戶模塊
#幫助 ansible-doc user #創建用戶 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'服務模塊
#幫助 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創建路徑為/tmp/1.txt,并且賦予777權限的文件 ansible host1 -m file -a 'path=/tmp/1.txt mode=777 state=touch' #在host1創建在/tmp/下的目錄catalog,并賦予777權限 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' 創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎總結
以上是生活随笔為你收集整理的ansible(自动化运维中)——ansible常用模块的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: t+3个工作日到账是什么意思
- 下一篇: ansible(自动化运维下)——yam