Changed when
- name: Changed_when
hosts: nodes
become: true
tasks:
- name: Uptime
shell: uptime
register: uptime_message
changed_when: "'Success' in uptime_message"
“uptime_message” ile gelen textin icinde “Success” string i varsa chaged yoksa chenaged olmuyor. Normalde uptime her saniye changed ama artik bu kural sebebiyle changed olmuyor.
failed when
- name: Print message
debug:
msg: "{{ uptime_message }}"
failed_when: not myvariable is defined
gelen “uptime_message” string inin icinde myvariable yoksa veya null ise.