From e408c101e54eee3574c80a90eda3637ff692bb1e Mon Sep 17 00:00:00 2001 From: Matt Anson Date: Fri, 11 Jul 2025 14:30:10 +0100 Subject: [PATCH] Clone Kayobe into a tempdir when doing version checks Cloning Kayobe as part of check-kayobe-version.yml would fail with POSIX permission errors when it was run by multiple users, because the clone destination directory is a) always the same and b) never cleaned up. Clone Kayobe into a unique directory each time using ansible.builtin.tempfile and clean up the directory tree when it is no longer needed. This ensures that each user that runs check-kayobe-version.yml gets a Kayobe checkout to a unique path, and not one that already exists and is owned by someone else. --- etc/kayobe/ansible/check-kayobe-version.yml | 14 ++++++++++++-- ...fix-kayobe-version-checks-d1fb3e09391e4a3e.yaml | 5 +++++ 2 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 releasenotes/notes/fix-kayobe-version-checks-d1fb3e09391e4a3e.yaml diff --git a/etc/kayobe/ansible/check-kayobe-version.yml b/etc/kayobe/ansible/check-kayobe-version.yml index b527fc5d8e..b893d806f0 100644 --- a/etc/kayobe/ansible/check-kayobe-version.yml +++ b/etc/kayobe/ansible/check-kayobe-version.yml @@ -29,18 +29,28 @@ register: kayobe_git_commit failed_when: kayobe_git_commit.stdout == "" + - name: Create a temporary directory to clone Kayobe into + ansible.builtin.tempfile: + state: directory + register: kayobe_temp_dir + - name: Clone Kayobe ansible.builtin.git: repo: https://github.com/stackhpc/kayobe.git - dest: /tmp/kayobe-git + dest: "{{ kayobe_temp_dir.path }}/kayobe-git" version: stackhpc/{{ openstack_release }} - name: Get tag from Kayobe commit ansible.builtin.command: cmd: git describe --tags {{ kayobe_git_commit.stdout }} - chdir: /tmp/kayobe-git + chdir: "{{ kayobe_temp_dir.path }}/kayobe-git" register: kayobe_current_version + - 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 diff --git a/releasenotes/notes/fix-kayobe-version-checks-d1fb3e09391e4a3e.yaml b/releasenotes/notes/fix-kayobe-version-checks-d1fb3e09391e4a3e.yaml new file mode 100644 index 0000000000..f185977a45 --- /dev/null +++ b/releasenotes/notes/fix-kayobe-version-checks-d1fb3e09391e4a3e.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + Fix Kayobe version checks that were failing on multiuser + Ansible control hosts.