🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
常用参数: chdir 运行command命令前先cd到这个目录 creates 当指定的这个参数对应的文件存在,就不行command命令,如果不存在,那么就运行command命令 案例: ~~~ [admin@node1 ~]$ ansible webserver -m command -a "chdir=/tmp touch aa01.txt" [WARNING]: Consider using file module with state=touch rather than running touch 192.168.52.130 | SUCCESS | rc=0 >> 192.168.52.132 | SUCCESS | rc=0 >> 192.168.52.131 | SUCCESS | rc=0 >> ~~~ ~~~ [admin@node1 ~]$ ansible webserver -m command -a "chdir=/tmp touch testfile.txt creates=/tmp/aa01.txt" 192.168.52.130 | SUCCESS | rc=0 >> skipped, since /tmp/aa01.txt exists 192.168.52.132 | SUCCESS | rc=0 >> skipped, since /tmp/aa01.txt exists 192.168.52.131 | SUCCESS | rc=0 >> skipped, since /tmp/aa01.txt exists ~~~