Skip to content

Commit

Permalink
Add isimip-files role and fix issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jochenklar committed Aug 14, 2023
1 parent 82d4ce6 commit f43769e
Show file tree
Hide file tree
Showing 16 changed files with 32 additions and 37 deletions.
7 changes: 4 additions & 3 deletions group_vars/all.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
env: "prod"
data_url: "{% if env == 'prod' %}data.isimip.org{% else %}{{ env }}.isimip.org{% endif %}"
files_url: "files.isimip.org"
env: prod
data_url: data.isimip.org
data_gunicorn_port: 9000
files_url: files.isimip.org
2 changes: 2 additions & 0 deletions main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
become: yes
become_user: root
roles:
- role: isimip-files
tags: isimip-files
- role: isimip-files-api
tags: isimip-files-api
- role: isimip-publisher
Expand Down
2 changes: 0 additions & 2 deletions roles/config/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
---

- name: Copy /root/.bash_aliases
copy:
src: bash_aliases
Expand Down
9 changes: 8 additions & 1 deletion roles/isimip-data/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
- postgresql15-server
- postgresql15-devel
state: present

- name: Create /srv/www/prod or /srv/www/dev for isimip-data
file:
path: /srv/www/{{ env }}
Expand Down Expand Up @@ -59,3 +58,11 @@
dest: "/etc/systemd/system/{{ env }}.service"
notify:
- Restart gunicorn

- name: Create nginx config for data.isimip.org
template:
src: "{{ data_url }}.conf"
dest: /etc/nginx/vhosts.d/{{ data_url }}.conf
when: "'data' in group_names"
notify:
- Restart nginx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ server {
}
location /static/ {
add_header "Access-Control-Allow-Origin" *;
alias /home/isimip-data/{{ env }}/static_root/;
alias /home/isimip/{{ env }}/static_root/;
}
location /media/ {
alias /home/isimip/prod/media_root/;
alias /home/isimip/{{ env }}/media_root/;
}

error_page 502 /502.html;
Expand Down
8 changes: 8 additions & 0 deletions roles/isimip-data/templates/data.service
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ EnvironmentFile=/srv/www/{{ env }}/.env
LogsDirectory=django/{{ env }} gunicorn/{{ env }}
RuntimeDirectory=gunicorn/{{ env }}

Environment=GUNICORN_BIN=env/bin/gunicorn
Environment=GUNICORN_WORKER=3
Environment=GUNICORN_PORT={{ data_gunicorn_port }}
Environment=GUNICORN_TIMEOUT=120
Environment=GUNICORN_PID_FILE=/run/gunicorn/{{ env }}/pid
Environment=GUNICORN_ACCESS_LOG_FILE=/var/log/gunicorn/{{ env }}/access.log
Environment=GUNICORN_ERROR_LOG_FILE=/var/log/gunicorn/{{ env }}/error.log

ExecStart=/bin/sh -c '${GUNICORN_BIN} \
--workers ${GUNICORN_WORKER} \
--pid ${GUNICORN_PID_FILE} \
Expand Down
6 changes: 6 additions & 0 deletions roles/isimip-files/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- name: Create config for files.isimip.org
template:
src: "{{ files_url }}.conf"
dest: /etc/nginx/vhosts.d/{{ files_url }}.conf
notify:
- Restart nginx
File renamed without changes.
2 changes: 1 addition & 1 deletion roles/isimip-publisher/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
update: no
become_user: isimip

- name: /data is present on files.isimip.org
- name: Create /data
file:
path: "{{ item }}"
state: directory
Expand Down
2 changes: 0 additions & 2 deletions roles/nginx/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
---

- name: Restart nginx
service:
name: nginx
Expand Down
18 changes: 0 additions & 18 deletions roles/nginx/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
---

- name: Install nginx and certbot
zypper:
name:
Expand All @@ -8,22 +6,6 @@
- python3-certbot-nginx
state: present

- name: Create nginx config for data.isimip.org
template:
src: "{{ data_url }}.conf"
dest: /etc/nginx/vhosts.d/{{ data_url }}.conf
when: "'data' in group_names"
notify:
- Restart nginx

- name: Create config for files.isimip.org
template:
src: "{{ files_url }}.conf"
dest: /etc/nginx/vhosts.d/{{ files_url }}.conf
when: "'files' in group_names"
notify:
- Restart nginx

- name: Copy 502.html
copy:
src: 502.html
Expand Down
2 changes: 0 additions & 2 deletions roles/packages/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
---

- name: Install common packages
zypper:
name: "{{ packages }}"
Expand Down
2 changes: 0 additions & 2 deletions roles/packages/vars/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
---

packages:
# utils
- pwgen
Expand Down
1 change: 1 addition & 0 deletions roles/redis/files/redis.service
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Group=redis
ExecStart=/usr/sbin/redis-server /etc/redis/redis.conf
ExecStop=/usr/bin/redis-cli shutdown
Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target
2 changes: 0 additions & 2 deletions roles/redis/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
---

- name: Restart redis
service:
name: nginx
Expand Down
2 changes: 0 additions & 2 deletions roles/redis/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
---

- name: Install redis
zypper:
name: redis
Expand Down

0 comments on commit f43769e

Please sign in to comment.