If i increase the delay, in that condition also, it gives the same error.
when i ran the above scripts in ansible-playbook --check debug option.
it gave this error
fatal: [localhost]: FAILED! => {"msg": "'dict object' has no attribute
'instances'"}
to retry, use: --limit @/root/instance/provision-ec2.retry
so i commented this part in the main.yml file, and now it runs ok, but does
not wait for the machine to come up.
# - debug: var=item
# with_items: "{{ ec2.instances }}"
# - add_host: name={{ item.public_ip }} >
#
groups=tag_Type_{{ec2_tag_Type}},tag_Environment_{{ec2_tag_Environment}}
# ec2_region={{ec2_region}}
# ec2_tag_Name={{ec2_tag_Name}}
# ec2_tag_Type={{ec2_tag_Type}}
# ec2_tag_Environment={{ec2_tag_Environment}}
# ec2_ip_address={{item.public_ip}}
# with_items: "{{ ec2.instances }}"
# - name: Wait for the instances to boot by checking the ssh port
# wait_for: host={{item.public_ip}} port=22 delay=60 timeout=320
state=started
# with_items: "{{ ec2.instances }}"
now it runs Ok. but does not waits for the machine to come up.
=============================================================================
On Monday, December 18, 2017 at 10:16:18 AM UTC+5:30, [email protected]
wrote:
>
> What happens if you increase the delay?
>
> On Wednesday, December 13, 2017 at 3:56:47 PM UTC+11, Ajay Sharma wrote:
>>
>> My Ansible AWS EC2 instance creation script gives this error.
>>
>> "Timeout when waiting for 172.31.25.6:22"}
>> to retry, use: --limit @/root/instance/provision-ec2.retry
>>
>> this code is causing problem, Please let me know, how to solve this.
>>
>>
>>
>>
>> *- name: Wait for the instances to boot by checking the ssh port wait_for:
>> host={{item.public_ip}} port=22 delay=60 timeout=220 state=started
>> with_items: "{{ ec2.instances }}" ~ *
>> here is the entire code.
>> ###################
>> ---
>> - name: Provision EC2 Box
>> local_action:
>> module: ec2
>> key_name: "{{ ec2_keypair }}"
>> group_id: "{{ ec2_security_group }}"
>> instance_type: "{{ ec2_instance_type }}"
>> image: "{{ ec2_image }}"
>> vpc_subnet_id: "{{ ec2_subnet_ids|random }}"
>> region: "{{ ec2_region }}"
>> instance_tags:
>> '{"Name":"{{ec2_tag_Name}}","Type":"{{ec2_tag_Type}}","Environment":"{{ec2_tag_Environment}}"}'
>> assign_public_ip: yes
>> wait: true
>> count: 1
>> volumes:
>> - device_name: /dev/sda1
>> device_type: gp2
>> volume_size: "{{ ec2_volume_size }}"
>> delete_on_termination: true
>> register: ec2
>>
>> - debug: var=item
>> with_items: "{{ ec2.instances }}"
>>
>> - add_host: name={{ item.public_ip }} >
>>
>> groups=tag_Type_{{ec2_tag_Type}},tag_Environment_{{ec2_tag_Environment}}
>> ec2_region={{ec2_region}}
>> ec2_tag_Name={{ec2_tag_Name}}
>> ec2_tag_Type={{ec2_tag_Type}}
>> ec2_tag_Environment={{ec2_tag_Environment}}
>> ec2_ip_address={{item.public_ip}}
>> with_items: "{{ ec2.instances }}"
>>
>> - name: Wait for the instances to boot by checking the ssh port
>> wait_for: host={{item.public_ip}} port=22 delay=60 timeout=220
>> state=started
>> with_items: "{{ ec2.instances }}"
>> ~
>> #################
>> Regards,
>> Ajay
>>
>>
--
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/40a9fc61-d452-4568-ad98-6486ac51bcc1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.