Java package names should be in default not vars
evilhamsterman opened this issue · 1 comments
Why are the java package names defined in vars rather than
We use group_vars to setup variables for most of our playbooks, such as here the default java version, however since the package name is defined in the role vars through include_vars the only way to change the default java is through a couple layers of redirection (setting it in all.yml then using that value in the role import. This if fragile if someone forgets to add the var to the role include.
Is there a reason the vars are defined where they are rather than as defaults which would be easier to override with inventory vars?
Note that __java_packages
is a 'magic variable' (a coin I'm using here, not an official term). The way the role uses the variable is:
- If you set
java_packages
, it will use that. - If you don't set
java_packages
, it will fall back to__java_packages
, which is platform/version specific.
The reason is Ansible doesn't have an easy way to define default variables that vary by OS or platform... so I use this 'magic' naming convention and have a set_fact
task in the role that sets it if not set by you.
Your inventory / playbook / extra vars should always take precedence, if you set java_packages
.