summaryrefslogtreecommitdiffstats
path: root/tasks/persistent_cloud.yml
blob: bbfeb0bd8f838193fb37502fa0e6f7e80e27554d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
---
- 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
  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 }} region={{ region }}
  register: inst_res
  when: host_is_up|failed

- name: assign it a special ip
  local_action: shell euca-associate-address --config {{ persist_config }} -i {{ inst_res.instances[0].id }} {{ public_ip }}
  when: host_is_up|failed

- name: wait for the reassignation
  local_action: wait_for host={{ public_ip }} port=22 delay=20 timeout=300
  when: host_is_up|failed

# attach and mount volumes
- name: attach volumes to the system
  local_action: shell euca-attach-volume --config {{ persist_config }} -i {{ inst_res.instances[0].id }} {{ item }}
  with_items: volumes
  when: volumes is defined and host_is_up|failed