Hello - Apologies for the late reply. I failed to see the update before. Thanks for the suggestion. I ended up defining this as a fact early on in my playbook.
As for your question on roles, I do agree with you. I already redesigned the role setup to make more sense. Thanks! On Wednesday, November 9, 2016 at 6:25:43 PM UTC-6, Dick Davies wrote: > > you could set it as a group_var in your inventory. > > Do you mind me asking what's going on with your roles there (I don't > understand what the target var is for)? > If you have 2 different roles that you want to apply to groups, > couldn't you just have multiple plays? > > ... > ... > - hosts: Lower_Envs > roles: > - role_mhe_config_lower > > - hosts: Upper_Envs > roles: > - role_mhe_config_upper > ... > ... > > > > On 8 November 2016 at 22:59, <[email protected] <javascript:>> wrote: > > Hello - > > > > Is there a way to store playbook name as a 'global' variable across > plays?? > > I've seen potential options via callbacks or group_vars:all 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] <javascript:>. > > To post to this group, send email to [email protected] > <javascript:>. > > 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. > -- 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/00c28b10-53e3-48f4-916b-1504091d71b7%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
