Skip to content

Commit 9202db2

Browse files
Kolla-Ansible/Kayobe version enforcement (#1551)
* Check Kayobe version playbook * Fix pipefail * Ignore linter * Include tag option * Hook for overcloud host upgrade * Check on control host upgrade * Include remaining hooks * Clarify fail message for unexpected current versions * Kolla-Ansible version check playbook * Add pip 24 precheck * Kolla-Ansible check hooks * service upgrade hook * s/latest/expected/g * Fixup Reno * Add hook for host configure * Include option to skip in config * Make linter happy * Ensure commit hash is not empty * Update links * Fix playbook lint * Apply suggestions from code review Co-authored-by: Alex-Welsh <[email protected]> --------- Co-authored-by: Alex-Welsh <[email protected]>
1 parent 4834cf6 commit 9202db2

27 files changed

+133
-0
lines changed

.ansible-lint-ignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ etc/kayobe/ansible/vault-generate-internal-tls.yml fqcn[action-core]
55
etc/kayobe/ansible/vault-generate-test-external-tls.yml fqcn[action-core]
66
etc/kayobe/ansible/rabbitmq-reset.yml command-instead-of-module
77
etc/kayobe/ansible/ubuntu-upgrade.yml syntax-check[missing-file]
8+
etc/kayobe/ansible/check-kayobe-version.yml command-instead-of-module
9+
etc/kayobe/ansible/check-kolla-ansible-version.yml command-instead-of-module
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
- name: Check Kayobe version
3+
tags: kayobe-version-check
4+
hosts: localhost
5+
gather_facts: false
6+
vars:
7+
requirements_path: "{{ kayobe_config_path }}/../../requirements.txt"
8+
tasks:
9+
- name: Check version
10+
when: stackhpc_enable_kayobe_check
11+
block:
12+
- name: Get package info
13+
community.general.pip_package_info:
14+
register: packages
15+
16+
- name: Check if pip is version 24.0 or newer
17+
ansible.builtin.assert:
18+
that: "{{ packages.packages.pip.pip[0].version is version('24.0', '>=') }}"
19+
fail_msg: |
20+
Pip must be 24.0 or newer to run this check. Upgrade pip by running
21+
pip install -U pip and reinstall Kayobe by running:
22+
pip install --force-reinstall -r {{ requirements_path }}
23+
24+
- name: Get installed Kayobe commit
25+
ansible.builtin.shell:
26+
cmd: set -o pipefail && pip freeze | grep kayobe | cut -d @ -f 3
27+
executable: /usr/bin/bash
28+
register: kayobe_git_commit
29+
failed_when: kayobe_git_commit.stdout == ""
30+
31+
- name: Clone Kayobe
32+
ansible.builtin.git:
33+
repo: https://github.com/stackhpc/kayobe.git
34+
dest: /tmp/kayobe-git
35+
version: stackhpc/{{ openstack_release }}
36+
37+
- name: Get tag from Kayobe commit
38+
ansible.builtin.command:
39+
cmd: git describe --tags {{ kayobe_git_commit.stdout }}
40+
chdir: /tmp/kayobe-git
41+
register: kayobe_current_version
42+
43+
- name: Get latest Kayobe version
44+
ansible.builtin.shell:
45+
cmd: set -o pipefail && grep -o kayobe@stackhpc\/.*$ {{ requirements_path }} | cut -d @ -f 2
46+
executable: /usr/bin/bash
47+
register: kayobe_latest_version
48+
49+
- name: Check installed Kayobe version is the latest
50+
ansible.builtin.assert:
51+
that: "kayobe_latest_version.stdout in kayobe_current_version.stdout"
52+
fail_msg: |
53+
Kayobe must use the expected version before continuing.
54+
55+
Current Kayobe version: {{ kayobe_current_version.stdout }}
56+
Expected Kayobe version: {{ kayobe_latest_version.stdout }}
57+
58+
Recreate the Kayobe environment, or install the expected version
59+
by running: pip install --force-reinstall -r {{ requirements_path }}
60+
success_msg: |
61+
Kayobe running at version: {{ kayobe_current_version.stdout }}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
- name: Check Kolla-Ansible version
3+
tags: kolla-ansible-version-check
4+
hosts: localhost
5+
gather_facts: false
6+
tasks:
7+
- name: Check version
8+
when: stackhpc_enable_kolla_ansible_check
9+
block:
10+
- name: Get current Kolla-Ansible tag
11+
ansible.builtin.command:
12+
cmd: git describe --tags
13+
chdir: "{{ lookup('ansible.builtin.env', 'KOLLA_SOURCE_PATH') }}"
14+
register: kolla_ansible_current_version
15+
16+
- name: Check installed Kolla-Ansible version is the expected version
17+
ansible.builtin.assert:
18+
that: "stackhpc_kolla_ansible_source_version in kolla_ansible_current_version.stdout"
19+
fail_msg: |
20+
Kolla-Ansible must use the expected version before continuing.
21+
22+
Current Kolla-Ansible version: {{ kolla_ansible_current_version.stdout }}
23+
Expected Kolla-Ansible version: {{ stackhpc_kolla_ansible_source_version }}
24+
25+
Upgrade Kolla-Ansible by running: kayobe control host upgrade
26+
success_msg: |
27+
Kolla-Ansible running at version: {{ kolla_ansible_current_version.stdout }}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../ansible/check-kayobe-version.yml
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../ansible/check-kayobe-version.yml
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../ansible/check-kayobe-version.yml
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../ansible/check-kolla-ansible-version.yml
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../ansible/check-kayobe-version.yml
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../ansible/check-kolla-ansible-version.yml
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../ansible/check-kayobe-version.yml
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../ansible/check-kolla-ansible-version.yml
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../ansible/check-kayobe-version.yml
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../ansible/check-kolla-ansible-version.yml
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../ansible/check-kayobe-version.yml
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../ansible/check-kolla-ansible-version.yml
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../ansible/check-kayobe-version.yml
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../ansible/check-kolla-ansible-version.yml
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../ansible/check-kayobe-version.yml
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../ansible/check-kolla-ansible-version.yml
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../ansible/check-kayobe-version.yml
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../ansible/check-kolla-ansible-version.yml
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../ansible/check-kayobe-version.yml
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../ansible/check-kolla-ansible-version.yml
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../ansible/check-kayobe-version.yml
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../ansible/check-kolla-ansible-version.yml

etc/kayobe/stackhpc.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,14 @@ stackhpc_docker_registry_password: "{{ pulp_password }}"
187187
# Whether or not to run CIS benchmark hardening playbooks. Default is false.
188188
#stackhpc_enable_cis_benchmark_hardening_hook:
189189

190+
# Whether or not to check the installed Kayobe version when running Kayobe commands.
191+
# Default is true.
192+
stackhpc_enable_kayobe_check: true
193+
194+
# Whether or not to check the installed Kolla-Ansible version when running Kayobe commands.
195+
# Default is true.
196+
stackhpc_enable_kolla_ansible_check: true
197+
190198
###############################################################################
191199
# Octavia Amphora image
192200

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
---
2+
features:
3+
- |
4+
Added playbooks to check the installed Kayobe/Kolla-Ansible versions
5+
against the expected versions in Kayobe configuration. These checks
6+
will run on Kayobe bootstrap, host and service operations.
7+
upgrade:
8+
- |
9+
Kolla Ansible and Kayobe version checks are enabled by default which
10+
may fail on existing deployments using custom forks or branches for
11+
Kayobe and Kolla-Ansible. To disable version checks in configuration
12+
set ``stackhpc_enable_kayobe_check`` and
13+
``stackhpc_enable_kolla_ansible_check`` to false.

0 commit comments

Comments
 (0)