Skip to content

Commit

Permalink
Replace web_root with django_root and drop soft-linked web root
Browse files Browse the repository at this point in the history
  • Loading branch information
neoformit committed Sep 29, 2024
1 parent 2fa0d81 commit b50902f
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion deploy/ansible/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ python -m pip install ansible
- *Optional* - Host installation paths:
- `project_root` - where this git repository will be cloned
- `server_root` - where server configuration will be saved
- `web_root` - where the application will be served from
- `django_root` - where the application will be served from
- `venv_root` - where the virtual env will be created


Expand Down
2 changes: 1 addition & 1 deletion deploy/ansible/group_vars/webservers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ project_root: /srv/sites/galaxy-media-site
server_root: /srv/config

# App will be served from here
web_root: "{{ project_root }}/webapp"
django_root: "{{ project_root }}/webapp"

# Virtual environment will be created here
venv_root: "{{ project_root }}/venv"
Expand Down
2 changes: 1 addition & 1 deletion deploy/ansible/group_vars/webservers.yml.sample
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ project_root: /home/ubuntu/galaxy-content-site
server_root: /home/ubuntu/serve

# App will be served from here
web_root: /srv/webapp
django_root: /srv/webapp

# Virtual environment will be created here
venv_root: "{{ project_root }}/.venv"
Expand Down
2 changes: 1 addition & 1 deletion deploy/ansible/roles/galaxy_media_site/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
project_root: /home/ubuntu/galaxy-content-site
server_root: /home/ubuntu/server
web_root: /srv/webapp
django_root: /srv/webapp
venv_root: "{{ project_root }}/venv"

webapp:
Expand Down
14 changes: 7 additions & 7 deletions deploy/ansible/roles/galaxy_media_site/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@

- name: create webapp media directory
file:
path: "{{ web_root }}/webapp/media"
path: "{{ django_root }}/webapp/media"
state: directory

- name: create webapp logs directory
file:
path: "{{ web_root }}/webapp/logs"
path: "{{ django_root }}/webapp/logs"
state: directory

- name: template webserver configuration
Expand Down Expand Up @@ -82,7 +82,7 @@

- name: Ensure webapp superuser login
shell: |
cd {{ web_root }} && \
cd {{ django_root }} && \
export DJANGO_SUPERUSER_PASSWORD={{ admin_user.password }} && \
{{ venv_root }}/bin/python manage.py createsuperuser --noinput \
--email {{ admin_user.email }} \
Expand All @@ -100,18 +100,18 @@
group: ubuntu

- name: update media file ownership
file: dest={{ web_root }}/webapp/media owner=www-data group=www-data mode=u=rwX,g=rwX,o=rwX recurse=yes
file: dest={{ django_root }}/webapp/media owner=www-data group=www-data mode=u=rwX,g=rwX,o=rwX recurse=yes

- name: update log file ownership
file: dest={{ web_root }}/webapp/logs owner=www-data group=www-data mode=u=rwX,g=rwX,o=rwX recurse=yes
file: dest={{ django_root }}/webapp/logs owner=www-data group=www-data mode=u=rwX,g=rwX,o=rwX recurse=yes

- name: make update.sh executable
file: dest=/home/ubuntu/update.sh mode=a+x

- name: check whether news scraper in GMS version
ansible.builtin.shell: "{{ venv_root }}/bin/python manage.py scrape_news --help"
args:
chdir: "{{ web_root }}"
chdir: "{{ django_root }}"
register: check_scraper

- name: add cron job to scrape news feed
Expand All @@ -120,5 +120,5 @@
user: ubuntu
hour: 9
minute: 0
job: "cd {{ web_root }} && {{ venv_root }}/bin/python manage.py scrape_news"
job: "cd {{ django_root }} && {{ venv_root }}/bin/python manage.py scrape_news"
when: check_scraper.rc == 0
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ server {
}

location = /favicon.ico {
alias {{ web_root }}/webapp/static/favicon/favicon.ico;
alias {{ django_root }}/webapp/static/favicon/favicon.ico;
}

location /static {
root {{ web_root }}/webapp;
root {{ django_root }}/webapp;
}

location /media {
root {{ web_root }}/webapp;
root {{ django_root }}/webapp;
}

location / {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ PIDFile=/run/gunicorn/pid
User = www-data
Group = www-data
RuntimeDirectory=gunicorn
WorkingDirectory={{ web_root }}
WorkingDirectory={{ django_root }}
Environment="PATH={{ venv_root }}/.venv/bin:$PATH"
ExecStart={{ venv_root }}/bin/gunicorn --pid /run/gunicorn/pid \
--bind unix:/run/webapp.sock \
Expand Down

0 comments on commit b50902f

Please sign in to comment.