写法如下:

[root@localhost ~]$ ansible 192.168.119.134 -m command -a 'date'           # 对指定的主机远程执行命令,-m 指定使用哪个模块,-a 指定执行哪些命令
[root@localhost ~]$ ansible test -m command -a 'date'                      # 对指定的主机组远程执行命令,需要先配置/etc/ansible/hosts
[root@localhost ~]$ ansible 192.168.119.134 -m shell -a 'ls | grep txt'    # 如果要执行的命令带有管道,必须使用 shell 模块

 

 

 

 

 

    

相关文章:

  • 2021-12-23
  • 2021-06-29
  • 2021-10-02
  • 2021-05-16
  • 2021-06-26
  • 2021-10-03
  • 2021-07-14
猜你喜欢
  • 2021-07-12
  • 2022-02-01
  • 2022-12-23
  • 2021-05-29
  • 2022-12-23
  • 2022-12-23
  • 2021-12-23
相关资源
相似解决方案