关于ansbile工具的shell、command、script、raw模块的区别和使用场景

command模块 [执行远程命令]

[root@node1 ansible]# ansible testservers -m command -a 'uname -n'

script模块 [在远程主机执行主控端的shell/python脚本 ]  (使用相对路径)

[root@node1 ansible]# ansible testservers -m script -a '/etc/ansible/test.sh

 shell模块 [执行远程主机的shell/python脚本]

[root@node1 ansible]# ansible testservers -m shell -a 'bash /root/test.sh'

 raw模块 [类似于command模块、支持管道传递]

[root@node1 ansible]# ansible testservers -m raw -a "ifconfig eth0 |sed -n 2p |awk '{print $2}' |awk -F: '{print $2}'"
原文地址:https://www.cnblogs.com/smail-bao/p/8549868.html