Matteo Scandolo | 3896c47 | 2017-08-01 13:31:42 -0700 | [diff] [blame] | 1 | |
| 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 | |
| 16 | |
Andy Bavier | 3a1d064 | 2016-07-01 14:11:39 -0400 | [diff] [blame] | 17 | --- |
| 18 | # roles/juju-compute-setup/main/tasks.yml |
| 19 | |
| 20 | # Code for this is in library/juju_facts.py |
| 21 | - name: Obtain Juju Facts for creating machines |
| 22 | juju_facts: |
| 23 | |
| 24 | # For setwise operations on desired vs Juju state: |
| 25 | # list of active juju_machines names: juju_machines.keys() |
| 26 | # list of active juju_services names: juju_services.keys() |
| 27 | |
Andy Bavier | 3a1d064 | 2016-07-01 14:11:39 -0400 | [diff] [blame] | 28 | - name: Add machines to Juju |
Zack Williams | 3562456 | 2016-08-28 17:12:26 -0700 | [diff] [blame] | 29 | when: "{{ groups['compute'] | difference( juju_machines.keys() ) | length }}" |
Andy Bavier | 3a1d064 | 2016-07-01 14:11:39 -0400 | [diff] [blame] | 30 | command: "juju add-machine ssh:{{ item }}" |
| 31 | with_items: "{{ groups['compute'] | difference( juju_machines.keys() ) }}" |
| 32 | |
| 33 | # run this again, so machines will be in the juju_machines list |
| 34 | - name: Obtain Juju Facts after machine creation |
| 35 | juju_facts: |
| 36 | |
| 37 | - name: Deploy nova-compute service if needed |
Andy Bavier | 3a1d064 | 2016-07-01 14:11:39 -0400 | [diff] [blame] | 38 | when: '"nova-compute" not in juju_services.keys()' |
Zack Williams | 3562456 | 2016-08-28 17:12:26 -0700 | [diff] [blame] | 39 | command: "juju deploy {{ charm_versions[item] | default(item) }} --to {{ juju_machines[groups['compute'][0]]['machine_id'] }} --config={{ juju_config_path }}" |
| 40 | with_items: |
| 41 | - "nova-compute" |
Andy Bavier | 3a1d064 | 2016-07-01 14:11:39 -0400 | [diff] [blame] | 42 | |
| 43 | - name: Create relations between nova-compute and other services if needed |
| 44 | command: "juju add-relation '{{ item.0.name }}' '{{ item.1 }}'" |
| 45 | register: juju_relation |
| 46 | failed_when: "juju_relation|failed and 'relation already exists' not in juju_relation.stderr" |
| 47 | with_subelements: |
| 48 | - "{{ compute_relations }}" |
| 49 | - relations |
Zack Williams | 3562456 | 2016-08-28 17:12:26 -0700 | [diff] [blame] | 50 | tags: |
| 51 | - 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] | 52 | |
| 53 | # run another time |
| 54 | - name: Obtain Juju Facts after deploying nova-compute |
Andy Bavier | 3a1d064 | 2016-07-01 14:11:39 -0400 | [diff] [blame] | 55 | when: '"nova-compute" not in juju_services.keys()' |
Zack Williams | 3562456 | 2016-08-28 17:12:26 -0700 | [diff] [blame] | 56 | juju_facts: |
Andy Bavier | 3a1d064 | 2016-07-01 14:11:39 -0400 | [diff] [blame] | 57 | |
| 58 | - name: Add more nova-compute units |
| 59 | command: "juju add-unit nova-compute --to {{ juju_machines[item]['machine_id'] }}" |
| 60 | with_items: "{{ groups['compute'] | difference( juju_compute_nodes.keys() ) }}" |
Zack Williams | 3562456 | 2016-08-28 17:12:26 -0700 | [diff] [blame] | 61 | tags: |
| 62 | - 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] | 63 | |
| 64 | - name: Pause to let Juju settle |
| 65 | pause: |
| 66 | prompt="Waiting for Juju..." |
| 67 | seconds=20 |
| 68 | |
Zack Williams | ba5549c | 2017-03-25 15:04:45 -0700 | [diff] [blame] | 69 | # 100*30s = 3000s = 50m max wait |
Andy Bavier | 3a1d064 | 2016-07-01 14:11:39 -0400 | [diff] [blame] | 70 | - name: Wait for nova-compute nodes to come online |
| 71 | juju_facts: |
| 72 | 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] | 73 | retries: 100 |
| 74 | delay: 30 |
Andy Bavier | 3a1d064 | 2016-07-01 14:11:39 -0400 | [diff] [blame] | 75 | with_items: "{{ groups['compute'] }}" |
| 76 | |
Zack Williams | 1396aa3 | 2017-06-06 10:28:29 -0700 | [diff] [blame] | 77 | - name: Verify that the nodes appear in nova |
Zack Williams | c989f26 | 2017-05-11 13:02:59 -0700 | [diff] [blame] | 78 | 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] | 79 | register: result |
| 80 | until: result | success |
Zack Williams | ba5549c | 2017-03-25 15:04:45 -0700 | [diff] [blame] | 81 | retries: 20 |
| 82 | delay: 15 |
Andy Bavier | 3a1d064 | 2016-07-01 14:11:39 -0400 | [diff] [blame] | 83 | with_items: "{{ groups['compute'] }}" |
Zack Williams | 3562456 | 2016-08-28 17:12:26 -0700 | [diff] [blame] | 84 | tags: |
| 85 | - skip_ansible_lint # this really should be the os_server module, but ansible doesn't know about juju created openstack |
| 86 | |