当ansible_os_family为RedHat时,执行/bin/ps -ef >>/tmp/ps
[root@node110 yml]# cat when.yml
---
- hosts: 192.168.198.120
tasks:
- name: "ps -ef when os is redhat "
shell: /bin/ps -ef >>/tmp/ps
when: ansible_os_family == "RedHat"
模型:
tasks:
- command: /bin/false
register: result
ignore_errors: True
- command: /bin/something
when: result|failed #当result执行的结果为failed时,执行/bin/something
- command: /bin/something_else
when: result|success #当result的执行结果为success时,执行/bin/something_else
- command: /bin/still/something_else
when: result|skipped
2017-04-18
ansible 条件语句when
评论
发表评论
姓 名: