Skip to content

Commit 8932c15

Browse files
authored
fix: Another attempt at fixing git-clean permission issues (chown -R) (#325)
We're still seeing the issue. Remove the safe-directory stuff (which might have worked if we dropped the `become_user`, but was probably more complicated than necessary) and instead just `chown -R` the repo before doing the clean. Hopefully that does it.
1 parent 2d95afc commit 8932c15

File tree

1 file changed

+7
-28
lines changed

1 file changed

+7
-28
lines changed

playbooks/roles/edxapp/tasks/deploy.yml

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -45,39 +45,18 @@
4545
- install
4646
- install:base
4747

48-
# Do A Checkout
49-
# Ensure correct ownership of edx-platform directory before git operations
50-
# to avoid Git's "dubious ownership" protection (introduced in Git 2.35.2+)
51-
- name: ensure edx-platform directory is owned by {{ edxapp_user }}
48+
# Ensure all files in code dir are owned by the edxapp user. For unknown
49+
# reasons, we sometimes get stale files here that are owned by root or some
50+
# other user. (From successive builds of the same edx-platform commit sharing a
51+
# builder instance, perhaps?) This then causes `git clean` to fail with
52+
# "Permission denied" on various static-asset paths.
53+
- name: ensure edx-platform repo files are owned by {{ edxapp_user }}
5254
file:
5355
path: "{{ edxapp_code_dir }}"
5456
state: directory
5557
owner: "{{ edxapp_user }}"
5658
group: "{{ edxapp_user }}"
57-
# Do not recurse - git module will handle file ownership within the repo
58-
recurse: no
59-
tags:
60-
- install
61-
- install:code
62-
63-
# Configure Git safe.directory for edxapp user to prevent "dubious ownership" errors
64-
# when running git commands on the edx-platform repository. Uses --global scope
65-
# (not --local) because the configuration is needed before the repository is cloned.
66-
- name: check if edx-platform is already in git safe.directory
67-
command: git config --global --get-all safe.directory
68-
become_user: "{{ edxapp_user }}"
69-
register: safe_directory_check
70-
changed_when: false
71-
# Git config returns exit code 1 when no entries exist, which is expected
72-
failed_when: false
73-
tags:
74-
- install
75-
- install:code
76-
77-
- name: add edx-platform to git safe.directory
78-
command: git config --global --add safe.directory '{{ edxapp_code_dir }}'
79-
become_user: "{{ edxapp_user }}"
80-
when: edxapp_code_dir not in (safe_directory_check.stdout_lines | default([]))
59+
recurse: yes
8160
tags:
8261
- install
8362
- install:code

0 commit comments

Comments
 (0)