Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions backoffice.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@

tasks:
- import_tasks: tasks/apt-update.yaml
- import_tasks: tasks/python.yaml
- import_tasks: tasks/source.yaml
- import_tasks: tasks/systemd.yaml
- import_tasks: tasks/prometheus.yaml
- import_tasks: tasks/uwsgi.yaml
Expand All @@ -33,6 +35,18 @@
name: prometheus
state: reloaded

- name: uwsgi apps are restarted
loop: "{{ uwsgi_apps }}"
service:
name: "uwsgi@{{ item }}"
state: restarted

- name: uwsgi apps are reloaded
loop: "{{ uwsgi_apps }}"
service:
name: "uwsgi@{{ item }}"
state: reloaded

- name: promtail is restarted
service:
name: promtail
Expand Down
19 changes: 19 additions & 0 deletions tasks/python.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
- name: python basics are installed
apt:
package:
- python3
- python3-dev
- python3-pip
- python3-venv

- name: pipenv is installed
pip:
name:
- pipenv==2018.11.26

- name: pipenv is configured
lineinfile:
path: /etc/environment
regexp: '^PIPENV_VENV_IN_PROJECT='
line: 'PIPENV_VENV_IN_PROJECT=1'
25 changes: 25 additions & 0 deletions tasks/source.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
- name: "/opt/backoffice is owned by {{app_user}}"
file:
path: /opt/backoffice
state: directory
owner: "{{app_user}}"
group: "{{app_user}}"

- name: /opt/backoffice is up-to-date
git:
repo: https://github.com/seattleflu/backoffice
dest: /opt/backoffice
become: no

- name: os deps are installed
apt:
package:
- libpq-dev
- postgresql-client-10

- name: id3c-production deps are installed
shell:
chdir: /opt/backoffice/id3c-production
cmd: PIPENV_VENV_IN_PROJECT=1 pipenv sync
become: no
30 changes: 30 additions & 0 deletions tasks/uwsgi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
- uwsgi
- uwsgi-plugin-python3

- name: default uwsgi multi-app service is disabled
service:
name: uwsgi
enabled: no
state: stopped

- name: uwsgi base config exists
copy:
Expand All @@ -13,6 +18,8 @@
owner: root
group: root
mode: ugo=r
notify:
- uwsgi apps are reloaded

- name: uwsgi app configs exists
loop: "{{ uwsgi_apps }}"
Expand All @@ -22,6 +29,8 @@
owner: root
group: root
mode: ugo=r
notify:
- uwsgi apps are reloaded

- name: uwsgi app logs readable by adm group
file:
Expand All @@ -39,3 +48,24 @@
owner: root
group: adm
mode: u=rwx,go=rxs

- name: uwsgi apps are enabled
loop: "{{uwsgi_apps}}"
service:
name: "uwsgi@{{item}}"
enabled: yes
state: started

- name: uwsgi apps are enabled
loop: "{{uwsgi_apps}}"
service:
name: "uwsgi@{{item}}"
enabled: yes
state: started

- name: uwsgi prometheus exporters are enabled
loop: "{{uwsgi_apps}}"
service:
name: "prometheus-uwsgi-exporter@{{item}}"
enabled: yes
state: started