commit f1d0c91619a89fb9f1bb374c1025d8be7b8a2937 Author: Dmitry Tantsur Date: Thu Sep 17 15:54:42 2020 +0200 Ensure that repositories are owned by the running users Currently requirements may end up owned by root. Change-Id: I563af83ddea9fe3392a486c049607151f361faa2 (cherry picked from commit 0ef62ca2dc49c81c52f8547869534cff3a215a71) diff --git a/playbooks/roles/bifrost-create-vm-nodes/tasks/main.yml b/playbooks/roles/bifrost-create-vm-nodes/tasks/main.yml index 285f5d9..6a2fb9a 100644 --- a/playbooks/roles/bifrost-create-vm-nodes/tasks/main.yml +++ b/playbooks/roles/bifrost-create-vm-nodes/tasks/main.yml @@ -113,6 +113,16 @@ clone: yes when: ci_testing_zuul | bool == false and copy_from_local_path | bool == false +- name: ensure ownership of requirements + file: + path: "{{ reqs_git_folder }}" + owner: "{{ ansible_env.SUDO_USER | default(ansible_user_id) }}" + group: "{{ ansible_user_gid }}" + recurse: yes + when: + - not ci_testing_zuul | bool + - not copy_from_local_path | bool + - name: copy requirements from local path command: cp -a {{ reqs_git_url }} {{ reqs_git_folder }} creates={{ reqs_git_folder }} when: ci_testing_zuul | bool == true or copy_from_local_path | bool == true diff --git a/playbooks/roles/bifrost-prep-for-install/tasks/main.yml b/playbooks/roles/bifrost-prep-for-install/tasks/main.yml index cf2cc9b..ffc0451 100644 --- a/playbooks/roles/bifrost-prep-for-install/tasks/main.yml +++ b/playbooks/roles/bifrost-prep-for-install/tasks/main.yml @@ -32,6 +32,17 @@ with_items: "{{ bifrost_install_sources }}" when: ci_testing_zuul | bool == false and copy_from_local_path | bool == false +- name: "Ensure ownership of repositories" + file: + path: "{{ item.git_folder }}" + owner: "{{ ansible_env.SUDO_USER | default(ansible_user_id) }}" + group: "{{ ansible_user_gid }}" + recurse: yes + loop: "{{ bifrost_install_sources }}" + when: + - not ci_testing_zuul | bool + - not copy_from_local_path | bool + - name: "Copy from local path" command: cp -a {{ item.git_url }} {{ item.git_folder }} creates={{ item.git_folder }} with_items: "{{ bifrost_install_sources }}" diff --git a/releasenotes/notes/repo-owner-41db02a4d0406a7a.yaml b/releasenotes/notes/repo-owner-41db02a4d0406a7a.yaml new file mode 100644 index 0000000..f2a38fc --- /dev/null +++ b/releasenotes/notes/repo-owner-41db02a4d0406a7a.yaml @@ -0,0 +1,4 @@ +--- +fixes: + - | + Ensures that repositories are consistently owned by the calling user.