Ansible 远程执行命令

写法如下:

[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 模块

 

 

 

 

 

    

posted @ 2019-01-03 11:11  孔雀东南飞  阅读(4811)  评论(0编辑  收藏  举报