2012-10-25 22:40:35 +02:00
|
|
|
---
|
|
|
|
- name: check it out
|
2014-01-01 20:15:11 +01:00
|
|
|
local_action: shell nc -d -z -w 5 {{ inventory_hostname }} 22 >>/dev/null
|
2012-10-25 22:40:35 +02:00
|
|
|
register: host_is_up
|
|
|
|
ignore_errors: true
|
|
|
|
|
|
|
|
- name: spin it up
|
2014-01-15 17:50:37 +01:00
|
|
|
local_action: ec2 keypair={{ keypair }} image={{ image }} type={{ instance_type }} wait=true group={{ security_group }} ec2_access_key={{ persist_access_key }} ec2_secret_key={{ persist_secret_key }} ec2_url={{ os_ec2_url }}
|
2012-10-25 22:40:35 +02:00
|
|
|
register: inst_res
|
2013-06-18 18:58:09 +02:00
|
|
|
when: host_is_up|failed
|
2012-10-25 22:40:35 +02:00
|
|
|
|
|
|
|
- name: assign it a special ip
|
2014-01-01 20:15:11 +01:00
|
|
|
local_action: shell euca-associate-address --config {{ persist_config }} -i {{ inst_res.instances[0].id }} {{ public_ip }}
|
2013-06-18 18:58:09 +02:00
|
|
|
when: host_is_up|failed
|
2012-10-25 22:40:35 +02:00
|
|
|
|
|
|
|
- name: wait for the reassignation
|
2014-01-01 20:15:11 +01:00
|
|
|
local_action: wait_for host={{ public_ip }} port=22 delay=20 timeout=300
|
2013-06-18 18:58:09 +02:00
|
|
|
when: host_is_up|failed
|
2012-10-25 22:40:35 +02:00
|
|
|
|
2012-11-19 21:07:00 +01:00
|
|
|
# attach and mount volumes
|
|
|
|
- name: attach volumes to the system
|
2014-01-01 20:15:11 +01:00
|
|
|
local_action: shell euca-attach-volume --config {{ persist_config }} -i {{ inst_res.instances[0].id }} {{ item }}
|
2014-01-01 20:47:31 +01:00
|
|
|
with_items: volumes
|
2013-06-18 18:58:09 +02:00
|
|
|
when: volumes is defined and host_is_up|failed
|
|
|
|
|