New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The value of 'serial' in playbook cannot be set based on a variable defined per group #18131
Comments
What would happen if two groups have conflicting value of variable for serial? |
What happens when two groups have conflicting values of any variable? |
The groups are not an issue, that each host has a different value is, as vars are flattened by host so groups have no bearing after that. |
@FlorinAndrei Normally each host would have some value calculated based on precedence, but I believe value of serial must be 'global' for entire play and cannot be different for hosts within it. For example something like that:
And assume that |
I just want some way to template that variable, the way many other variables can be templated. It's a bit crazy to have to use different versions of the same playbook for different environments, only because one variable is hardcoded. I would like to be able to pull its value from somewhere, no matter how many times it could potentially be overridden. I'm sure there are good structural reasons for the current behavior, but from the user's perspective Ansible seems a little inconsistent. Some variables can be pulled from groups. Others can't. It's difficult to know what the logic is until you actually try to see if it works. :( |
you can template it, you just cannot use host variables to do so |
Just ran into this issue too, was trying to have Zuul dynamically do this for me via host vars. Back to the drawing board. |
I've just run into this problem. My Ansible CM is a VM with X MB RAM. Each host consumes ca. 300 MB for the tasks I'm running. So I first set serial hard to 3. But what if I decide to give more or less RAM to my Ansible CM? So I started to create some tasks to dynamically set the amount of servers this play can do in parallel:
Which didn't work because I can't use host variables and Control Machine variables aren't a thing that exists. So, it would be nice if I could do this at some time in the future... |
@danowar2k 'control machine variables' would be 'extra vars' |
How would I detect how much memory the Ansible CM has and set some of those variables with it? Do you have an example? |
a 'pipe' lookup could get you that info |
I'll try that out. Meanwhile, a warning to those who try my method above. When I do the setup module as a local action, Ansible overwrites the setup facts for every host with facts about the Ansible CM. I thought I could avoid that with register, but it didn't work. Maybe a switch for setup could prevent this... |
@danowar2k your |
Thanks, I didn't yet know about that. |
Since this is a hard limitation on what a play is and how hosts work, I'm going to close this issue as we don't see this feature being implemented. |
ISSUE TYPE
COMPONENT NAME
playbook
ANSIBLE VERSION
CONFIGURATION
OS / ENVIRONMENT
N/A
SUMMARY
Doing rolling updates with Ansible.
The problem is,
serial: 4
works well in production, but the value is too large for staging. In staging I'd like to useserial: 1
.I've tried to define a variable such as
api_deploy_serial
in places likeproduction/group_vars/all/vars
(and also for staging), and used that to define the value for serial in the playbook, but it does not seem to be taken into account. Seems like variables are evaluated after serial is used in the playbook.I do not want to maintain multiple deploy playbooks, one for each environment. That playbook needs to be created once, and pull variables from various environments for various behaviors. That's how config management is supposed to work.
Having multiple playbooks, one per environment, without the ability to template the behavior in the standard way, would be like a throw back to the bad old days of shell scripts.
STEPS TO REPRODUCE
If I do:
then only the default value is used, no matter what I add to
group_vars
.EXPECTED RESULTS
ACTUAL RESULTS
The text was updated successfully, but these errors were encountered: