- 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
"ec2": {
"changed": true,
"msg": "All items completed",
"results": [
{
"changed": true,
"instance_ids": [
"i-85170f6a"
],
"instances": [
{
"ami_launch_index": "0",
"architecture": "x86_64",
"hypervisor": "xen",
"virtualization_type": "paravirtual"
}
],
"invocation": {
"module_args": "",
"module_name": "ec2"
},
]
},
{
"changed": true,
"instance_ids": [
"i-9c18cf77"
],
"instances": [
{
"ami_launch_index": "0",
"architecture": "x86_64",
"hypervisor": "xen",
}
],
"invocation": {
"module_args": "",
"module_name": "ec2"
},
}
]
}
- name: Add new servers to group for configuration
local_action: add_host hostname={{item.1.public_dns_name}} groupname={{ec2_groupname}}
with_subelements:- ec2.results- instanceswhen: ec2.changed
--
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/ee6699a9-c8dc-44b5-ac96-d262c8c39747%40googlegroups.com.