本文共 429 字,大约阅读时间需要 1 分钟。
when:通过register赋值给httpd_num ,然后通过变量判断
---- hosts: tomcat vars: tomca: 1 tasks: - name: ps shell: rpm -qa|grep httpd|wc -l register: httpd_num #命令结果赋值给httpd_num - debug: var=httpd_num #var=nginx_num这一项,结果执行的时候,总是skipping跳过,说明条件错误后来才使用debug模块调试,var固定 - name: command shell: touch /root/{ {httpd_num.stdout}} when: httpd_num.stdout == "1" #httpd_num.stdout,必须加stdout获取httpd_num的值
效果
成功转载地址:http://yaayb.baihongyu.com/