diff --git a/ansible/nginx-http.conf.j2 b/ansible/nginx-http.conf.j2 index 9c4cac382..b5ab85ebf 100644 --- a/ansible/nginx-http.conf.j2 +++ b/ansible/nginx-http.conf.j2 @@ -39,7 +39,7 @@ http { } location /media/ { - alias /home/{{ vps_user }}/{{ project_name }}/media/; + alias {{ media_dir }}/; } location / { diff --git a/ansible/playbook.yml b/ansible/playbook.yml index cfd949850..dc23dd54a 100644 --- a/ansible/playbook.yml +++ b/ansible/playbook.yml @@ -7,6 +7,7 @@ vps_user: django project_name: education-website project_root: /home/{{ vps_user }}/{{ project_name }} + media_dir: /home/{{ vps_user }}/media # NOTE: Updated to point to the canonical repo that now contains new management commands (e.g., dbdiag). # Previously this pointed to https://github.com/AlphaOneLabs/education-website.git which lacked recent commits. git_repo: "https://github.com/AlphaOneLabs/alphaonelabs-education-website.git" @@ -306,12 +307,21 @@ - name: Ensure media directory exists and readable file: - path: "{{ project_root }}/media" + path: "{{ media_dir }}" state: directory mode: '0755' owner: "{{ vps_user }}" group: "{{ vps_user }}" + - name: Symlink media directory + file: + src: "{{ media_dir }}" + dest: "{{ project_root }}/media" + state: link + owner: "{{ vps_user }}" + group: "{{ vps_user }}" + force: true + - name: Configure nginx template: src: nginx-http.conf.j2