Zack Williams | f6cc012 | 2018-03-30 16:00:49 -0700 | [diff] [blame] | 1 | --- |
Matteo Scandolo | 3896c47 | 2017-08-01 13:31:42 -0700 | [diff] [blame] | 2 | # Copyright 2017-present Open Networking Foundation |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
Andy Bavier | 3a1d064 | 2016-07-01 14:11:39 -0400 | [diff] [blame] | 16 | # roles/juju-compute-setup/main/tasks.yml |
| 17 | |
| 18 | # Code for this is in library/juju_facts.py |
| 19 | - name: Obtain Juju Facts for creating machines |
| 20 | juju_facts: |
| 21 | |
| 22 | # For setwise operations on desired vs Juju state: |
| 23 | # list of active juju_machines names: juju_machines.keys() |
| 24 | # list of active juju_services names: juju_services.keys() |
| 25 | |
Andy Bavier | 3a1d064 | 2016-07-01 14:11:39 -0400 | [diff] [blame] | 26 | - name: Add machines to Juju |
Zack Williams | 3562456 | 2016-08-28 17:12:26 -0700 | [diff] [blame] | 27 | when: "{{ groups['compute'] | difference( juju_machines.keys() ) | length }}" |
Andy Bavier | 3a1d064 | 2016-07-01 14:11:39 -0400 | [diff] [blame] | 28 | command: "juju add-machine ssh:{{ item }}" |
| 29 | with_items: "{{ groups['compute'] | difference( juju_machines.keys() ) }}" |
| 30 | |
| 31 | # run this again, so machines will be in the juju_machines list |
| 32 | - name: Obtain Juju Facts after machine creation |
| 33 | juju_facts: |
| 34 | |
| 35 | - name: Deploy nova-compute service if needed |
Andy Bavier | 3a1d064 | 2016-07-01 14:11:39 -0400 | [diff] [blame] | 36 | when: '"nova-compute" not in juju_services.keys()' |
Zack Williams | 3562456 | 2016-08-28 17:12:26 -0700 | [diff] [blame] | 37 | command: "juju deploy {{ charm_versions[item] | default(item) }} --to {{ juju_machines[groups['compute'][0]]['machine_id'] }} --config={{ juju_config_path }}" |
| 38 | with_items: |
| 39 | - "nova-compute" |
Andy Bavier | 3a1d064 | 2016-07-01 14:11:39 -0400 | [diff] [blame] | 40 | |
| 41 | - name: Create relations between nova-compute and other services if needed |
| 42 | command: "juju add-relation '{{ item.0.name }}' '{{ item.1 }}'" |
| 43 | register: juju_relation |
| 44 | failed_when: "juju_relation|failed and 'relation already exists' not in juju_relation.stderr" |
| 45 | with_subelements: |
| 46 | - "{{ compute_relations }}" |
| 47 | - relations |
Zack Williams | 3562456 | 2016-08-28 17:12:26 -0700 | [diff] [blame] | 48 | tags: |
| 49 | - 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] | 50 | |
| 51 | # run another time |
| 52 | - name: Obtain Juju Facts after deploying nova-compute |
Andy Bavier | 3a1d064 | 2016-07-01 14:11:39 -0400 | [diff] [blame] | 53 | when: '"nova-compute" not in juju_services.keys()' |
Zack Williams | 3562456 | 2016-08-28 17:12:26 -0700 | [diff] [blame] | 54 | juju_facts: |
Andy Bavier | 3a1d064 | 2016-07-01 14:11:39 -0400 | [diff] [blame] | 55 | |
| 56 | - name: Add more nova-compute units |
| 57 | command: "juju add-unit nova-compute --to {{ juju_machines[item]['machine_id'] }}" |
| 58 | with_items: "{{ groups['compute'] | difference( juju_compute_nodes.keys() ) }}" |
Zack Williams | 3562456 | 2016-08-28 17:12:26 -0700 | [diff] [blame] | 59 | tags: |
| 60 | - 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] | 61 | |
| 62 | - name: Pause to let Juju settle |
| 63 | pause: |
| 64 | prompt="Waiting for Juju..." |
| 65 | seconds=20 |
| 66 | |
Zack Williams | ba5549c | 2017-03-25 15:04:45 -0700 | [diff] [blame] | 67 | # 100*30s = 3000s = 50m max wait |
Andy Bavier | 3a1d064 | 2016-07-01 14:11:39 -0400 | [diff] [blame] | 68 | - name: Wait for nova-compute nodes to come online |
| 69 | juju_facts: |
| 70 | 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] | 71 | retries: 100 |
| 72 | delay: 30 |
Andy Bavier | 3a1d064 | 2016-07-01 14:11:39 -0400 | [diff] [blame] | 73 | with_items: "{{ groups['compute'] }}" |
| 74 | |
Zack Williams | 1396aa3 | 2017-06-06 10:28:29 -0700 | [diff] [blame] | 75 | - name: Verify that the nodes appear in nova |
Zack Williams | c989f26 | 2017-05-11 13:02:59 -0700 | [diff] [blame] | 76 | 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] | 77 | register: result |
Zack Williams | f6cc012 | 2018-03-30 16:00:49 -0700 | [diff] [blame] | 78 | until: result is success |
Zack Williams | ba5549c | 2017-03-25 15:04:45 -0700 | [diff] [blame] | 79 | retries: 20 |
| 80 | delay: 15 |
Andy Bavier | 3a1d064 | 2016-07-01 14:11:39 -0400 | [diff] [blame] | 81 | with_items: "{{ groups['compute'] }}" |
Zack Williams | 3562456 | 2016-08-28 17:12:26 -0700 | [diff] [blame] | 82 | tags: |
| 83 | - skip_ansible_lint # this really should be the os_server module, but ansible doesn't know about juju created openstack |
| 84 | |