diff --git a/backoffice.yaml b/backoffice.yaml index 0ea4a4a..388fa0b 100644 --- a/backoffice.yaml +++ b/backoffice.yaml @@ -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 @@ -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 diff --git a/tasks/python.yaml b/tasks/python.yaml new file mode 100644 index 0000000..9938cbe --- /dev/null +++ b/tasks/python.yaml @@ -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' diff --git a/tasks/source.yaml b/tasks/source.yaml new file mode 100644 index 0000000..99284bb --- /dev/null +++ b/tasks/source.yaml @@ -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 diff --git a/tasks/uwsgi.yaml b/tasks/uwsgi.yaml index 993b22c..ca811e3 100644 --- a/tasks/uwsgi.yaml +++ b/tasks/uwsgi.yaml @@ -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: @@ -13,6 +18,8 @@ owner: root group: root mode: ugo=r + notify: + - uwsgi apps are reloaded - name: uwsgi app configs exists loop: "{{ uwsgi_apps }}" @@ -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: @@ -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