ansible version: 1.9.2
i'm running playbook launch ec2 instance. have site.yml variables , use role launch ec2 instance. here's main.yml ec2_launch
--- - name: create ec2 instance ec2: key_name: "{{ keypair }}" group_id: "{{ security_group }}" instance_type: "{{ instance_type }}" image: "{{ image }}" region: "{{ region }}" vpc_subnet_id: "{{ vpc_subnet_id }}" assign_public_ip: yes wait: true instance_tags: name: "{{ instance_tag }}" environment: "{{ instance_tag2 }}" exact_count: 1 count_tag: name: "{{ instance_tag }}" environment: "{{ instance_tag2 }}" monitoring: yes register: ec2 - name: add ec2 instance hosts add_host: name={{ item.private_ip }} groups=group_name with_items: ec2.instances - name: wait ssh wait_for: host={{ item.private_ip }} port=22 delay=60 timeout=320 state=started with_items: ec2.instances when run -vvv option, output during add_hosts:
task: [ec2_launch | add ec2 instance hosts] ******************************** creating host via 'add_host': hostname=10.50.101.93 added host group via add_host module: group_name the ip correct , group name correct when check ansible hosts file, has not been modified. made sure include [group_name] in hosts file. there no errors during run , not sure why it's not being added file.
there's 'add_host' example on page: http://docs.ansible.com/ec2_module.html instead of name , groups, use hostname, groupname (which believe old). i've tried well. not sure i'm missing.
the add_host task not add host file, adds in-memory list of hosts.
adding hosts file wouldn't work in cases- instance, aws users use ./ec2.py script, binary executable replaces text-based hosts file.
Comments
Post a Comment