We are creating playbooks for our servers that include creating instances with rackspace. We have problems with setting up the different inventory files with the appropriate vars. To illustrate the problem I created a small test case:
So then my question is this: Both application A and B require a local connection and variables to communicate with rackspace (like hostname for instance). Do you have some pointers how I should setup my inventory file and were to put my variables? The playbook for both apps is basically:
if not exists create instance in rackspace with this {{ hostname }}
add host to group using add_host command
include application specific playbook
Like the example below one of the apps fails because it (rightfully) resolves to the wrong hostname.
You can also use the “exact_count” parameter to request an exact number of instances starting with a given name, and it will slay extra instances if you have too many.
rackspace_image is defined in group_vars/all since we use the same base image for our apps.
Maybe my earlier example was to simplistic but I thought it was easier to explain my question since it doesn’t require a rackspace account to test it.
So my question is still: how can I make sure that I pass the correct variables to the rax module in this case? Or I just hardcode them in the file? I’d really like it to make it a role so I can use it for my other apps as well, but being unable to use variables makes it impossible. Now I am sure I am missing something really obvious here, but I can’t figure out what…
Ok I get how it supposed to work now. I’d like to share our setup.
We created a rackspace role and pass in the different variables (different apps have different flavors on different environments). We no longer add the local-rackspace group to the application group and add specific vars to the local-rackspace group on specific environments(acceptance/production). Setup is now like this: