ansible(6)——模块命令command、shell详细用法

前面在使用-m command命令时,只用了一些基本的操作,其实可以通过ansible-doc的命令查看command里和shell更加详细的功能:
ansible(6)——模块命令command、shell详细用法
ansible(6)——模块命令command、shell详细用法

chdir
ansible(6)——模块命令command、shell详细用法
ansible(6)——模块命令command、shell详细用法
creates
如果creates后面的东西存在,则skip略过:
<1>先在/tmp目录下建一个test文件夹:
ansible(6)——模块命令command、shell详细用法
<2>实行creates命令:
ansible(6)——模块命令command、shell详细用法
可见已经skip掉。
<3>没有test1,所以执行:
ansible(6)——模块命令command、shell详细用法
removes
和creates恰恰相反:
ansible(6)——模块命令command、shell详细用法
ps:如果要实行多个命令,可以用;来连接,特殊符号(|&)都不能出现在command命令里,而且也不能查看局部变量,但可以查看全局变量。
如果要特殊字符,可以使用-m shell命令来完成