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}'"

 

相关文章:

  • 2021-06-22
  • 2022-02-27
  • 2021-09-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-02-27
  • 2021-06-28
  • 2022-12-23
  • 2022-12-23
  • 2021-07-08
  • 2022-12-23
相关资源
相似解决方案