Hello -

Is there a way to store playbook name as a 'global' variable across plays?? 
I've seen potential options via callbacks 
<https://github.com/ansible/ansible/issues/14772> or group_vars:all 
<http://grokbase.com/t/gg/ansible-devel/149s71x0gv/global-variables-file> but 
still struggling with the solve.

At the end of the day I want to log certain actions for a specific playbook 
(which contains several different plays). I have the default ansible 
logging setup, but it lacks readability and is otherwise difficult to 
consume. The playbook contains all sorts of prep, validations, and 
deployments but I only want to log the aggregate changes in our operational 
environments such that it can be easily digested. I envision a log file 
with <playbook_name>_<timestamp>.log with all the stuff I want to plop into 
it.

I could approach the callback; however I'm still new to ansible so 
hesitating before hopping into more 'advanced' features.
I don't believe group_vars:all will work because the playbook name isn't 
tied to the host groups.
Passing in the name as an extra-var on the command line reduces usability.
So far the best that I could do is manually define the var in the playbook 
when calling the role. However, it then only exists for that specific play. 



- name: MHE Dematic Conveyer Configuration
  hosts: "{{ target }}"
  vars:
    playbook_name: "pb_MA_WMOS_Post_Install_Config"
  roles:
  - { role: role_mhe_config_lower, when: "'Lower_Envs' in group_names", tags
: ["Lower_Envs"] }
  - { role: role_mhe_config_upper, when: "'Upper_Envs' in group_names", tags
: ["Upper_Envs"] }


Or, perhaps I'm just looking at this all wrong and restricting too much 
down one path. Thoughts?

Thanks!

-- 
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/01de0105-bc9d-4efc-a4da-4f62ebc87ee5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to