- name: Launch image(s)
local_action:
module: ec2
region: "{{item.ec2_region}}"
zone: "{{item.ec2_zone}}"
instance_type: "{{item.ec2_instance_type}}"
image: "{{item.ec2_image}}"
key_name: "{{item.ec2_keypair}}"
exact_count: "{{item.ec2_exact_count}}"
group: "{{item.ec2_security_groups}}"
instance_tags: "{{item.ec2_tags}}"
count_tag: "{{item.ec2_tags}}"
vpc_subnet_id: "{{item.ec2_vpc_subnet_id}}"
instance_profile_name: "{{item.ec2_instance_profile_name}}"
wait: true
register: ec2
- name: Add new servers to group for configuration
local_action: add_host hostname={{item.public_dns_name}} groupname={{ec2_groupname}}
with_items: ec2.instances
when: ec2.changed
- name: Wait for the instances to boot by checking the ssh port
local_action: wait_for host={{item.public_dns_name}} port=22 delay=60 timeout=320 state=started
with_items: ec2.instances
when: ec2.changed
- name: Launch image(s)
local_action:
module: ec2
region: "{{item.ec2_region}}"
zone: "{{item.ec2_zone}}"
instance_type: "{{item.ec2_instance_type}}"
image: "{{item.ec2_image}}"
key_name: "{{item.ec2_keypair}}"
exact_count: "{{item.ec2_exact_count}}"
group: "{{item.ec2_security_groups}}"
instance_tags: "{{item.ec2_tags}}"
count_tag: "{{item.ec2_tags}}"
vpc_subnet_id: "{{item.ec2_vpc_subnet_id}}"
instance_profile_name: "{{item.ec2_instance_profile_name}}"
wait: true
register: ec2
with_items: ec2_defs
ok: [localhost] => {
"ec2": {
"changed": true,
"msg": "All items completed",
"results": [
{
"changed": true,
"instance_ids": [
"i-85170f6a"
],
"instances": [
{
"ami_launch_index": "0",
"architecture": "x86_64",
"ebs_optimized": false,
"hypervisor": "xen",
}
],
]
},
{
"changed": true,
"instance_ids": [
"i-9c18cf77"
],
"instances": [
{
"ami_launch_index": "0",
"architecture": "x86_64",
"ebs_optimized": false,
"hypervisor": "xen",
}
],
]
}
]
}
--
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-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/e74d2d54-43c0-4c85-8d46-4dfe3d40ab66%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
- local_action: wait_for port=22 host="{{ item.instances[0].private_ip }}" search_regex=OpenSSH delay=10
with_items: "{{ ec2.results }}"
local_action: wait_for port=22 host="{{ item.instances[0].private_ip }}" search_regex=OpenSSH delay=10 with_items: "{{ ec2.results }}"
with_items: "{{ ec2.results }}"