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 | |
Andy Bavier | 3a1d064 | 2016-07-01 14:11:39 -0400 | [diff] [blame] | 12 | - name: Add machines to Juju |
Zack Williams | 3562456 | 2016-08-28 17:12:26 -0700 | [diff] [blame] | 13 | when: "{{ groups['compute'] | difference( juju_machines.keys() ) | length }}" |
Andy Bavier | 3a1d064 | 2016-07-01 14:11:39 -0400 | [diff] [blame] | 14 | 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 Bavier | 3a1d064 | 2016-07-01 14:11:39 -0400 | [diff] [blame] | 22 | when: '"nova-compute" not in juju_services.keys()' |
Zack Williams | 3562456 | 2016-08-28 17:12:26 -0700 | [diff] [blame] | 23 | 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 Bavier | 3a1d064 | 2016-07-01 14:11:39 -0400 | [diff] [blame] | 26 | |
| 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 Williams | 3562456 | 2016-08-28 17:12:26 -0700 | [diff] [blame] | 34 | tags: |
| 35 | - skip_ansible_lint # benign to do this more than once, hard to check for |
Andy Bavier | 3a1d064 | 2016-07-01 14:11:39 -0400 | [diff] [blame] | 36 | |
| 37 | # run another time |
| 38 | - name: Obtain Juju Facts after deploying nova-compute |
Andy Bavier | 3a1d064 | 2016-07-01 14:11:39 -0400 | [diff] [blame] | 39 | when: '"nova-compute" not in juju_services.keys()' |
Zack Williams | 3562456 | 2016-08-28 17:12:26 -0700 | [diff] [blame] | 40 | juju_facts: |
Andy Bavier | 3a1d064 | 2016-07-01 14:11:39 -0400 | [diff] [blame] | 41 | |
| 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 Williams | 3562456 | 2016-08-28 17:12:26 -0700 | [diff] [blame] | 45 | tags: |
| 46 | - skip_ansible_lint # benign to do this more than once, hard to check for |
Andy Bavier | 3a1d064 | 2016-07-01 14:11:39 -0400 | [diff] [blame] | 47 | |
| 48 | - name: Pause to let Juju settle |
| 49 | pause: |
| 50 | prompt="Waiting for Juju..." |
| 51 | seconds=20 |
| 52 | |
Zack Williams | ba5549c | 2017-03-25 15:04:45 -0700 | [diff] [blame] | 53 | # 100*30s = 3000s = 50m max wait |
Andy Bavier | 3a1d064 | 2016-07-01 14:11:39 -0400 | [diff] [blame] | 54 | - 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 Williams | ba5549c | 2017-03-25 15:04:45 -0700 | [diff] [blame] | 57 | retries: 100 |
| 58 | delay: 30 |
Andy Bavier | 3a1d064 | 2016-07-01 14:11:39 -0400 | [diff] [blame] | 59 | with_items: "{{ groups['compute'] }}" |
| 60 | |
Zack Williams | 1396aa3 | 2017-06-06 10:28:29 -0700 | [diff] [blame] | 61 | - name: Verify that the nodes appear in nova |
Zack Williams | c989f26 | 2017-05-11 13:02:59 -0700 | [diff] [blame] | 62 | action: shell bash -c "source /opt/cord_profile/admin-openrc.sh; nova hypervisor-list | grep '{{ item }}'" |
Andy Bavier | 3a1d064 | 2016-07-01 14:11:39 -0400 | [diff] [blame] | 63 | register: result |
| 64 | until: result | success |
Zack Williams | ba5549c | 2017-03-25 15:04:45 -0700 | [diff] [blame] | 65 | retries: 20 |
| 66 | delay: 15 |
Andy Bavier | 3a1d064 | 2016-07-01 14:11:39 -0400 | [diff] [blame] | 67 | with_items: "{{ groups['compute'] }}" |
Zack Williams | 3562456 | 2016-08-28 17:12:26 -0700 | [diff] [blame] | 68 | tags: |
| 69 | - skip_ansible_lint # this really should be the os_server module, but ansible doesn't know about juju created openstack |
| 70 | |