2012-10-25 20:40:35 +00:00
|
|
|
---
|
|
|
|
- name: check it out
|
|
|
|
local_action: shell nc -d -z -w 5 ${inventory_hostname} 22 >>/dev/null
|
|
|
|
register: host_is_up
|
|
|
|
ignore_errors: true
|
|
|
|
|
|
|
|
- name: spin it up
|
2012-10-25 21:42:26 +00:00
|
|
|
local_action: ec2_create keypair=${keypair} image=${image} type=${instance_type} wait=true group=${security_group}
|
2012-10-25 20:40:35 +00:00
|
|
|
register: inst_res
|
|
|
|
only_if: "'${host_is_up.rc}' != '0'"
|
|
|
|
|
|
|
|
- name: assign it a special ip
|
|
|
|
local_action: shell euca-associate-address -i ${inst_res.instances[0].id} ${public_ip}
|
|
|
|
only_if: "'${host_is_up.rc}' != '0'"
|
|
|
|
|
|
|
|
- name: wait for the reassignation
|
|
|
|
local_action: wait_for host=${public_ip} port=22 delay=20 timeout=300
|
|
|
|
only_if: "'${host_is_up.rc}' != '0'"
|
|
|
|
|
2012-11-19 20:07:00 +00:00
|
|
|
# attach and mount volumes
|
|
|
|
- name: attach volumes to the system
|
|
|
|
local_action: shell euca-attach-volume -i ${inst_res.instances[0].id} $item
|
2012-11-19 20:20:23 +00:00
|
|
|
only_if: "'${host_is_up.rc}' != '0' and is_set('''${volumes}''')"
|
2012-11-19 20:07:00 +00:00
|
|
|
with_items: $volumes
|
|
|
|
|