mirror of https://github.com/ansible/ansible.git
Introduce 'changed_when' keyword to override a task's changed status with the evaluation of a Jinja2 expression
parent
81940c8b11
commit
eb45f07ae3
@ -0,0 +1,25 @@
|
||||
---
|
||||
- hosts: all
|
||||
connection: local
|
||||
gather_facts: False
|
||||
|
||||
tasks:
|
||||
- action: command echo first action
|
||||
- action: command echo second action
|
||||
register: var
|
||||
changed_when: "'X' in var.stdout"
|
||||
- action: shell exit 2
|
||||
register: exit
|
||||
ignore_errors: yes
|
||||
changed_when: "exit.rc < 1"
|
||||
- action: command echo third action
|
||||
changed_when: false
|
||||
- action: file path=/ state=directory
|
||||
changed_when: true
|
||||
- action: command echo {{item}}
|
||||
register: out
|
||||
changed_when: "'e' in out.stdout"
|
||||
with_items:
|
||||
- hello
|
||||
- foo
|
||||
- bye
|
||||
Loading…
Reference in New Issue