写法如下:
[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 模块