Andy Bavier | 3a1d064 | 2016-07-01 14:11:39 -0400 | [diff] [blame] | 1 | --- |
| 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 Williams | 6f5a6e7 | 2016-08-10 17:45:27 -0700 | [diff] [blame] | 12 | # 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 Bavier | 3a1d064 | 2016-07-01 14:11:39 -0400 | [diff] [blame] | 18 | - name: Add machines to Juju |
| 19 | command: "juju add-machine ssh:{{ item }}" |
| 20 | with_items: "{{ groups['compute'] | difference( juju_machines.keys() ) }}" |
| 21 | |
| 22 | # run this again, so machines will be in the juju_machines list |
| 23 | - name: Obtain Juju Facts after machine creation |
| 24 | juju_facts: |
| 25 | |
| 26 | - name: Deploy nova-compute service if needed |
| 27 | command: "juju deploy {{ charm_versions[item] | default(item) }} --to {{ juju_machines[groups['compute'][0]]['machine_id'] }} --config={{ juju_config_path }}" |
| 28 | with_items: |
| 29 | - "nova-compute" |
| 30 | when: '"nova-compute" not in juju_services.keys()' |
| 31 | |
| 32 | - name: Create relations between nova-compute and other services if needed |
| 33 | command: "juju add-relation '{{ item.0.name }}' '{{ item.1 }}'" |
| 34 | register: juju_relation |
| 35 | failed_when: "juju_relation|failed and 'relation already exists' not in juju_relation.stderr" |
| 36 | with_subelements: |
| 37 | - "{{ compute_relations }}" |
| 38 | - relations |
| 39 | |
| 40 | # run another time |
| 41 | - name: Obtain Juju Facts after deploying nova-compute |
| 42 | juju_facts: |
| 43 | when: '"nova-compute" not in juju_services.keys()' |
| 44 | |
| 45 | - name: Add more nova-compute units |
| 46 | command: "juju add-unit nova-compute --to {{ juju_machines[item]['machine_id'] }}" |
| 47 | with_items: "{{ groups['compute'] | difference( juju_compute_nodes.keys() ) }}" |
| 48 | |
| 49 | - name: Pause to let Juju settle |
| 50 | pause: |
| 51 | prompt="Waiting for Juju..." |
| 52 | seconds=20 |
| 53 | |
| 54 | # 160*15s = 2400s = 40m max wait |
| 55 | - name: Wait for nova-compute nodes to come online |
| 56 | juju_facts: |
| 57 | until: item in juju_compute_nodes.keys() and juju_compute_nodes[item]['workload-status']['message'] == "Unit is ready" |
| 58 | retries: 160 |
| 59 | delay: 15 |
| 60 | with_items: "{{ groups['compute'] }}" |
| 61 | |
| 62 | - name: verify that the nodes appear in nova |
| 63 | action: shell bash -c "source ~/admin-openrc.sh; nova hypervisor-list | grep '{{ item }}'" |
| 64 | register: result |
| 65 | until: result | success |
| 66 | retries: 5 |
| 67 | delay: 5 |
| 68 | with_items: "{{ groups['compute'] }}" |