Hi Brian, thanks a lot, that was indeed one part of the problem. I also had to remove the meta: refresh_inventory at the end of the first play.
WORKING VERSION --- - name: "provision EC2" hosts: localhost connection: local vars_files: - vars/vars_infrastracture.yml - vars/vars-ec2-ami-linux.yml - vars/vars-ec2-name.yml gather_facts: false roles: - ec2 - name: "config service inside EC2" hosts: launched tasks: - name: niente debug: var: tag_service EC2 ROLE --- - name: "Provision EC2" ec2_instance: name: "{{ ec2_name }}" security_groups: - "{{ security_group }}" instance_type: "{{ instance_type }}" image_id: "{{ image_id }}" wait: yes region: "{{ region }}" key_name: "{{ ec2_keypair }}" vpc_subnet_id: "{{ subnet_id }}" volumes: - device_name: /dev/xvda ebs: volume_size: "{{ disk_size }}" delete_on_termination: true register: ec2_result - name: Add new instance to host group add_host: host: "{{ item.network_interfaces[0].private_ip_address }}" groups: launched with_items: "{{ ec2_result.instances }}" On Wednesday, May 6, 2020 at 4:20:52 PM UTC+2, Brian Coca wrote: > > this is just a variable named 'groupname' > groupname: launched > > Per the docs > https://docs.ansible.com/ansible/latest/modules/add_host_module.html, > if you actually want to add it to the 'launched' group: > > groups: launched > > > > -- > ---------- > Brian Coca > > -- 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 ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/4358d237-4aa7-4eab-9901-4a8ab5552932%40googlegroups.com.