Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 26 additions & 18 deletions etc/kayobe/ansible/check-kayobe-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,47 +26,55 @@
ansible.builtin.shell:
cmd: set -o pipefail && pip freeze | grep kayobe | cut -d @ -f 3
executable: /usr/bin/bash
register: kayobe_git_commit
failed_when: kayobe_git_commit.stdout == ""
register: kayobe_current_commit
failed_when: kayobe_current_commit.stdout == ""

- name: Create a temporary directory to clone Kayobe into
ansible.builtin.tempfile:
state: directory
register: kayobe_temp_dir

- name: Clone Kayobe
- name: Get expected Kayobe version
ansible.builtin.shell:
cmd: set -o pipefail && grep -o kayobe@.*$ {{ requirements_path }} | cut -d @ -f 3
executable: /usr/bin/bash
register: kayobe_expected_version

- name: Clone Kayobe at the expected version
ansible.builtin.git:
repo: https://github.com/stackhpc/kayobe.git
dest: "{{ kayobe_temp_dir.path }}/kayobe-git"
version: stackhpc/{{ openstack_release }}
version: "{{ kayobe_expected_version.stdout }}"

- name: Get tag from Kayobe commit
- name: Get tag from current Kayobe commit

Check warning on line 49 in etc/kayobe/ansible/check-kayobe-version.yml

View workflow job for this annotation

GitHub Actions / Ansible 2.18 lint with Python 3.12

command-instead-of-module

git used in place of git module

Check warning on line 49 in etc/kayobe/ansible/check-kayobe-version.yml

View workflow job for this annotation

GitHub Actions / Ansible 2.17 lint with Python 3.10

command-instead-of-module

git used in place of git module
ansible.builtin.command:
cmd: git describe --tags {{ kayobe_git_commit.stdout }}
cmd: git describe --tags {{ kayobe_current_commit.stdout }}
chdir: "{{ kayobe_temp_dir.path }}/kayobe-git"
register: kayobe_current_version
register: kayobe_current_tag

- name: Get commit from Kayobe checkout
ansible.builtin.command:
cmd: git rev-parse HEAD
chdir: "{{ kayobe_temp_dir.path }}/kayobe-git"
register: kayobe_expected_commit

- name: Clean up temporary directory
ansible.builtin.file:
state: absent
path: "{{ kayobe_temp_dir.path }}"

- name: Get latest Kayobe version
ansible.builtin.shell:
cmd: set -o pipefail && grep -o kayobe@stackhpc\/.*$ {{ requirements_path }} | cut -d @ -f 2
executable: /usr/bin/bash
register: kayobe_latest_version

- name: Check installed Kayobe version is the latest
- name: Check installed Kayobe version matches
ansible.builtin.assert:
that: "kayobe_latest_version.stdout in kayobe_current_version.stdout"
that: kayobe_current_commit.stdout in kayobe_expected_commit.stdout
fail_msg: |
Kayobe must use the expected version before continuing.

Current Kayobe version: {{ kayobe_current_version.stdout }}
Expected Kayobe version: {{ kayobe_latest_version.stdout }}
Current Kayobe commit: {{ kayobe_current_commit.stdout }}
Current Kayobe tag: {{ kayobe_current_tag.stdout }}
Expected Kayobe commit: {{ kayobe_expected_commit.stdout }}
Expected Kayobe version: {{ kayobe_expected_version.stdout }}

Recreate the Kayobe environment, or install the expected version
by running: pip install --force-reinstall -r {{ requirements_path }}
success_msg: |
Kayobe running at version: {{ kayobe_current_version.stdout }}
Kayobe running at version: {{ kayobe_expected_version.stdout }}
28 changes: 23 additions & 5 deletions etc/kayobe/ansible/check-kolla-ansible-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,39 @@
when: stackhpc_enable_kolla_ansible_check
check_mode: false
block:
- name: Get current Kolla-Ansible tag

Check warning on line 11 in etc/kayobe/ansible/check-kolla-ansible-version.yml

View workflow job for this annotation

GitHub Actions / Ansible 2.18 lint with Python 3.12

command-instead-of-module

git used in place of git module

Check warning on line 11 in etc/kayobe/ansible/check-kolla-ansible-version.yml

View workflow job for this annotation

GitHub Actions / Ansible 2.17 lint with Python 3.10

command-instead-of-module

git used in place of git module
ansible.builtin.command:
cmd: git describe --tags
chdir: "{{ lookup('ansible.builtin.env', 'KOLLA_SOURCE_PATH') }}"
register: kolla_ansible_current_version
register: kolla_ansible_current_tag

- name: Get current Kolla-Ansible branch
ansible.builtin.command:
cmd: git branch --show-current
chdir: "{{ lookup('ansible.builtin.env', 'KOLLA_SOURCE_PATH') }}"
register: kolla_ansible_current_branch

- name: Get current Kolla-Ansible commit
ansible.builtin.command:
cmd: git rev-parse HEAD
chdir: "{{ lookup('ansible.builtin.env', 'KOLLA_SOURCE_PATH') }}"
register: kolla_ansible_current_commit

- name: Check installed Kolla-Ansible version is the expected version
ansible.builtin.assert:
that: "stackhpc_kolla_ansible_source_version in kolla_ansible_current_version.stdout"
that: >
stackhpc_kolla_ansible_source_version in kolla_ansible_current_tag.stdout or
stackhpc_kolla_ansible_source_version in kolla_ansible_current_branch.stdout or
stackhpc_kolla_ansible_source_version in kolla_ansible_current_commit.stdout
fail_msg: |
Kolla-Ansible must use the expected version before continuing.
Kolla-Ansible must use the expected version before continuing. Either the
tag, branch, or commit should match the expected version.

Current Kolla-Ansible version: {{ kolla_ansible_current_version.stdout }}
Current Kolla-Ansible tag: {{ kolla_ansible_current_tag.stdout }}
Current Kolla-Ansible branch: {{ kolla_ansible_current_branch.stdout if kolla_ansible_current_branch.stdout != "" else 'No branch found' }}
Current Kolla-Ansible commit: {{ kolla_ansible_current_commit.stdout }}
Expected Kolla-Ansible version: {{ stackhpc_kolla_ansible_source_version }}

Upgrade Kolla-Ansible by running: kayobe control host upgrade
success_msg: |
Kolla-Ansible running at version: {{ kolla_ansible_current_version.stdout }}
Kolla-Ansible running at version: {{ stackhpc_kolla_ansible_source_version }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
features:
- |
Updated the Kayobe and Kolla-Ansible version checks to support pinning to
branches or a specific commit.
Loading