1.copy本机文件到hosts的node1主机组内各主机。
ansible node1 -m copy -a “src=/home/ecip/mm/mm_shutdown.sh
dest=/home/ecip/mm/ mode=775”
2.在node1组内各主机执行命令
ansible node2 -m shell -a “”
3.更改node1组内各主机文件权限
ansible node1 -m file -a “mode=775 path=/home/ecip/mm/test.tar”
4.本机shell脚本再node1组内各主机执行。
ansible node1 -m script -a “/etc/ansible/cup.sh”
5.在各主机添加定时任务
ansible all -m cron -a ‘name=“ban IP of login” minute=* hour=/2 day= month=* weekday=* job=“sh /data/x5online/ban_try_login_ip.sh”’
6.拉取各主机文件到本机。
ansible -i hosts all -m fetch -a “src=/etc/shadow dest=/home/yonghu/shad/”
7.删除定时任务最后一行
ansible node1 -m shell -a “sed -i ‘$d’ /etc/crontab”
ansible实用模块
最新推荐文章于 2022-04-26 17:53:37 发布