blob: 7473a066d6881ba92834df07c2e3daa15b435a24 [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
Zack Williams6f5a6e72016-08-10 17:45:27 -070012# FIXME: Need to add firewall rules to head node or compute machines won't be
13# able to talk to head node VM's. iptables cmd's look like this:
14#
15# iptables -A FORWARD -i eth0 -o mgmtbr -s <extnet> -d <vmnet> -j ACCEPT
16# iptables -A FORWARD -i mgmtbr -o eth0 -s <vmnet> -d <extnet> -j ACCEPT
17
Andy Bavier3a1d0642016-07-01 14:11:39 -040018- name: Add machines to Juju
Zack Williams35624562016-08-28 17:12:26 -070019 when: "{{ groups['compute'] | difference( juju_machines.keys() ) | length }}"
Andy Bavier3a1d0642016-07-01 14:11:39 -040020 command: "juju add-machine ssh:{{ item }}"
21 with_items: "{{ groups['compute'] | difference( juju_machines.keys() ) }}"
22
23# run this again, so machines will be in the juju_machines list
24- name: Obtain Juju Facts after machine creation
25 juju_facts:
26
27- name: Deploy nova-compute service if needed
Andy Bavier3a1d0642016-07-01 14:11:39 -040028 when: '"nova-compute" not in juju_services.keys()'
Zack Williams35624562016-08-28 17:12:26 -070029 command: "juju deploy {{ charm_versions[item] | default(item) }} --to {{ juju_machines[groups['compute'][0]]['machine_id'] }} --config={{ juju_config_path }}"
30 with_items:
31 - "nova-compute"
Andy Bavier3a1d0642016-07-01 14:11:39 -040032
33- name: Create relations between nova-compute and other services if needed
34 command: "juju add-relation '{{ item.0.name }}' '{{ item.1 }}'"
35 register: juju_relation
36 failed_when: "juju_relation|failed and 'relation already exists' not in juju_relation.stderr"
37 with_subelements:
38 - "{{ compute_relations }}"
39 - relations
Zack Williams35624562016-08-28 17:12:26 -070040 tags:
41 - skip_ansible_lint # benign to do this more than once, hard to check for
Andy Bavier3a1d0642016-07-01 14:11:39 -040042
43# run another time
44- name: Obtain Juju Facts after deploying nova-compute
Andy Bavier3a1d0642016-07-01 14:11:39 -040045 when: '"nova-compute" not in juju_services.keys()'
Zack Williams35624562016-08-28 17:12:26 -070046 juju_facts:
Andy Bavier3a1d0642016-07-01 14:11:39 -040047
48- name: Add more nova-compute units
49 command: "juju add-unit nova-compute --to {{ juju_machines[item]['machine_id'] }}"
50 with_items: "{{ groups['compute'] | difference( juju_compute_nodes.keys() ) }}"
Zack Williams35624562016-08-28 17:12:26 -070051 tags:
52 - skip_ansible_lint # benign to do this more than once, hard to check for
Andy Bavier3a1d0642016-07-01 14:11:39 -040053
54- name: Pause to let Juju settle
55 pause:
56 prompt="Waiting for Juju..."
57 seconds=20
58
59# 160*15s = 2400s = 40m max wait
60- name: Wait for nova-compute nodes to come online
61 juju_facts:
62 until: item in juju_compute_nodes.keys() and juju_compute_nodes[item]['workload-status']['message'] == "Unit is ready"
63 retries: 160
64 delay: 15
65 with_items: "{{ groups['compute'] }}"
66
67- name: verify that the nodes appear in nova
68 action: shell bash -c "source ~/admin-openrc.sh; nova hypervisor-list | grep '{{ item }}'"
69 register: result
70 until: result | success
71 retries: 5
72 delay: 5
73 with_items: "{{ groups['compute'] }}"
Zack Williams35624562016-08-28 17:12:26 -070074 tags:
75 - skip_ansible_lint # this really should be the os_server module, but ansible doesn't know about juju created openstack
76