[Ansible]command shell模块

  • 默认是command模块
  • shell模块
    • 可以使用shell内置命令 管道
[root@ceph1 ~]# ansible all -a "echo 'hello'"
ceph3 | CHANGED | rc=0 >>
hello
ceph2 | CHANGED | rc=0 >>
hello

[root@ceph1 ~]# ansible all -m shell -a "ps -aux | grep 5000"
ceph3 | CHANGED | rc=0 >>
root         538  0.0  0.0  45000  1856 ?        Ss   9月11   0:00 /usr/lib/systemd/systemd-udevd
root       22712  0.0  0.0 113280  1204 pts/0    S+   11:44   0:00 /bin/sh -c ps -aux | grep 5000
root       22714  0.0  0.0 112828   960 pts/0    S+   11:44   0:00 grep 5000
ceph2 | CHANGED | rc=0 >>
root         542  0.0  0.0  45000  1860 ?        Ss   9月11   0:00 /usr/lib/systemd/systemd-udevd
root       24971  0.0  0.0 113280  1204 pts/0    S+   11:44   0:00 /bin/sh -c ps -aux | grep 5000
root       24973  0.0  0.0 112828   956 pts/0    S+   11:44   0:00 grep 5000

END

原文地址:https://www.cnblogs.com/leoshi/p/13666712.html