boto (2.40.0) ansible 2.0.2.0

When running this and trying to add multiple hosts to a new group for in 
memory inventory it only adding the first ec2 instance. On the wait for ssh 
task it does wait for all ec2 instances just not on the add host task.

- hosts: ec2_instances
  connection: local
  gather_facts: true
  tasks:
    - name: Launch Instance
      ec2:
        group_id: "{{ hostvars[inventory_hostname].group_id }}"
        count: 1
        instance_type: 't2.micro'
        image: "{{ hostvars[inventory_hostname].image }}"
        wait: true
        region: 'us-east-1'
        keypair: "{{ key_pair }}"
        vpc_subnet_id: "{{ priv_subnet }}"
        instance_tags: "{{ hostvars[inventory_hostname].tags }}"
        register: ec2

     - name: Wait for SSH
       wait_for:
         host: "{{ item.private_ip }}"
         port: 22
         delay: 10
         timeout: 320
         state: started
       with_items: "{{ ec2.instances }}"

    - name: Add hosts group temporary inventory group
      add_host: name={{ item.private_ip }} groups=dynamic_hosts
      with_items: "{{ ec2.instances }}"

- hosts: dynamic_hosts
  gather_facts: yes
  sudo: yes
  roles:
    - ansible-hostname-master

-- 
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/d11eecec-4195-4b4e-bab3-d0cedc66284a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to