So, I don't think I can exactly answer your question but I think I can get you in the right direction.
So if you were using cloud instead of Vagrant, I'd tell you to use the dynamic inventory scripts. For example, the rax.py dynamic inventory plugin groups hosts both logically and dynamically at runtime. There is a Vagrant pluging that also queries for dynamic inventory, but according to the doucmentation, all it does it return a single group called "vagrant". The Vagrant module is here: https://github.com/ansible/ansible/blob/devel/plugins/inventory/vagrant.py If you're doing your work all at once in a single ansible-playbook run (provisioning and bootstrapping), then you can use the add_host module to assign the hosts that you provision via Ansible to an arbitrary group or groups, which you can then target with additional work. http://docs.ansible.com/add_host_module.html Perhaps combining the inventory script and the add_host module you may find a solution -- but AFAIK, there's not a solution that will do exactly what you're looking for. On Tue, Mar 25, 2014 at 7:54 AM, Deyna Cegielski <[email protected]> wrote: > Hey guys, > > I've written a playbook that defines the configuration policies for an > "application server" running nodejs. I've been using this playbook to > provision a vagrant box (local sandbox) with great success but now I want > to use this playbook to provision sandboxes in the cloud. > > Ultimately I'd like to be able to spin up and provision an infinite number > of environments, each existing as their own subdomain e.g. > sandbox1.mydomain,com sandbox2.mydomain.com. I've looked into spinning up > instances and dynamically so that they are added to my inventory allowing > me to then target them for provisioning easily: > > [appservers] > 1.2.3.4 > 5.6.7.8 > > --- hosts: appservers > roles: nodejs > > However, how do I distinguish between sandbox1 and sandbox2 in the > inventory file whilst maintaining the "appserver" policy? I would like the > run a deployment script that only targets the specified sandbox? I was > thinking something along the lines of: > > [appservers] > 1.2.3.4 > 5.6.7.8 > > [sandbox1] > 1.2.3.4 > > [sandbox2] > 5.6.7.8 > > And then I can target --limit sandbox1 to only run the deployment task > against this group. > > Is this a valid way of achieving my goal? > > > -- > 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/0767671e-4a6f-4687-8aea-e5a7414b1287%40googlegroups.com<https://groups.google.com/d/msgid/ansible-project/0767671e-4a6f-4687-8aea-e5a7414b1287%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- 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/CAK6JQEHEmF6bQLdrSwZ5yGGEacELtZtqZ8ckdp_LqgogF0Cibg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
