Hi!
I tried to read up on everything I could find w.r.t. multi stage
environments, but I haven't found a solution that fits my needs yet.
Let's say, I have 4 "environments": dev, test, stage, production
And 2 "kinds" of servers: web, db
To simplify things, I only have on variable, the size of the "ram".
In "dev", "test" and "stage" the ram for "web" should be 1GB, and 4GB for
"prod" (artificial example to show the issue!)
And in "dev", "test" and "stage" the ram for "db" should be 2GB, and 8GB
for "prod":
dev test stage prod
+-----------+ +-----------+ +-----------+ +-----------+
web | (1GB) | | (1GB) | | (1GB) | | (4GB) |
+-----------+ +-----------+ +-----------+ +-----------+
+-----------+ +-----------+ +-----------+ +-----------+
db | (2GB) | | (2GB) | | (2GB) | | (8GB) |
+-----------+ +-----------+ +-----------+ +-----------+
The roles are centrally defined (say ansible-galaxy), and I cannot use the
defaults from the roles.
Possible solutions:
1) I have an inventory for each stage, but then I have to maintain the
"ram" variable duplicated everywhere,
although I have a useful default value for each "kind" of server. I do not
know where to put the default "ram" for "web"
servers or for "db" servers:
├── dev/
│ ├── group_vars/
│ │ ├── db
│ │ └── web
│ └── inventory
...
└── prod/
├── group_vars/
│ ├── db
│ └── web
└── inventory
2) I could merge the inventories, like this:
[db-prod]
[web-prod]
[db-dev]
[web-prod]
...
[db:children]
db-prod
db-dev
...
[web:children]
...
[prod:children]
db-prod
web-prod
[dev:children]
...
But the problem is that group precedence is alphabetically, I cannot
express that "prod" has precedence over "web"
3) I could use the fact that group-vars in the inventory vars have lower
precedence than group_vars in the file system, so that I define group vars
for server "kinds" (db and web) in the inventory file and group vars for
environment in the file system. But that feels rather artificial
4) I could use the alphabetical precedence of group names by using by using
names like:
10env_dev 10env_test 10env_stage 10env_prod
20kind_db 20kind_web
but this is quite ugly.
--
I would like to be able to express the precedence of groups and perhaps use
a directory structure like this:
├── db
├── web
├── dev
│ ├── db
│ └── web
...
└── prod
├── db
└── web
How do you solve the problem?
[1] http://rosstuck.com/multistage-environments-with-ansible/
[2]
http://www.erikaheidi.com/blog/configuring-a-multistage-environment-with-ansible-and-vagrant
[3]
http://docs.ansible.com/playbooks_best_practices.html#how-to-differentiate-stage-vs-production
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/b2ba3bcf-ea7d-4b28-8b13-f71143e0fe59%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.