Skip to content

Commit 7553da5

Browse files
committed
Refactor deploy-openstack.sh into multinode.sh
Drop Terraform templating to make it easier to understand and maintain. Provide multiple script entry points to make it easier to perform different operations. The previous behaviour is maintained as a 'deploy_full' command. Add support for upgrading the overcloud with an 'upgrade_overcloud' command.
1 parent 2e6e346 commit 7553da5

File tree

6 files changed

+465
-247
lines changed

6 files changed

+465
-247
lines changed

ansible/deploy-openstack-config.yml

Lines changed: 65 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,18 +63,57 @@
6363
state: present
6464
become: true
6565

66+
- name: Ensure uuid-runtime is present (Ubuntu)
67+
ansible.builtin.package:
68+
name: uuid-runtime
69+
state: present
70+
become: true
71+
when: ansible_facts['distribution'] == "Ubuntu"
72+
6673
- name: Ensure `source` directory exists
6774
ansible.builtin.file:
6875
path: "{{ src_directory }}"
6976
state: directory
7077
mode: "0755"
7178

79+
- name: Revert TLS changes to avoid git conflicts (upgrade)
80+
ansible.builtin.shell:
81+
cmd: >-
82+
if [[ -f {{ kayobe_environment_path }}/kolla/globals-tls-config.yml ]]; then
83+
sed -i 's/^kolla_enable_tls_internal: true/# kolla_enable_tls_internal: true/g' {{ kayobe_environment_path }}/kolla.yml
84+
fi
85+
when: upgrade | bool
86+
vars:
87+
kayobe_environment_path: "{{ src_directory }}/kayobe-config/etc/kayobe/environments/{{ kayobe_config_environment }}"
88+
89+
- name: Stash Kayobe Config changes (upgrade)
90+
ansible.builtin.command:
91+
cmd: git stash
92+
chdir: "{{ src_directory }}/{{ kayobe_config_name }}"
93+
when: upgrade | bool
94+
7295
- name: Ensure Kayobe Config repository is present
7396
ansible.builtin.git:
7497
repo: "{{ kayobe_config_repo }}"
7598
version: "{{ kayobe_config_version }}"
7699
dest: "{{ src_directory }}/{{ kayobe_config_name }}"
77-
update: false
100+
update: "{{ upgrade | bool }}"
101+
102+
- name: Pop stashed Kayobe Config changes (upgrade)
103+
ansible.builtin.command:
104+
cmd: git stash pop
105+
chdir: "{{ src_directory }}/{{ kayobe_config_name }}"
106+
when: upgrade | bool
107+
108+
- name: Replace TLS changes to avoid git conflicts (upgrade)
109+
ansible.builtin.shell:
110+
cmd: >-
111+
if [[ -f {{ kayobe_environment_path }}/kolla/globals-tls-config.yml ]]; then
112+
sed -i 's/# kolla_enable_tls_internal: true/kolla_enable_tls_internal: true/g' {{ kayobe_environment_path }}/kolla.yml
113+
fi
114+
when: upgrade | bool
115+
vars:
116+
kayobe_environment_path: "{{ src_directory }}/kayobe-config/etc/kayobe/environments/{{ kayobe_config_environment }}"
78117

79118
- name: Ensure hooks directory are present
80119
ansible.builtin.file:
@@ -103,7 +142,6 @@
103142
- { src: fix-networking.yml, dest: infra-vm-host-configure/pre.d/15-fix-networking.yml }
104143
- { src: configure-vxlan.yml, dest: infra-vm-host-configure/pre.d/20-configure-vxlan.yml }
105144

106-
107145
- name: Ensure Admin Overcloud Network file is present
108146
ansible.builtin.copy:
109147
src: "files/admin-oc-networks.yml"
@@ -116,6 +154,15 @@
116154
dest: "{{ src_directory }}/{{ kayobe_config_name }}/etc/kayobe/environments/{{ kayobe_config_environment }}/inventory/hosts"
117155
mode: "0644"
118156

157+
- name: Ensure multinode.sh script is present
158+
ansible.builtin.copy:
159+
src: "files/multinode.sh"
160+
dest: "/usr/local/bin/multinode.sh"
161+
mode: "0755"
162+
become: true
163+
tags:
164+
- multinode.sh
165+
119166
- name: Ensure root_domain is defined
120167
ansible.builtin.lineinfile:
121168
path: "{{ src_directory }}/{{ kayobe_config_name }}/etc/kayobe/environments/{{ kayobe_config_environment }}/inventory/group_vars/all/main.yml"
@@ -162,9 +209,15 @@
162209
repo: "{{ kayobe_repo }}"
163210
version: "{{ kayobe_version or 'stackhpc/' ~ openstack_release.stdout }}"
164211
dest: "{{ src_directory }}/{{ kayobe_name }}"
165-
update: false
212+
update: "{{ upgrade | bool }}"
166213
when: kayobe_src_required
167214

215+
- name: Ensure `venvs` directory is absent (upgrade)
216+
ansible.builtin.file:
217+
path: "{{ ansible_env.HOME }}/venvs"
218+
state: absent
219+
when: upgrade | bool
220+
168221
- name: Ensure `venvs` directory exists
169222
ansible.builtin.file:
170223
path: "{{ ansible_env.HOME }}/venvs"
@@ -231,6 +284,15 @@
231284
key: "{{ item }}"
232285
loop: "{{ extra_ssh_public_keys }}"
233286

287+
- name: "{% if upgrade | bool %}Upgrade{% else %}Bootstrap{% endif %} control host"
288+
ansible.builtin.shell:
289+
cmd: |-
290+
set -eu
291+
source {{ ansible_env.HOME }}/venvs/kayobe/bin/activate
292+
source {{ src_directory }}/{{ kayobe_config_name }}/kayobe-env --environment {{ kayobe_config_environment }}
293+
export KAYOBE_VAULT_PASSWORD="$(cat ~/vault.password)"
294+
kayobe control host {% if upgrade | bool %}upgrade{% else %}bootstrap{% endif %}
295+
234296
- name: Ensure OpenStack Config repository is present
235297
ansible.builtin.git:
236298
repo: "{{ openstack_config_repo }}"
@@ -278,13 +340,6 @@
278340
dest: "{{ src_directory }}/{{ openstack_config_name }}/ansible/inventory"
279341
mode: 0644
280342

281-
- name: Ensure `deploy-openstack.sh` script is present
282-
ansible.builtin.copy:
283-
src: "files/deploy-openstack.sh"
284-
dest: "{{ ansible_env.HOME }}/deploy-openstack.sh"
285-
mode: "755"
286-
tags: deploy-openstack
287-
288343
- name: Ensure docker repository is present
289344
ansible.builtin.command:
290345
cmd: dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

ansible/deploy-openstack.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
hosts: ansible_control
44
gather_facts: false
55
vars:
6+
multinode_command: "deploy_full"
67
# 6 hours should be enough...
78
deployment_timeout_s: "{{ 6 * 60 * 60 }}"
89
lock_path: /tmp/deploy-openstack.lock
@@ -30,7 +31,7 @@
3031
pipe-pane -t {{ tmux_session }} -o 'cat >> ~/tmux.#S:#P.log'
3132
when: session_check.rc != 0
3233

33-
# deploy-openstack.sh uses a "lock" directory to ensure that only one
34+
# multinode.sh uses a "lock" directory to ensure that only one
3435
# instance can run concurrently.
3536
- name: Check that no deployment is in progress
3637
stat:
@@ -45,9 +46,9 @@
4546
directory and run this playbook again.
4647
when: lock_stat.stat.exists
4748

48-
- name: Run deploy-openstack.sh in tmux window
49+
- name: "Run multinode.sh {{ multinode_command }} in tmux window"
4950
command: >-
50-
tmux send -t {{ tmux_session }}.0 './deploy-openstack.sh' ENTER
51+
tmux send -t {{ tmux_session }}.0 'multinode.sh {{ multinode_command }}' ENTER
5152
5253
- name: Show how to follow deployment progress
5354
debug:
@@ -57,11 +58,11 @@
5758
5859
{{ connection_info }}
5960
60-
- name: Wait for deploy-openstack.sh to start
61+
- name: "Wait for multinode.sh {{ multinode_command }} to start"
6162
pause:
6263
seconds: 30
6364

64-
- name: Wait for deployment to complete
65+
- name: "Wait for multinode.sh {{ multinode_command }} to complete"
6566
stat:
6667
path: "{{ lock_path }}"
6768
register: lock_stat
@@ -70,13 +71,13 @@
7071
delay: 10
7172
failed_when: false
7273

73-
# deploy-openstack.sh writes an exit code to a file. 0 is success
74-
- name: Check deployment result
74+
# multinode.sh writes an exit code to a file. 0 is success
75+
- name: "Check multinode.sh {{ multinode_command }} result"
7576
slurp:
7677
path: "{{ rc_path }}"
7778
register: rc_slurp
7879

79-
- name: Fail if deployment was unsuccessful
80+
- name: "Fail if multinode.sh {{ multinode_command }} was unsuccessful"
8081
fail:
8182
msg: |
8283
Deployment or testing of OpenStack was unsuccessful.

0 commit comments

Comments
 (0)