blob: f4e3918f8d412e68b0420d71f49bb5a122f45771 [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
Andy Bavier3a1d0642016-07-01 14:11:39 -040012- name: Add machines to Juju
Zack Williams35624562016-08-28 17:12:26 -070013 when: "{{ groups['compute'] | difference( juju_machines.keys() ) | length }}"
Andy Bavier3a1d0642016-07-01 14:11:39 -040014 command: "juju add-machine ssh:{{ item }}"
15 with_items: "{{ groups['compute'] | difference( juju_machines.keys() ) }}"
16
17# run this again, so machines will be in the juju_machines list
18- name: Obtain Juju Facts after machine creation
19 juju_facts:
20
21- name: Deploy nova-compute service if needed
Andy Bavier3a1d0642016-07-01 14:11:39 -040022 when: '"nova-compute" not in juju_services.keys()'
Zack Williams35624562016-08-28 17:12:26 -070023 command: "juju deploy {{ charm_versions[item] | default(item) }} --to {{ juju_machines[groups['compute'][0]]['machine_id'] }} --config={{ juju_config_path }}"
24 with_items:
25 - "nova-compute"
Andy Bavier3a1d0642016-07-01 14:11:39 -040026
27- name: Create relations between nova-compute and other services if needed
28 command: "juju add-relation '{{ item.0.name }}' '{{ item.1 }}'"
29 register: juju_relation
30 failed_when: "juju_relation|failed and 'relation already exists' not in juju_relation.stderr"
31 with_subelements:
32 - "{{ compute_relations }}"
33 - relations
Zack Williams35624562016-08-28 17:12:26 -070034 tags:
35 - skip_ansible_lint # benign to do this more than once, hard to check for
Andy Bavier3a1d0642016-07-01 14:11:39 -040036
37# run another time
38- name: Obtain Juju Facts after deploying nova-compute
Andy Bavier3a1d0642016-07-01 14:11:39 -040039 when: '"nova-compute" not in juju_services.keys()'
Zack Williams35624562016-08-28 17:12:26 -070040 juju_facts:
Andy Bavier3a1d0642016-07-01 14:11:39 -040041
42- name: Add more nova-compute units
43 command: "juju add-unit nova-compute --to {{ juju_machines[item]['machine_id'] }}"
44 with_items: "{{ groups['compute'] | difference( juju_compute_nodes.keys() ) }}"
Zack Williams35624562016-08-28 17:12:26 -070045 tags:
46 - skip_ansible_lint # benign to do this more than once, hard to check for
Andy Bavier3a1d0642016-07-01 14:11:39 -040047
48- name: Pause to let Juju settle
49 pause:
50 prompt="Waiting for Juju..."
51 seconds=20
52
Zack Williamsba5549c2017-03-25 15:04:45 -070053# 100*30s = 3000s = 50m max wait
Andy Bavier3a1d0642016-07-01 14:11:39 -040054- name: Wait for nova-compute nodes to come online
55 juju_facts:
56 until: item in juju_compute_nodes.keys() and juju_compute_nodes[item]['workload-status']['message'] == "Unit is ready"
Zack Williamsba5549c2017-03-25 15:04:45 -070057 retries: 100
58 delay: 30
Andy Bavier3a1d0642016-07-01 14:11:39 -040059 with_items: "{{ groups['compute'] }}"
60
61- name: verify that the nodes appear in nova
62 action: shell bash -c "source ~/admin-openrc.sh; nova hypervisor-list | grep '{{ item }}'"
63 register: result
64 until: result | success
Zack Williamsba5549c2017-03-25 15:04:45 -070065 retries: 20
66 delay: 15
Andy Bavier3a1d0642016-07-01 14:11:39 -040067 with_items: "{{ groups['compute'] }}"
Zack Williams35624562016-08-28 17:12:26 -070068 tags:
69 - skip_ansible_lint # this really should be the os_server module, but ansible doesn't know about juju created openstack
70