[svc]ansible自动化模块

ansible命令执行模块

- command模块 [执行远程命令]
$ ansible n1 -m command -a 'uname -n'

- raw模块 [类似于command模块、支持管道传递]
$ ansible n1 -m raw -a "ifconfig eth0 |sed -n 2p |awk '{print $2}' |awk -F: '{print $2}'"

- shell模块 [执行远程主机的shell/python脚本]
$ ansible n1 -m shell -a 'bash /root/test.sh'


- script模块 [在远程主机执行主控端的shell/python脚本 ]  (使用相对路径)
$ ansible n1 -m script -a '/etc/ansible/test.sh

查看模块帮助

ansible-doc shell
原文地址:https://www.cnblogs.com/iiiiher/p/8478125.html