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

 

 

 

 

 

    


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM