I'm trying to modify a value, if all tasks are ok, it should have a value = A, if one or more tasks need change it should have a value = B. I am registering all task results in a variable and I have a conditional to change the subject and then send an email.
- name: Task05:summary, set setting_config fact
set_fact:
settings_config: false
when: task01.changed == false and task02.changed == false
- name: Task006:summary, set summary fact
set_fact:
sujectmail : "{{ 'Ansible email Summary Status:green ' if settings_config == false else 'Ansible email Report Status: red!' }}"
- name: task10 report HTML report for infrastructure
template:
src: "{{ settings_report_template }}"
dest: "{{ settings_report_file }}"
delegate_to: localhost
run_once: true
check_mode: no
- name: task11 Send email report
mail:
host: "{{ mail_gateway }}"
port: "{{ mail_gateway_port }}"
sender: "{{ mail_sender }}"
subtype: html
to: "{{ mail_recipients }}"
subject: "{{sujectm}}"
body: "{{ lookup('file', config_check_report_file) }}"
secure: starttls
register: mail_output
delegate_to: localhost
run_once: true
check_mode: no
The problem with that is task10/task11 is selecting only one host. Is there any way that it can find in all registered facts and if it finds "settings_config" variable it applies the corresponding value instead just one or the latest host?