command 模塊是 ansible ad-hoc command 模式下的默認(rèn)模塊,也就是說(shuō)你不需要指定參數(shù)-m。
Example
1. creates
creates 表示存在則不運(yùn)行命令
ansible group1 -a "ls / creates=/tem/testfile"
上面的命令表示:如果 /tem/testfile 文件夾不存在則運(yùn)行 ls / 命令
2. removes
removes 表示存在運(yùn)行則運(yùn)行
ansible group1 -a "ls / removes=/tem/testfile"
上面的命令表示:如果 /tem/testfile 文件夾存在則運(yùn)行 ls / 命令