-
Notifications
You must be signed in to change notification settings - Fork 112
/
Copy pathprepare_undercloud.yml
242 lines (226 loc) · 9.11 KB
/
prepare_undercloud.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
---
# Copyright Red Hat, Inc.
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
- name: Run prepration tasks on undercloud
delegate_to: "osp-undercloud-0"
block:
- name: Ensure needed logins
ansible.builtin.include_tasks: login_registries.yml
args:
apply:
delegate_to: "osp-undercloud-0"
- name: Ensure repos are setup
become: true
ansible.builtin.command:
cmd: "subscription-manager repos --enable {{ cifmw_adoption_osp_deploy_repos | join(' --enable ') }}"
- name: Install director packages
become: true
ansible.builtin.dnf:
name: python3-tripleoclient
state: present
- name: Ensure ci-framework-data folder is created in undercloud
vars:
cifmw_ci_setup_basedir: "{{ cifmw_basedir }}"
directory_state: directory
ansible.builtin.include_role:
name: "ci_setup"
tasks_from: "directories.yml"
apply:
delegate_to: "osp-undercloud-0"
- name: Create containers-prepare-parameters if needed
vars:
_container_prepare_cmd: >-
openstack tripleo container image prepare
default --output-env-file
{{ ansible_user_dir }}/containers-prepare-parameters.yaml
cifmw.general.ci_script:
output_dir: "{{ cifmw_basedir }}/artifacts"
script: "{{ _container_prepare_cmd }}"
when: cifmw_adoption_osp_deploy_scenario.container_prepare_params is not defined
- name: Copy containers-prepare-parameters if needed
vars:
_container_prapare_path: >-
{{
[cifmw_adoption_source_scenario_path,
cifmw_adoption_osp_deploy_scenario.container_prepare_params
] | path_join
}}
ansible.builtin.copy:
src: "{{ _container_prapare_path }}"
dest: "{{ ansible_user_dir }}/containers-prepare-parameters.yaml"
when: cifmw_adoption_osp_deploy_scenario.container_prepare_params is defined
# Adoption requires Ceph 7 (Reef) as a requirement. Instead of performing a Ceph
# upgrade from 6 (the default) to 7, let's try to deploy 7 in greenfield
- name: Patch containers-prepare-parameters Ceph container images
ansible.builtin.lineinfile:
path: "{{ ansible_user_dir }}/containers-prepare-parameters.yaml"
regexp: '^(\s.*)+: rhceph-6-rhel9'
line: '\1: rhceph-7-rhel9'
backup: true
backrefs: true
- name: Ensure os-net-config folder exists
become: true
ansible.builtin.file:
path: "/etc/os-net-config"
state: directory
mode: '0755'
- name: Generate os-net-config file
become: true
vars:
_undercloud_name: "{{ _vm_groups['osp-underclouds'] | first }}"
_undercloud_net: "{{ cifmw_networking_env_definition.instances[_undercloud_name] }}"
_ctlplane_ip: "{{ _undercloud_net.networks.ctlplane.ip_v4 }}"
_ctlplane_vip: "{{ cifmw_adoption_osp_deploy_scenario.undercloud.ctlplane_vip }}"
_ctlplane_net: "{{ cifmw_networking_env_definition.networks.ctlplane }}"
_dns_server: "{{ _ctlplane_net.dns_v4 }}"
_gateway_ip: "{{ _ctlplane_net.gw_v4 }}"
_interface_mtu: "{{ _undercloud_net.networks.ctlplane.mtu }}"
_ctlplane_cidr: "{{ _undercloud_net.networks.ctlplane.prefix_length_v4 }}"
ansible.builtin.template:
src: "os_net_config_undercloud.yml.j2"
dest: /etc/os-net-config/tripleo_config.yaml
mode: "0644"
- name: Copy undercloud.conf file to location to edit it
ansible.builtin.copy:
src: "/usr/share/python-tripleoclient/undercloud.conf.sample"
dest: "{{ ansible_user_dir }}/undercloud.conf"
remote_src: true
mode: "0644"
- name: Add environment specific vars for undercloud
vars:
_undercloud_name: "{{ _vm_groups['osp-underclouds'] | first }}"
_undercloud_net: "{{ cifmw_networking_env_definition.instances[_undercloud_name] }}"
_undercloud_ip: "{{ _undercloud_net.networks.ctlplane.ip_v4 }}"
_undercloud_net_prefix: "{{ _undercloud_net.networks.ctlplane.prefix_length_v4 }}"
_ctlplane_cidr: "{{ cifmw_networking_env_definition.networks.ctlplane.network_v4 }}"
_interface_mtu: "{{ _undercloud_net.networks.ctlplane.mtu }}"
_env_undercloud:
config:
- section: DEFAULT
option: local_ip
value: "{{ _undercloud_ip }}/{{ _undercloud_net_prefix }}"
- section: DEFAULT
option: local_mtu
value: "{{ _interface_mtu }}"
- section: DEFAULT
option: undercloud_ntp_servers
value: "{{ cifmw_adoption_osp_deploy_ntp_server }}"
- section: DEFAULT
option: container_images_file
value: "{{ ansible_user_dir }}/containers-prepare-parameters.yaml"
- section: DEFAULT
option: net_config_override
value: "/etc/os-net-config/tripleo_config.yaml"
- section: DEFAULT
option: undercloud_public_host
value: "{{ _ctlplane_cidr | ansible.utils.nthhost(122) }}"
- section: DEFAULT
option: undercloud_admin_host
value: "{{ _ctlplane_cidr | ansible.utils.nthhost(123) }}"
- section: "ctlplane-subnet"
option: "cidr"
value: "{{ _ctlplane_cidr }}"
- section: "ctlplane-subnet"
option: "dhcp_start"
value: "{{ _ctlplane_cidr | ansible.utils.nthhost(110) }}"
- section: "ctlplane-subnet"
option: "dhcp_end"
value: "{{ _ctlplane_cidr | ansible.utils.nthhost(130) }}"
- section: "ctlplane-subnet"
option: "gateway"
value: "{{ cifmw_networking_env_definition.networks.ctlplane.gw_v4 }}"
- section: "ctlplane-subnet"
option: "inspection_iprange"
value: "{{ _ctlplane_cidr | ansible.utils.nthhost(200) }},{{ _ctlplane_cidr | ansible.utils.nthhost(220) }}"
- section: "ctlplane-subnet"
option: "masquerade"
value: true
ansible.builtin.set_fact:
_undercloud_conf: >-
{{
cifmw_adoption_osp_deploy_scenario.undercloud |
combine(_env_undercloud, recursive=true, list_merge="append_rp")
}}
- name: Copy undercloud overrides file if present and amend undercloud conf
when: cifmw_adoption_osp_deploy_scenario.undercloud.undercloud_parameters_override is defined
vars:
_undercloud_overrides_path: >-
{{
[cifmw_adoption_source_scenario_path,
cifmw_adoption_osp_deploy_scenario.undercloud.undercloud_parameters_override
] | path_join
}}
_filename: "{{ _undercloud_overrides_path | basename }}"
_dest_path: "{{ ansible_user_dir }}/{{ _filename }}"
block:
- name: Copy overrides file
delegate_to: "osp-undercloud-0"
ansible.builtin.copy:
src: "{{ _undercloud_overrides_path }}"
dest: "{{ _dest_path }}"
mode: "0644"
- name: Amend undercloud conf
vars:
_undercloud_overrides:
config:
- section: DEFAULT
option: hieradata_override
value: "{{ _dest_path }}"
ansible.builtin.set_fact:
_undercloud_conf: >-
{{
_undercloud_conf |
combine(_undercloud_overrides, recursive=true, list_merge="append_rp")
}}
- name: Copy undercloud parameter defaults file if present and amend undercloud conf
when: cifmw_adoption_osp_deploy_scenario.undercloud.undercloud_parameters_defaults is defined
vars:
_undercloud_defaults_path: >-
{{
[cifmw_adoption_source_scenario_path,
cifmw_adoption_osp_deploy_scenario.undercloud.undercloud_parameters_defaults
] | path_join
}}
_filename: "{{ _undercloud_defaults_path | basename }}"
_dest_path: "{{ ansible_user_dir }}/{{ _filename }}"
block:
- name: Copy defaults file
delegate_to: "osp-undercloud-0"
ansible.builtin.copy:
src: "{{ _undercloud_defaults_path }}"
dest: "{{ _dest_path }}"
mode: "0644"
- name: Amend undercloud conf
vars:
_undercloud_overrides:
config:
- section: DEFAULT
option: custom_env_files
value: "{{ _dest_path }}"
ansible.builtin.set_fact:
_undercloud_conf: >-
{{
_undercloud_conf |
combine(_undercloud_overrides, recursive=true, list_merge="append_rp")
}}
- name: Generate undercloud.conf with scenario specific values
delegate_to: "osp-undercloud-0"
community.general.ini_file:
path: "{{ ansible_user_dir }}/undercloud.conf"
section: "{{ item.section }}"
option: "{{ item.option }}"
value: "{{ item.value }}"
state: "present"
loop: "{{ _undercloud_conf.config }}"