blob: f12ce43ce6fb193dfaa1d5185b9a3fa73e1ec3bf [file] [log] [blame]
Andy Bavier3a1d0642016-07-01 14:11:39 -04001---
2# roles/juju-compute-setup/main/tasks.yml
3
4# Code for this is in library/juju_facts.py
5- name: Obtain Juju Facts for creating machines
6 juju_facts:
7
8# For setwise operations on desired vs Juju state:
9# list of active juju_machines names: juju_machines.keys()
10# list of active juju_services names: juju_services.keys()
11
12- name: Add machines to Juju
13 command: "juju add-machine ssh:{{ item }}"
14 with_items: "{{ groups['compute'] | difference( juju_machines.keys() ) }}"
15
16# run this again, so machines will be in the juju_machines list
17- name: Obtain Juju Facts after machine creation
18 juju_facts:
19
20- name: Deploy nova-compute service if needed
21 command: "juju deploy {{ charm_versions[item] | default(item) }} --to {{ juju_machines[groups['compute'][0]]['machine_id'] }} --config={{ juju_config_path }}"
22 with_items:
23 - "nova-compute"
24 when: '"nova-compute" not in juju_services.keys()'
25
26- name: Create relations between nova-compute and other services if needed
27 command: "juju add-relation '{{ item.0.name }}' '{{ item.1 }}'"
28 register: juju_relation
29 failed_when: "juju_relation|failed and 'relation already exists' not in juju_relation.stderr"
30 with_subelements:
31 - "{{ compute_relations }}"
32 - relations
33
34# run another time
35- name: Obtain Juju Facts after deploying nova-compute
36 juju_facts:
37 when: '"nova-compute" not in juju_services.keys()'
38
39- name: Add more nova-compute units
40 command: "juju add-unit nova-compute --to {{ juju_machines[item]['machine_id'] }}"
41 with_items: "{{ groups['compute'] | difference( juju_compute_nodes.keys() ) }}"
42
43- name: Pause to let Juju settle
44 pause:
45 prompt="Waiting for Juju..."
46 seconds=20
47
48# 160*15s = 2400s = 40m max wait
49- name: Wait for nova-compute nodes to come online
50 juju_facts:
51 until: item in juju_compute_nodes.keys() and juju_compute_nodes[item]['workload-status']['message'] == "Unit is ready"
52 retries: 160
53 delay: 15
54 with_items: "{{ groups['compute'] }}"
55
56- name: verify that the nodes appear in nova
57 action: shell bash -c "source ~/admin-openrc.sh; nova hypervisor-list | grep '{{ item }}'"
58 register: result
59 until: result | success
60 retries: 5
61 delay: 5
62 with_items: "{{ groups['compute'] }}"