Sorry of the subject is not very descriptive. Let me be more explicit here
I have a role that installs a piece of software at version N. this role by default open ports number x and y in the firewall. This list of ports is defined in /default/main.yml
Now I want to install version N+1 of the same software and version N+1 requires ports x, y and z to be open in the firewall but other than that, everything remains the same
I am not sure what the best practice is here
Of course, I am asking because would like to avoid to create a role for each version of the software just because the list of ports changes
How do you guys generally address this type of question
I’m not much of an expert but I have done similar things based on OS version which can be done by having a task for each version then using ‘when’ conditionals and using the ansible OS version fact.
In a similar way if you could assign the version number to a variable you could base it off that
Well, this is not what I want. I dont want to modify the tasks everytime the list of ports changes. I guess the answer is by using some include statement (which will include a file containing the version specific list of ports). I am just wondering where this include file should be included. What the best place is for doing this include (eg inside /defaults/main.yml vs playbooks using the role, etc…)
Well, this is not what I want. I dont want to modify the tasks everytime
the list of ports changes. I guess the answer is by using some include
statement (which will include a file containing the version specific list
of ports). I am just wondering where this include file should be included.
What the best place is for doing this include (eg inside
<role>/defaults/main.yml vs playbooks using the role, etc...)
An option would be to use "include_vars" in a task, that suits
your purpose best (for example tasks/main.yml)