Skip to content

Commit e408c10

Browse files
committed
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.
1 parent d2a7883 commit e408c10

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

etc/kayobe/ansible/check-kayobe-version.yml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,28 @@
2929
register: kayobe_git_commit
3030
failed_when: kayobe_git_commit.stdout == ""
3131

32+
- name: Create a temporary directory to clone Kayobe into
33+
ansible.builtin.tempfile:
34+
state: directory
35+
register: kayobe_temp_dir
36+
3237
- name: Clone Kayobe
3338
ansible.builtin.git:
3439
repo: https://github.com/stackhpc/kayobe.git
35-
dest: /tmp/kayobe-git
40+
dest: "{{ kayobe_temp_dir.path }}/kayobe-git"
3641
version: stackhpc/{{ openstack_release }}
3742

3843
- name: Get tag from Kayobe commit
3944
ansible.builtin.command:
4045
cmd: git describe --tags {{ kayobe_git_commit.stdout }}
41-
chdir: /tmp/kayobe-git
46+
chdir: "{{ kayobe_temp_dir.path }}/kayobe-git"
4247
register: kayobe_current_version
4348

49+
- name: Clean up temporary directory
50+
ansible.builtin.file:
51+
state: absent
52+
path: "{{ kayobe_temp_dir.path }}"
53+
4454
- name: Get latest Kayobe version
4555
ansible.builtin.shell:
4656
cmd: set -o pipefail && grep -o kayobe@stackhpc\/.*$ {{ requirements_path }} | cut -d @ -f 2
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
fixes:
3+
- |
4+
Fix Kayobe version checks that were failing on multiuser
5+
Ansible control hosts.

0 commit comments

Comments
 (0)