blob: d24fe0e82f7d4b938e9455955ac66707a271e740 [file] [log] [blame]
Zack Williamsf6cc0122018-03-30 16:00:49 -07001---
Matteo Scandolo3896c472017-08-01 13:31:42 -07002# 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 Bavier3a1d0642016-07-01 14:11:39 -040016# 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 Bavier3a1d0642016-07-01 14:11:39 -040026- name: Add machines to Juju
Zack Williams35624562016-08-28 17:12:26 -070027 when: "{{ groups['compute'] | difference( juju_machines.keys() ) | length }}"
Andy Bavier3a1d0642016-07-01 14:11:39 -040028 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 Bavier3a1d0642016-07-01 14:11:39 -040036 when: '"nova-compute" not in juju_services.keys()'
Zack Williams35624562016-08-28 17:12:26 -070037 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 Bavier3a1d0642016-07-01 14:11:39 -040040
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 Williams35624562016-08-28 17:12:26 -070048 tags:
49 - skip_ansible_lint # benign to do this more than once, hard to check for
Andy Bavier3a1d0642016-07-01 14:11:39 -040050
51# run another time
52- name: Obtain Juju Facts after deploying nova-compute
Andy Bavier3a1d0642016-07-01 14:11:39 -040053 when: '"nova-compute" not in juju_services.keys()'
Zack Williams35624562016-08-28 17:12:26 -070054 juju_facts:
Andy Bavier3a1d0642016-07-01 14:11:39 -040055
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 Williams35624562016-08-28 17:12:26 -070059 tags:
60 - skip_ansible_lint # benign to do this more than once, hard to check for
Andy Bavier3a1d0642016-07-01 14:11:39 -040061
62- name: Pause to let Juju settle
63 pause:
64 prompt="Waiting for Juju..."
65 seconds=20
66
Zack Williamsba5549c2017-03-25 15:04:45 -070067# 100*30s = 3000s = 50m max wait
Andy Bavier3a1d0642016-07-01 14:11:39 -040068- 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 Williamsba5549c2017-03-25 15:04:45 -070071 retries: 100
72 delay: 30
Andy Bavier3a1d0642016-07-01 14:11:39 -040073 with_items: "{{ groups['compute'] }}"
74
Zack Williams1396aa32017-06-06 10:28:29 -070075- name: Verify that the nodes appear in nova
Zack Williamsc989f262017-05-11 13:02:59 -070076 action: shell bash -c "source /opt/cord_profile/admin-openrc.sh; nova hypervisor-list | grep '{{ item }}'"
Andy Bavier3a1d0642016-07-01 14:11:39 -040077 register: result
Zack Williamsf6cc0122018-03-30 16:00:49 -070078 until: result is success
Zack Williamsba5549c2017-03-25 15:04:45 -070079 retries: 20
80 delay: 15
Andy Bavier3a1d0642016-07-01 14:11:39 -040081 with_items: "{{ groups['compute'] }}"
Zack Williams35624562016-08-28 17:12:26 -070082 tags:
83 - skip_ansible_lint # this really should be the os_server module, but ansible doesn't know about juju created openstack
84