NIUCLOUD是一款SaaS管理后台框架多应用插件+云编译。上千名开发者、服务商正在积极拥抱开发者生态。欢迎开发者们免费入驻。一起助力发展! 广告
常用参数: 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 ~~~