(5) ping模組
檢測客戶端機器的連通性
ansible webserver -m ping
(6) group模組
建立使用者的附加組。
ansible webserver -m group -a 'gid=2016 name=test'
驗證ansible webserver -m shell -a 'cat /etc/group | grep test'
注意:command模組不支援管道符,而shell模組支援。
(7) user模組
該模組用於建立使用者。
ansible webserver -m user -a "name=test group=test"
ansible webserver -m user -a "name=test state=absent remove=yes"
(8) shell模組
為ansible的預設模組。可執行所有客戶端許可權範圍內的shell命令。可執行shell script支援管道符。
ansible webserver -m shell -a "/tmp/echo_hello.sh"
(9) script模組
在遠端客戶機上執行本地ansible機器中的shell指令碼。相當於scp+shell的組合命令。
ansible webserver -m script -a "~/hello.sh"
(10) get_url模組
ansible webserver -m get_url -a 'url= dest=/tmp'
(11) yum模組
~ config_file: yum的配置檔案
~ disable_gpg_check: 關閉gpg check
~ diablerepo: 不啟用某個源
~ enablerepo: 啟用某個源
~ name: 要操作的軟體包的名字,可以傳遞乙個url或乙個本地rpm包的路徑
~ state: present(安裝)|absent(刪除)|latest(安裝) 三種狀態
ansible 192.168.43.12 -m yum -a 'name=nginx enablerepo=nginx state=present'
ansible 192.168.43.12 -m shell -a 'yum list installed | grep nginx'
獲取幫助
ansible-doc yum
(12) cron模組
每天凌晨1點過1分執行對時。
ansible webserver -m cron -a '"name=ntpdate time every day" minute="1" hour="1" job="/sbin/ntpdate ntp.api.bz >> /dev/null"'
獲取幫助
ansible-doc cron
(13) service模組
客戶端的服務管理。
ansible webserver -m service -a "name=nginx state=started"
ansible webserver -m service -a 'name=mysqld state=started enabled=yes'
導演,指揮,編排器。
模版使用injia2模組處理。使用yaml描述定義。
yaml的變數:{{varname}}
配置檔案的語法檢查
執行yaml配置
10為並行程序數
ansible 自動化運維工具
ansible 自動化運維工具 批量管理 python開發 無客戶端 基於ssh服務 22 安裝 1.ansible包在擴充套件源,epel release yum y install epel release yum repolist 2.安裝,ansible yum y install ansi...
自動化運維工具 ansible
ansible ansible 一 簡介和部署 ansible 二 主機清單管理 ansible 三 配置和命令集 ansible 四 常用模組 ansible 五 palybooks劇本 ansible 彙總 ansible 中文權威指南 本部落格 至 小左先森的部落格 ansible ansib...
ansible 自動化運維工具
ansible是新出現的自動化運維工具,基於python開發,集合了眾多運維工具 puppet cfengine chef func fabric 的優點,實現了批量系統配置 批量程式部署 批量執行命令等功能。ansible是基於模組工作的,本身沒有批量部署的能力。真正具有批量部署的是ansible...