Maybe you just need to add the host (cf.stack_outputs.PublicIP) to a group
as per the example here using the add_host module, this will add it to your
inventory temporarily

http://docs.ansible.com/ansible/ec2_module.html

    - name: create some ec2 instances
      ec2: ....
      register: ec2

    - name: Add new instance to host group
      add_host: hostname={{ item.public_ip }} groupname=launched
      with_items: ec2.instances
...

I've used something like this and then include the same roles I would call
for a deployment on the host in the same playbook, just a different play.

hosts: launched

  roles::
    - my_role

There are other examples on the ec2 page, it's been update a lot since I
last looked at it.

If you want to reuse the same playbooks tag your instances and just mention
the tag and group name to later use the ec2.py inventory to manage the
instance. (I've used a tag called AnsibleGroup)

hosts: launched:tag_AnsibleGroup_launched

launched would be a really esoteric group name to use, I'm just trying to
fit in with your example.

On 7 December 2015 at 11:01, Juris <[email protected]> wrote:

> James,
>
> I stumbled across ec2.py dynamic inventory and immediately got bit the
> issue no refresh of dynamic inventory if executed from the same playbook.
> If I go with the approach of separating cloud infrastructure deployment and
> application provisioning into a separate  playbooks then this problem can
> be avoided and I probably can stick with suggested approach of tagging
> resources in CF template.
>
> I am just wondering how more experienced engineers approach this problem,
> what are the good practices?
>
> Thanks,
> Juris
>
> --
> 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/dcbe4f72-86c6-4e16-8f94-55b68e625727%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/dcbe4f72-86c6-4e16-8f94-55b68e625727%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Steve

-- 
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/CA%2Bemtqv-N1jxzpy1viCN4BBfHQhdi1pT_L8S9qyOfOCU5Fa3WA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to