1. 程式人生 > >ansible批量替換文件並重啟服務

ansible批量替換文件並重啟服務

ansible

ansible批量替換文件並重啟服務:

註:
1、需提前配好免密碼登錄
2、被操作端需安裝python

apt-get install ansible

vi /etc/ansible/hosts

[ming]
10.0.0.2
10.0.0.3
:wq

替換(copy參數):

ansible ming -m copy -a ‘src=/etc/ntp.conf dest=/etc/‘

重啟服務(service參數):

ansible ming -m service -a ‘name=ntp state=restarted‘

查看服務情況(shell參數):

ansible ming -m shell -a ‘ntpq -p‘

ansible批量替換文件並重啟服務