blob: dff82cdc36eca9de794992d867c0d11c8f3f6c06 [file] [log] [blame]
Matteo Scandolo3896c472017-08-01 13:31:42 -07001
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 Bavier3a1d0642016-07-01 14:11:39 -040017---
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 Bavier3a1d0642016-07-01 14:11:39 -040028- name: Add machines to Juju
Zack Williams35624562016-08-28 17:12:26 -070029 when: "{{ groups['compute'] | difference( juju_machines.keys() ) | length }}"
Andy Bavier3a1d0642016-07-01 14:11:39 -040030 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 Bavier3a1d0642016-07-01 14:11:39 -040038 when: '"nova-compute" not in juju_services.keys()'
Zack Williams35624562016-08-28 17:12:26 -070039 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 Bavier3a1d0642016-07-01 14:11:39 -040042
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 Williams35624562016-08-28 17:12:26 -070050 tags:
51 - skip_ansible_lint # benign to do this more than once, hard to check for
Andy Bavier3a1d0642016-07-01 14:11:39 -040052
53# run another time
54- name: Obtain Juju Facts after deploying nova-compute
Andy Bavier3a1d0642016-07-01 14:11:39 -040055 when: '"nova-compute" not in juju_services.keys()'
Zack Williams35624562016-08-28 17:12:26 -070056 juju_facts:
Andy Bavier3a1d0642016-07-01 14:11:39 -040057
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 Williams35624562016-08-28 17:12:26 -070061 tags:
62 - skip_ansible_lint # benign to do this more than once, hard to check for
Andy Bavier3a1d0642016-07-01 14:11:39 -040063
64- name: Pause to let Juju settle
65 pause:
66 prompt="Waiting for Juju..."
67 seconds=20
68
Zack Williamsba5549c2017-03-25 15:04:45 -070069# 100*30s = 3000s = 50m max wait
Andy Bavier3a1d0642016-07-01 14:11:39 -040070- 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 Williamsba5549c2017-03-25 15:04:45 -070073 retries: 100
74 delay: 30
Andy Bavier3a1d0642016-07-01 14:11:39 -040075 with_items: "{{ groups['compute'] }}"
76
Zack Williams1396aa32017-06-06 10:28:29 -070077- name: Verify that the nodes appear in nova
Zack Williamsc989f262017-05-11 13:02:59 -070078 action: shell bash -c "source /opt/cord_profile/admin-openrc.sh; nova hypervisor-list | grep '{{ item }}'"
Andy Bavier3a1d0642016-07-01 14:11:39 -040079 register: result
80 until: result | success
Zack Williamsba5549c2017-03-25 15:04:45 -070081 retries: 20
82 delay: 15
Andy Bavier3a1d0642016-07-01 14:11:39 -040083 with_items: "{{ groups['compute'] }}"
Zack Williams35624562016-08-28 17:12:26 -070084 tags:
85 - skip_ansible_lint # this really should be the os_server module, but ansible doesn't know about juju created openstack
86