According to the documentation, in order to manage an Ansible variable inside of Foreman, you go to Configure -> Variables and select the Override check box and give it a sensible default.
Then you can go to a host and add the variable name with a value for that host.
However, no matter what you do at the host or host group level, the Ansible role will always receive the global default value. Is this the intended behavior?
Interestingly enough, the YAML dump at the host shows the correctly overridden value at the host level.
The Ansbile role should use the setting from the host or host group and only if not found, use the global default.
Foreman and Proxy versions:
The first document is Ansible only and as the variables are passed in by Foreman, should not really be a factor for my case.
The second link is what I followed - and together with the info buttons on the configure -> variables page - leads to the conclusion (at least for me):
you need to click “override” in order to manage the variable inside of Foreman (see Procedure, point 2: Select the Ansible variable that you want to override and manage with Foreman.)
you then add the variable to the host/host group (see Procedure at the end: To use the Ansible variable, add the variable as a parameter to your host or host group, or add the variable as a global parameter.)
So in my understanding, I click the box, give it a default value (for instance ntp_timezone: Etc/UTC) and then add it to the host in order to give it a more granular value (eq Americas/Chicago). YAML dump concurs but the actual execution puts Etc/UTC into the variable for that host.
Yep, I was stumbling at that one too. In my setup the ssh user and effective user are identical, so I was hoping to not be affected by this paragraph. Which, btw, I also cannot fully comprehend as the Ansible docs do not cover variables passed in by Foreman, so I think I would need a lot more understanding of the internals to make sense of it.
It looks like the priority is as follows:
value of variable in foreman with override checked > host parameter > hostgroup parameter > global parameter > role default.
I have no idea if this is intended, but it kinda makes sense. The way I think about it is: If you set the override on a variable you are essentially saying “this is the value I want to use, no matter what”, hence an override. If you assign it to the host/hostgroup/global parameter, that value is used, unless overriden.