I have a diagnostic task that dumps the Ansible dictionaries at the end of 
a run. However if the hosts fail the Playbook stops and my task doesn't get 
executed. But of course that's when it's most important.  How can I arrange 
that this task always runs after everything else?

For what it's worth, here's my dump_vars code. The real goal is to have a 
data dump at the end of each Playbook. Another means to this end would also 
be a valuable solution.

... Other Playbook code ...

# Last Play
- hosts: localhost
  gather_facts: no
  tasks:
    - name: dump all vars
      local_action: template src=dump_vars.j2 dest=./dump_vars.out
      tags: [testing1]
      ignore_errors: yes
      changed_when: False


cat dump_vars.j2

{
  "aaa_export_info1": "Export of all Ansible 1.x Dicts as a single JSON 
dict",
  "aaa_export_info2": "This file combines the dicts into a single JSON 
record",
  "aaa_export_info3": "Note that indentation is a bit off",

  "vars":         {{ vars        | remove_sensitive_data | to_nice_json }},
  "environment":  {{ environment | remove_sensitive_data | to_nice_json }},
  "group_names":  {{ group_names | remove_sensitive_data | to_nice_json }},
  "groups":       {{ groups      | remove_sensitive_data | to_nice_json }},
  "hostvars":     {{ hostvars    | remove_sensitive_data | to_nice_json }}
}




-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/d1898f1b-0788-4e90-8fd9-a434df133ca9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to