Skip to content

Commit 73de44d

Browse files
bogdandodanpawlik
authored andcommitted
Multi-cell adoption support for osp-deploy plugin
Adapt templating vars for multi-cell layout Remove no longer used edpm_computes. Change data formats to become compliant with multi-cell topology. Signed-off-by: Bohdan Dobrelia <[email protected]>
1 parent 26d53bf commit 73de44d

File tree

9 files changed

+230
-35
lines changed

9 files changed

+230
-35
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
---
2+
# Copyright Red Hat, Inc.
3+
# All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License. You may obtain
7+
# a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for the specific language governing permissions and limitations
15+
# under the License.
16+
17+
- name: OSP 17 - Multi-stack multi-cell post overcloud
18+
hosts: "{{ cifmw_target_host | default('localhost') }}"
19+
gather_facts: false
20+
module_defaults:
21+
ansible.builtin.shell:
22+
executable: /bin/bash
23+
vars:
24+
_stack: "{{ stack | default('overcloud') }}"
25+
_ansible_user_dir: "{{ ansible_user_dir | default('/home/zuul') }}"
26+
tasks:
27+
- name: Ensure merged inventory directory exists
28+
delegate_to: osp-undercloud-0
29+
ansible.builtin.file:
30+
state: directory
31+
path: "{{ _ansible_user_dir }}/inventories"
32+
mode: "0755"
33+
34+
- name: Copy stack inventory file
35+
delegate_to: osp-undercloud-0
36+
ansible.builtin.copy:
37+
src: "{{ _ansible_user_dir }}/overcloud-deploy/{{ _stack }}/config-download/{{ _stack }}/tripleo-ansible-inventory.yaml"
38+
dest: "{{ _ansible_user_dir }}/inventories/{{ _stack }}.yaml"
39+
remote_src: true
40+
mode: "0644"
41+
42+
- name: Install crudini
43+
delegate_to: osp-undercloud-0
44+
environment:
45+
ANSIBLE_HOST_KEY_CHECKING: "False"
46+
ANSIBLE_SSH_RETRIES: "3"
47+
OS_CLOUD: overcloud
48+
ansible.builtin.command:
49+
cmd: >-
50+
ansible -bi {{ _ansible_user_dir }}/inventories/{{ _stack }}.yaml
51+
-m ansible.builtin.package -a "name=crudini" all
52+
53+
- name: Manage cells
54+
when: stack != "overcloud"
55+
delegate_to: osp-undercloud-0
56+
environment:
57+
ANSIBLE_HOST_KEY_CHECKING: "False"
58+
ANSIBLE_SSH_RETRIES: "3"
59+
OS_CLOUD: overcloud
60+
ansible.builtin.shell: |
61+
set -e -o pipefail
62+
ansible-playbook -i {{ _ansible_user_dir }}/inventories \
63+
/usr/share/ansible/tripleo-playbooks/create-nova-cell-v2.yaml \
64+
-e tripleo_cellv2_cell_name={{ _stack }} \
65+
-e tripleo_cellv2_containercli=podman \
66+
-e tripleo_cellv2_cellcontroller_rolename=CellController
67+
68+
openstack aggregate create {{ _stack }} --zone {{ _stack }}
69+
for i in $(openstack hypervisor list -f value -c 'Hypervisor Hostname'| grep {{ _stack }}); do
70+
openstack aggregate add host {{ _stack }} $i
71+
done
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
# Copyright Red Hat, Inc.
3+
# All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License. You may obtain
7+
# a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for the specific language governing permissions and limitations
15+
# under the License.
16+
17+
- name: OSP 17 - Multi-stack post overcloud
18+
hosts: "{{ cifmw_target_host | default('localhost') }}"
19+
vars:
20+
_ansible_user_dir: "{{ ansible_user_dir | default('/home/zuul') }}"
21+
tasks:
22+
- name: Manage cells
23+
delegate_to: osp-undercloud-0
24+
environment:
25+
ANSIBLE_HOST_KEY_CHECKING: "False"
26+
ANSIBLE_SSH_RETRIES: "3"
27+
ANSIBLE_REMOTE_USER: tripleo-admin
28+
OS_CLOUD: overcloud
29+
ansible.builtin.shell: |
30+
set -eu
31+
ansible allovercloud \
32+
-i {{ _ansible_user_dir }}/inventories -m include_role \
33+
-a name=tripleo_hosts_entries \
34+
-e tripleo_stack_name=all \
35+
-e role_networks='["InternalApi"]' \
36+
-e hostname_resolve_network=ctlplane -e plan=overcloud \
37+
-e @{{ _ansible_user_dir }}/overcloud-deploy/overcloud/config-download/overcloud/global_vars.yaml
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
# Copyright Red Hat, Inc.
3+
# All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
6+
# not use this file except in compliance with the License. You may obtain
7+
# a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14+
# License for the specific language governing permissions and limitations
15+
# under the License.
16+
17+
- name: OSP 17 - Multi-stack pre overcloud
18+
hosts: "{{ cifmw_target_host | default('localhost') }}"
19+
gather_facts: false
20+
module_defaults:
21+
ansible.builtin.shell:
22+
executable: /bin/bash
23+
vars:
24+
_stack: "{{ stack | default('overcloud') }}"
25+
_ansible_user_dir: "{{ ansible_user_dir | default('/home/zuul') }}"
26+
tasks:
27+
- name: Export the stack data from the overcloud stack
28+
delegate_to: osp-undercloud-0
29+
environment:
30+
OS_CLOUD: overcloud
31+
ansible.builtin.command:
32+
cmd: >-
33+
openstack overcloud cell export --control-plane-stack overcloud -f
34+
--output-file {{ _ansible_user_dir }}/{{ _stack }}-input.yaml
35+
--working-dir {{ _ansible_user_dir }}/overcloud-deploy/overcloud/

roles/adoption_osp_deploy/tasks/generate_adoption_vars.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,14 @@
3030
_controller_1_name: "{{ _vm_groups['osp-controllers'] | first }}"
3131
_controller_1_net: "{{ cifmw_networking_env_definition.instances[_controller_1_name] }}"
3232
_controller_1_internalapi_ip: "{{ _controller_1_net.networks.internalapi[ip_version|default('ip_v4')] }}"
33-
_compute_1_name: "{{ _vm_groups['osp-computes'] | first }}"
34-
_compute_1_net: "{{ cifmw_networking_env_definition.instances[_compute_1_name] }}"
33+
_compute_1_name: >-
34+
{%- if _vm_groups['osp-computes'] | default([]) | length > 0 -%}
35+
{{ _vm_groups['osp-computes'] | first }}
36+
{%- else -%}
37+
standalone
38+
{%- endif -%}
39+
_compute_1_net: "{{ cifmw_networking_env_definition.instances[_compute_1_name] | default({'networks': {'ctlplane': {'ip_v4': '192.168.122.100'}}}) }}"
40+
_stack_names: "{{ cifmw_adoption_osp_deploy_scenario.stacks | map(attribute='stackname') | list }}"
3541
_compute_1_ip: "{{ _compute_1_net.networks.ctlplane[ip_version|default('ip_v4')] }}"
3642
ansible.builtin.template:
3743
src: "adoption_vars.yaml.j2"

roles/adoption_osp_deploy/tasks/prepare_overcloud.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@
3333
cifmw_adoption_osp_deploy_scenario.hostname_groups_map |
3434
ansible.utils.keep_keys(target=_stack.stack_nodes)
3535
}}
36+
_role_map_translation: >-
37+
{{
38+
cifmw_adoption_osp_deploy_scenario.roles_groups_map |
39+
ansible.utils.keep_keys(target=_stack.stack_nodes)
40+
}}
3641
_network_data_file: >-
3742
{{
3843
[cifmw_adoption_source_scenario_path,

roles/adoption_osp_deploy/templates/adoption_vars.yaml.j2

Lines changed: 63 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
#jinja2: trim_blocks:True, lstrip_blocks:True
2+
{%+ if multi_cell|default(false) +%}
3+
source_mariadb_ip:
4+
{% for stack in _stack_names %}
5+
{% if stack == 'overcloud' %}
6+
{% set cell = 'default' %}
7+
{% set prefix = '' %}
8+
{% else %}
9+
{% set cell = stack %}
10+
{% set prefix = stack ~ '-' %}
11+
{% endif %}
12+
{{ cell }}: {{ cifmw_networking_env_definition.instances[_vm_groups[prefix ~ 'osp-controllers'] | first].networks.internalapi[ip_version|default('ip_v4')] }}
13+
{% endfor %}
14+
{%+ else +%}
215
source_mariadb_ip: {{ _controller_1_internalapi_ip }}
16+
{%+ endif +%}
17+
318
source_ovndb_ip: {{ _controller_1_internalapi_ip }}
419
edpm_node_hostname: {{ _compute_1_name }}.{{ cifmw_adoption_osp_deploy_scenario.cloud_domain }}
520
edpm_node_ip: {{ _compute_1_ip }}
6-
7-
{% if _vm_groups['osp-computes'] | default([]) | length > 0 %}
8-
edpm_computes: |
9-
{% for compute in _vm_groups['osp-computes'] %}
10-
{% set node_nets = cifmw_networking_env_definition.instances[compute] %}
11-
["{{ compute }}.{{ cifmw_adoption_osp_deploy_scenario.cloud_domain }}"]="{{ node_nets.networks.ctlplane[ip_version|default('ip_v4')] }}"
12-
{% endfor %}
13-
{% endif %}
14-
1521
{% if _vm_groups['osp-networkers'] | default([]) | length > 0 %}
1622
edpm_networkers: |
1723
{% for networker in _vm_groups['osp-networkers'] | default([]) %}
@@ -20,31 +26,59 @@ edpm_networkers: |
2026
{% endfor %}
2127
{% endif %}
2228

23-
source_galera_members: |
29+
source_galera_members:
30+
{%+ if multi_cell|default(false) +%}
31+
{% for stack in _stack_names %}
32+
{% if stack == 'overcloud' %}
33+
{% set cell = 'default' %}
34+
{% set prefix = '' %}
35+
{% else %}
36+
{% set cell = stack %}
37+
{% set prefix = stack ~ '-' %}
38+
{% endif %}
39+
{{ cell }}:
40+
{% for controller in _vm_groups[prefix ~ 'osp-controllers'] %}
41+
{% set node_nets = cifmw_networking_env_definition.instances[controller] %}
42+
- name: "{{ controller }}.{{ cifmw_adoption_osp_deploy_scenario.cloud_domain }}"
43+
ip: "{{ node_nets.networks.internalapi[ip_version|default('ip_v4')] }}"
44+
{% endfor %}
45+
{% endfor %}
46+
{%+ else +%}
2447
{% for controller in _vm_groups['osp-controllers'] %}
25-
{% set node_nets = cifmw_networking_env_definition.instances[controller] %}
48+
{% set node_nets = cifmw_networking_env_definition.instances[controller] %}
2649
["{{ controller }}.{{ cifmw_adoption_osp_deploy_scenario.cloud_domain }}"]="{{ node_nets.networks.internalapi[ip_version|default('ip_v4')] }}"
2750
{% endfor %}
51+
{%+ endif +%}
2852

29-
{% if _vm_groups['osp-computes'] | default([]) | length > 0 %}
3053
edpm_nodes:
31-
{% for compute in _vm_groups['osp-computes'] %}
32-
{% set node_nets = cifmw_networking_env_definition.instances[compute] %}
33-
{{ compute }}:
34-
hostName: {{ compute }}.{{ cifmw_adoption_osp_deploy_scenario.cloud_domain }}
35-
ansible:
36-
ansibleHost: {{ node_nets.networks.ctlplane[ip_version|default('ip_v4')] }}
37-
networks:
38-
{% for net in node_nets.networks.keys() if net not in cifmw_adoption_osp_deploy_adoption_vars_exclude_nets %}
39-
- fixedIP: {{ node_nets.networks[net][ip_version|default('ip_v4')] }}
40-
name: {{ net }}
41-
subnetName: subnet1
42-
{% if net == 'ctlplane' %}
43-
defaultRoute: true
44-
{% endif %}
54+
{% for stack in _stack_names %}
55+
{% if stack == 'overcloud' %}
56+
{% set cell = 'default' %}
57+
{% set prefix = '' %}
58+
{% else %}
59+
{% set cell = stack %}
60+
{% set prefix = stack ~ '-' %}
61+
{% endif %}
62+
{% if _vm_groups[prefix ~ 'osp-computes'] | default([]) | length > 0 %}
63+
{{ cell }}:
64+
{% for compute in _vm_groups[prefix ~ 'osp-computes'] %}
65+
{% set node_nets = cifmw_networking_env_definition.instances[compute] %}
66+
{{ compute }}:
67+
hostName: {{ compute }}.{{ cifmw_adoption_osp_deploy_scenario.cloud_domain }}
68+
ansible:
69+
ansibleHost: {{ node_nets.networks.ctlplane[ip_version|default('ip_v4')] }}
70+
networks:
71+
{% for net in node_nets.networks.keys() if net not in cifmw_adoption_osp_deploy_adoption_vars_exclude_nets %}
72+
- fixedIP: {{ node_nets.networks[net][ip_version|default('ip_v4')] }}
73+
name: {{ net }}
74+
subnetName: subnet1
75+
{% if net == 'ctlplane' %}
76+
defaultRoute: true
77+
{% endif %}
78+
{% endfor %}
4579
{% endfor %}
46-
{% endfor %}
47-
{% endif %}
80+
{%+ endif +%}
81+
{% endfor %}
4882

4983
edpm_nodes_networker:
5084
{% if _vm_groups['osp-networkers'] | default([]) | length > 0 %}
@@ -84,5 +118,5 @@ edpm_nodes_networker:
84118

85119

86120
upstream_dns: {{ cifmw_networking_env_definition.networks.ctlplane[dns_version|default('dns_v4')] | first }}
87-
os_cloud_name: {{ cifmw_adoption_osp_deploy_scenario.stacks[0].stackname }}
121+
os_cloud_name: {{ _stack_names[0] }}
88122
standalone_ip: {{ _undercloud_ip }}

roles/adoption_osp_deploy/templates/os_net_config_overcloud.yml.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ network_config:
1313
addresses:
1414
- ip_netmask: {{ _ctlplane_ip }}/{{ _ctlplane_cidr }}
1515
{% if _stack.routes is defined %}
16-
{%- for route in stack.routes %}
16+
{%- for route in _stack.routes %}
1717
routes:
1818
- ip_netmask: {{ route.ip_netmask }}
1919
next_hop: {{ route.next_hop }}

roles/adoption_osp_deploy/templates/tripleo-ansible-inventory.yaml.j2

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,20 @@ Undercloud:
2828
ansible_host: localhost
2929
allovercloud:
3030
children:
31-
{% for _, role in cifmw_adoption_osp_deploy_scenario.roles_groups_map.items() %}
31+
{% for _, role in _role_map_translation.items() %}
3232
{{ role }}: {}
3333
{% endfor %}
3434
computes:
3535
children:
36-
{{ cifmw_adoption_osp_deploy_scenario.roles_groups_map['osp-computes'] }}: {}
36+
{% if _role_map_translation['osp-computes'] | default([]) | length > 0 %}
37+
{{ _role_map_translation['osp-computes'] }}: {}
38+
{% endif %}
39+
{% if _role_map_translation[_overcloud_name ~ '-osp-computes'] | default([]) | length > 0 %}
40+
{{ _role_map_translation[_overcloud_name ~ '-osp-computes'] }}: {}
41+
{% endif %}
3742
{{ _overcloud_name }}:
3843
hosts:
39-
{% for group in ['osp-controllers', 'osp-computes'] %}
44+
{% for group in _role_map_translation.keys() %}
4045
{% for node in _vm_groups[group] %}
4146
{% set node_nets = cifmw_networking_env_definition.instances[node] %}
4247
{{ node }}:
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
libvirt_manager_patch_layout: {}
2+
networking_mapper_definition_patch: {}

0 commit comments

Comments
 (0)