Reputation: 807
I'm trying to reuse generic playbooks so that they can be played within any larger scenario.
Think a build-basic-server playbook (which is composed of roles) that can be run on different cloud provider while overriding the generic playbook variables.
group_vars/
all
playbooks/
build-basic-server/
group_vars/
all
roles/
firewall/
web/
...
build.yml
roles/
my-cloud-provider/ or container/
main.yml (with - import_playbook: playbooks/build-basic-server/build.yml)
This works well, but my trouble is that I can't rely on the main group_vars/all
to take precedence over the playbooks/build-basic-server/group_vars/all
.
I need the main group_vars/all
to override the playbook one so that I can keep the playbook generic and testable with test variables values (Otherwise I'd have to a specific branch of the playbook per usage and would need to merge any modification to each branch...).
Is there any way to make this main group_vars/all
take precedence over everything?
Do you have any other way to implement such a use case?
Upvotes: 0
Views: 234
Reputation: 807
Using this additional folder for variables
inventory/
group_vars/
all
does override values in
playbooks/
build-basic-server/
group_vars/
all
for
playbooks/
build-basic-server/
build.xml
but not for root
main.yml
This is equivalent to switching from Play to Host Variable Scope
So that's one possible solution to the stated problem.
Upvotes: 1