We’ve run into a problem with the rax module. It worked fine to create our test env, but when we came to creating the prod version, it didn’t do anything. (No errors, but no changes either). Our incantation looks like this:
The problem seems to be that we’re using the same group for both sets of servers. The code here doesn’t check that the name pattern matches before adding it to the list of servers. I guess my question is: is this a bug, or are we using it wrong?
This is probably a better discussion for the ansible-project list instead of devel, but since it is here, I’ll go ahead and answer.
To directly address your question: I do not see it as a bug, and you are not using it wrong, you just haven’t been fully educated on the module.
The rax module looks at a few things for idempotency in your case:
region
group
count
exact_count
You are correct that the name is not considered in this scenario. I see that you have a few options to get this to do what you want:
use different accounts for dev/stg/prod
use different regions for dev/stg/prod
use different ‘group’ configurations
I’ll talk a little about #3 since 1 and 2 are somewhat simple enough to implement. This will also include info about using rax.py as an inventory script incase you are doing so.
The ‘group’ configuration is primarily used for idempotent operations when creating servers. I would recommend applying an ‘environment’ identifier to your ‘group’ such as:
group: app_servers_prod
Now assuming you are using rax.py and still want to be able to target ‘app_servers’, you can add something such as:
meta:
groups:
app_servers
prod
Those servers will be grouped in 3 groups: app_servers_prod, app_servers and prod. rax.py looks at both the ‘group’ and ‘groups’ metadata for creating groups. ‘group’ is just a single simple string. ‘groups’ can be specified as either a list or a comma separated string. The rax module automatically handles lists by turning them into comma separated strings for you, I just find it easier to look at it in list form. rax.py will split on commas in ‘groups’ and create individual inventory groups for each one.
Don’t worry, I’m quite happy to be told I’m doing it wrong
You’ve pointed out the fatal flaw in the plan, we need to have separate groups per env to be able to address just those servers. We’re going to switch to “{{ target_environment }}_app_servers”. Thanks.
Btw, it would be good to have that bit about the meta groups in the docs, I had to work it out for myself by digging through rax.py. Also, I have another question, but I’ll use the other list.