command模块配置
command模块只能执行普通的命令,高级shell命令需要使用shell模块来执行
1.command命令模块
实例1:查看主机名
[root@ansible ~]# ansible web_clust -m command -a "hostname" -f 3 192.168.81.240 | CHANGED | rc=0 >> backup 192.168.81.230 | CHANGED | rc=0 >> nfs 192.168.81.220 | CHANGED | rc=0 >> web -f =forks 结果返回的数量,比如一次对2台机器进行操作
实例2:创建用户
[root@ansible ~]# ansible web_clust -m command -a "useradd jiangxiaol" 192.168.81.230 | CHANGED | rc=0 >> 192.168.81.220 | CHANGED | rc=0 >> 192.168.81.180 | CHANGED | rc=0 >>