On Tue, 5 May 2020 09:48:44 -0700 (PDT)
Nicola Limongi <[email protected]> wrote:

> THIS WORKS (from the playbook)
> ---
> - name: "provision Ec2"
>   hosts: localhost
>   connection: local
>   gather_facts: false
>   tasks:
>   - ec2_instance:
>       name: "{{ ec2_name }}"
>       security_groups:
>       [ecc ecc....]
>     register: ec2_result
> 
> - name: Add new instance to launched group
>   hosts: localhost
>   tasks:
>   - add_host:
>       hostname: "{{ item.network_interfaces[0].private_ip_address }}"
>       groupname: launched
>     with_items: "{{ ec2_result.instances }}"
> 
> - name: "config service inside EC2"
>   hosts: launched
>   tasks:
>     [perform config of inside the EC2 ...]
> 
> THIS DOES NOT WORK (from inside a role)

The code is one playbook with three plays. It's not possible to put a
playbook "inside a role".

In particular, it's not possible to apply "hosts" in a "Role"
https://docs.ansible.com/ansible/latest/reference_appendices/playbooks_keywords.html#role

HTH,

        -vlado

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/20200505202833.116a4701%40gmail.com.

Attachment: pgp20KYuFKLDt.pgp
Description: OpenPGP digital signature

Reply via email to