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

相关文章:

  • 2021-11-22
  • 2021-04-30
  • 2021-12-20
  • 2022-12-23
  • 2021-10-27
  • 2021-10-09
  • 2021-05-28
猜你喜欢
  • 2022-12-23
  • 2022-01-22
  • 2021-12-02
  • 2021-09-04
  • 2022-12-23
  • 2022-12-23
  • 2022-01-18
相关资源
相似解决方案