ara icon indicating copy to clipboard operation
ara copied to clipboard

ara_playbook_name not useful in composite playbooks - last imported play wins

Open kfiresmith opened this issue 3 years ago • 1 comments

What is the issue ?

Within Ansible ARA, when an admin sets ara_playbook_name: vars within each playbook, if a composite playbook is created that leverages import_playbook: statements, the last imported play with 'ara_playbook_name' declared wins for the name of the Ansible playbook that is logged into ARA via the callback. You can actually watch the name of the executing play change in ARA as this happens.

What should be happening ?

Because of this behavior, ara_playbook_name becomes a non-useful variable to register. In such cases, it'd be nice to register a variable that supersedes ara_playbook_name such as ara_playbook_composite_name in the composite playbook.

kfiresmith avatar Apr 06 '21 22:04 kfiresmith

o/ thanks for the issue

Like discussed on IRC, the current logic is to update the name if it doesn't match what it currently is: https://github.com/ansible-community/ara/blob/52ca2898c23fe213ac2a9de348d2d8a113b77a04/ara/plugins/callback/ara_default.py#L455-L457

That's why if you have a playbook with an ara_playbook_name defined and there's another one set later, the last one will be used.

We have the same logic for labels so the behavior would be similar: https://github.com/ansible-community/ara/blob/52ca2898c23fe213ac2a9de348d2d8a113b77a04/ara/plugins/callback/ara_default.py#L459-L464

We can change that behavior (or make it configurable) but in the meantime, I think a good workaround is to use extra-vars so the value of the variable has precedence over those that might be set in other playbooks.

For example:

ansible-playbook foo.yml -e ara_playbook_name=foo ara_playbook_labels=one,two,three

For labels, ARA_DEFAULT_LABELS is another way to specify labels if relying on extra-vars isn't great for your use case.

dmsimard avatar Apr 07 '21 00:04 dmsimard