14 Apr 2017
需要知道一个文件是否存在
task文件内容
--- - name: check nginx exist or not stat: path: "/usr/local/nginx/sbin/nginx" register: nginx_cmd - debug: var=nginx_cmd.stat.exists ---
执行结果
TASK [server_initialize : check nginx exist or not] ****************************
ok: [testweb]
TASK [server_initialize : debug] ***********************************************
ok: [testweb] => {
"nginx_cmd.stat.exists": false
}
我们可以把register的结果用于when等语句里面去做判断