In Ansible roles you can define variables in different ways:
- in
vars/main.yml
- in
defaults/main.yml
- via
register
in a task - via a
set_fact
task - in task
vars
- probably more...
Through this answer I came across the recommendation to use a naming convention for role variable names, e. g. role_name__variable_name
. But I am not sure if this is just a recommendation or if I have to worry about scope/namespace problems caused by a role.
I can imagine that I should take such precaution when defining variables with set_fact
as this may overwrite existing host variables. But is this even true? At which variable definitions in a role do I have to worry about possible "namespace corruption"?