Skip to content

Commit eb97b50

Browse files
authored
Merge pull request #64 from stackhpc/multinode.sh
Refactor deploy-openstack.sh into multinode.sh
2 parents 1b67079 + a8b5180 commit eb97b50

File tree

8 files changed

+623
-265
lines changed

8 files changed

+623
-265
lines changed

README.rst

Lines changed: 70 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,64 @@ This configuration is typically used with the `ci-multinode` environment in the
2525
<https://stackhpc-kayobe-config.readthedocs.io/en/stackhpc-2023.1/contributor/environments/ci-multinode.html>`__
2626
repository.
2727

28+
What's in the box?
29+
==================
30+
31+
This repository contains various items.
32+
33+
Scripts
34+
-------
35+
36+
* ``scripts/deploy.sh`` - end-to-end cluster deployment and testing.
37+
* ``scripts/tear-down.sh`` - tear down test cluster infrastructure.
38+
39+
Terraform
40+
---------
41+
42+
Terraform configuration deploys test cluster infrastructure on an OpenStack
43+
cloud. It provides outputs that can be used to populate Kayobe Configuration
44+
with the details of the test infrastructure.
45+
46+
Ansible
47+
-------
48+
49+
Ansible playbooks in the ``ansible/`` directory are provided to prepare and use
50+
the Ansible control host.
51+
52+
#. ``configure-hosts.yml`` - sequentially executes 3 other playbooks:
53+
54+
#. ``wait-control-host.yml`` - Waits for the Ansible control host to become
55+
accessible and ready for deployment. Tag: ``wait``
56+
#. ``grow-control-host.yml`` - Applies LVM configuration to the control host
57+
to ensure it has enough space to continue with the rest of the
58+
deployment. Tag: ``lvm``
59+
#. ``deploy-openstack-config.yml`` - Prepares the Ansible control host as a
60+
Kayobe control host, cloning the Kayobe configuration and installing
61+
virtual environments. Tag: ``deploy``
62+
63+
These playbooks are tagged so that they can be invoked or skipped using
64+
`tags` or `--skip-tags` as required.
65+
66+
#. ``deploy-openstack.yml`` - runs the ``multinode.sh deploy_full`` command in
67+
a `tmux` session on the Ansible control host. The session is logged to
68+
``~/tmux.kayobe\:0.log`` on the Ansible control host. Use ``less -r
69+
~/tmux.kayobe\:0.log`` to view the logs in their original colourful glory.
70+
71+
#. ``fetch-logs.yml`` - fetches logs, diagnostics and tests results from the
72+
cluster to the host runnin the playbook..
73+
74+
Configuration variables for these playbooks are in
75+
``ansible/vars/defaults.yml``.
76+
77+
multinode.sh
78+
------------
79+
80+
The ``multinode.sh`` script is installed in ``/usr/local/bin/`` on the Ansible
81+
control host. It provides high-level automation of various aspects of OpenStack
82+
deployment, operations and testing. It accepts a single argument which is the
83+
command to perform. The supported commands may be listed by running it without
84+
arguments.
85+
2886
Prerequisites
2987
=============
3088

@@ -63,7 +121,7 @@ Initialise Terraform:
63121
terraform init
64122
65123
Generate an SSH keypair. Note that `ED25519 keys are not currently supported by RHEL
66-
<https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/9/html-single/securing_networks/index#making-openssh-more-secure_assembly_using-secure-communications-between-two-systems-with-openssh>`__
124+
<https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/9/html-single/securing_networks/index#making-openssh-more-secure_assembly_using-secure-communications-between-two-systems-with-openssh>`__
67125
when using the FIPS security standard (as enabled by the CIS benchmark hardening
68126
scripts in kayobe-config). The public key will be registered in OpenStack as a
69127
keypair and authorised by the instances deployed by Terraform. The private and
@@ -187,7 +245,7 @@ access to the control host.
187245
Configure Ansible variables
188246
===========================
189247

190-
Review the vars defined within `ansible/vars/defaults.yml`. In here you can customise the version of kayobe, kayobe-config or openstack-config.
248+
Review the vars defined within `ansible/vars/defaults.yml`. In here you can customise the version of kayobe, kayobe-config or openstack-config.
191249
Make sure to define `ssh_key_path` to point to the location of the SSH key in use by the nodes and also `vxlan_vni` which should be unique value between 1 to 100,000.
192250
VNI should be much smaller than the officially supported limit of 16,777,215 as we encounter errors when attempting to bring interfaces up that use a high VNI.
193251
You must set `vault_password_path`; this should be set to the path to a file containing the Ansible vault password.
@@ -201,7 +259,7 @@ Tempest testing without user interaction. Any errors encountered will be
201259
reported and halt the deployment.
202260

203261
This script makes use of the `ansible/deploy-openstack.yml` Ansible playbook
204-
that runs the `deploy-openstack.sh` script in a `tmux` session on the Ansible
262+
that runs the `multinode.sh deploy_full` command in a `tmux` session on the Ansible
205263
control host. The session is logged to `~/tmux.kayobe\:0.log` on the Ansible
206264
control host. Use `less -r ~/tmux.kayobe\:0.log` to view the logs in their
207265
original colourful glory.
@@ -255,30 +313,24 @@ Run the configure-hosts.yml playbook to configure the Ansible control host.
255313
256314
ansible-playbook -i ansible/inventory.yml ansible/configure-hosts.yml
257315
258-
This playbook sequentially executes 2 other playbooks:
259-
260-
#. ``grow-control-host.yml`` - Applies LVM configuration to the control host to ensure it has enough space to continue with the rest of the deployment. Tag: ``lvm``
261-
#. ``deploy-openstack-config.yml`` - Prepares the Ansible control host as a Kayobe control host, cloning the Kayobe configuration and installing virtual environments. Tag: ``deploy``
262-
263-
These playbooks are tagged so that they can be invoked or skipped using `tags` or `--skip-tags` as required.
264-
265316
Deploy OpenStack
266317
----------------
267318

268319
Once the Ansible control host has been configured with a Kayobe/OpenStack configuration you can then begin the process of deploying OpenStack.
269-
This can be achieved by either manually running the various commands to configure the hosts and deploy the services or automated by using the generated `deploy-openstack.sh` script.
270-
`deploy-openstack.sh` should be available within the home directory on your Ansible control host provided you ran `deploy-openstack-config.yml` earlier.
320+
This can be achieved by either manually running the various commands to configure the hosts and deploy the services or automated by using the ``multinode.sh deploy_full`` command.
321+
``multinode.sh`` should be available within ``/usr/local/bin/`` on your Ansible control host provided you ran `deploy-openstack-config.yml` earlier.
271322
This script will go through the process of performing the following tasks:
272323

273324
* kayobe control host bootstrap
274325
* kayobe seed host configure
275326
* kayobe overcloud host configure
276327
* cephadm deployment
328+
* HashiCorp Vault deployment & certificate generation
277329
* kayobe overcloud service deploy
278-
* openstack configuration
279-
* tempest testing
330+
* OpenStack configuration
331+
* Tempest testing
280332

281-
Tempest test results will be written to `~/tempest-artifacts`.
333+
Tempest test results will be written to ``~/tempest-artifacts``.
282334

283335
If you choose to opt for the automated method you must first SSH into your Ansible control host.
284336

@@ -292,11 +344,11 @@ Start a `tmux` session to avoid halting the deployment if you are disconnected.
292344
293345
tmux
294346
295-
Run the `deploy-openstack.sh` script.
347+
Run the `multinode.sh` script.
296348

297349
.. code-block:: console
298350
299-
~/deploy-openstack.sh
351+
multinode.sh deploy_full
300352
301353
Accessing OpenStack
302354
===================
@@ -308,7 +360,7 @@ Using software such as sshuttle will allow for easy access.
308360
309361
sshuttle -r $(terraform output -raw ssh_user)@$(terraform output -raw seed_access_ip_v4) 192.168.39.0/24
310362
311-
You may also use sshuttle to proxy DNS via the multinode environment. Useful if you are working with Designate.
363+
You may also use sshuttle to proxy DNS via the multinode environment. Useful if you are working with Designate.
312364
Important to node this will proxy all DNS requests from your machine to the first controller within the multinode environment.
313365

314366
.. code-block:: console

ansible/deploy-openstack-config.yml

Lines changed: 71 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"
@@ -225,6 +278,21 @@
225278
dest: "{{ ansible_env.HOME }}/.ssh/id_rsa"
226279
mode: "0600"
227280

281+
- name: Ensure additional public keys are authorised
282+
ansible.posix.authorized_key:
283+
user: "{{ ansible_user }}"
284+
key: "{{ item }}"
285+
loop: "{{ extra_ssh_public_keys }}"
286+
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+
228296
- name: Ensure OpenStack Config repository is present
229297
ansible.builtin.git:
230298
repo: "{{ openstack_config_repo }}"
@@ -272,13 +340,6 @@
272340
dest: "{{ src_directory }}/{{ openstack_config_name }}/ansible/inventory"
273341
mode: 0644
274342

275-
- name: Ensure `deploy-openstack.sh` script is present
276-
ansible.builtin.copy:
277-
src: "files/deploy-openstack.sh"
278-
dest: "{{ ansible_env.HOME }}/deploy-openstack.sh"
279-
mode: "755"
280-
tags: deploy-openstack
281-
282343
- name: Ensure docker repository is present
283344
ansible.builtin.command:
284345
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)