From d06c80e218a138783ff546004d95e5361942f398 Mon Sep 17 00:00:00 2001 From: "max.mehl" Date: Sun, 19 Dec 2021 20:51:04 +0100 Subject: [PATCH] further ansible tasks --- ansible/ansible.cfg | 3 +++ ansible/group_vars/all.yml | 1 + ansible/playbook.yml | 30 ++++++++++++++++++++++- ansible/templates/autoreply-editor.ini.j2 | 4 +++ ansible/templates/config.py.j2 | 2 +- 5 files changed, 38 insertions(+), 2 deletions(-) create mode 100644 ansible/ansible.cfg create mode 100644 ansible/templates/autoreply-editor.ini.j2 diff --git a/ansible/ansible.cfg b/ansible/ansible.cfg new file mode 100644 index 0000000..cbfaacc --- /dev/null +++ b/ansible/ansible.cfg @@ -0,0 +1,3 @@ +[defaults] +interpreter_python = python3 +inventory = inventory.txt diff --git a/ansible/group_vars/all.yml b/ansible/group_vars/all.yml index 58a8201..4a15ab2 100644 --- a/ansible/group_vars/all.yml +++ b/ansible/group_vars/all.yml @@ -1,2 +1,3 @@ --- message_file: message.txt +port: 5000 diff --git a/ansible/playbook.yml b/ansible/playbook.yml index a30e42e..93e2740 100644 --- a/ansible/playbook.yml +++ b/ansible/playbook.yml @@ -1,5 +1,5 @@ - hosts: autoreply_editor - gather_facts: false + gather_facts: true tasks: - name: Get newest version of autoreply-editor git: @@ -10,3 +10,31 @@ template: src: config.py.j2 dest: autoreply-editor/config.py + + - name: Install specified python requirements + pip: + requirements: requirements.txt + chdir: autoreply-editor + extra_args: --user + + - name: Register domain for service + command: "uberspace web domain add {{ domain }}" + register: cmdrtrn + failed_when: "'It is already configured for your Uberspace account' not in cmdrtrn.stderr" + + - name: Create web backend for service + command: "uberspace web backend set {{ domain }} --http --port {{ port }}" + + - name: Deploy supervisord service + template: + src: autoreply-editor.ini.j2 + dest: etc/services.d/autoreply-editor.ini + notify: reload supervisord + + handlers: + - name: reread supervisord + command: supervisorctl reread + listen: reload supervisord + - name: update supervisord + command: supervisorctl update + listen: reload supervisord diff --git a/ansible/templates/autoreply-editor.ini.j2 b/ansible/templates/autoreply-editor.ini.j2 new file mode 100644 index 0000000..9bcd98e --- /dev/null +++ b/ansible/templates/autoreply-editor.ini.j2 @@ -0,0 +1,4 @@ +[program:autoreply-editor] +directory=/home/{{ ansible_user_id }}/autoreply-editor +command=gunicorn --bind 0.0.0.0:{{ port }} wsgi:app +startsecs=60 diff --git a/ansible/templates/config.py.j2 b/ansible/templates/config.py.j2 index bbc973b..7c4f1e2 100644 --- a/ansible/templates/config.py.j2 +++ b/ansible/templates/config.py.j2 @@ -1,3 +1,3 @@ MESSAGE_FILE = "{{ message_file }}" -BASIC_AUTH_USERNAME = "{{ auth_user }} +BASIC_AUTH_USERNAME = "{{ auth_user }}" BASIC_AUTH_PASSWORD = "{{ auth_pass }}"