This callback plugin can aid in replicating the set_stats
workflow behavior in Tower
It allows you to dump the stats set with set_stats
to a file, and then use that file with --extra-vars
in subsequent ansible-playbook
calls.
- Download
dump_stats.py
file to acallback_plugins
directory relative to your playbook - Run
ansible-playbook
withANSIBLE_CALLBACK_WHITELIST=dump_stats
- Call the 2nd playbook with
--extra-vars @stats.json
The output file can be changed using DUMP_STATS_OUTPUT
env var, or output
under a [dump_stats_callback]
section in ansible.cfg
├── callback_plugins
│ └── dump_stats.py
├── playbook1.yml
└── playbook2.yml
$ ANSIBLE_CALLBACK_WHITELIST=dump_stats DUMP_STATS_OUTPUT=my_stats.json ansible-playbook playbook1.yml
PLAY [localhost] *****************************************************************************************************************************************************************************************************************************
TASK [set_stats] *****************************************************************************************************************************************************************************************************************************
ok: [localhost]
PLAY RECAP ***********************************************************************************************************************************************************************************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
$ ansible-playbook --extra-vars @my_stats.json playbook2.yml
PLAY [localhost] *****************************************************************************************************************************************************************************************************************************
TASK [debug] *********************************************************************************************************************************************************************************************************************************
ok: [localhost] => {
"foo": "bar"
}
PLAY RECAP ***********************************************************************************************************************************************************************************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0