--- - name: Container Setup vars: lxc_base: ansible-alpine3.11 lxc_name: healthchecks import_playbook: ../common/tasks/lxc.yml - name: Install Health Checks hosts: healthchecks vars_files: - ../variables.yml tasks: - name: Ensuring group exists group: name: "{{ healthchecks_user }}" state: present - name: Creating user and making home directory user: system: yes state: present name: "{{ healthchecks_user }}" groups: "{{ healthchecks_user }}" home: "{{ healthchecks_home }}" - name: Installing the required dependencies apk: state: present update_cache: yes name: - musl-dev - postgresql-dev - python3-dev - gcc - git - supervisor - sudo - uwsgi - uwsgi-python - block: - name: Cloning repository git: repo: "{{ healthchecks_repository }}" dest: "{{ healthchecks_home }}" version: "{{ healthchecks_version }}" - name: Setting up python virtual environment shell: python3 -m venv . args: chdir: "{{ healthchecks_home }}" creates: bin/activate - name: Pip installing application shell: | . bin/activate pip install -r requirements.txt args: chdir: "{{ healthchecks_home }}" creates: lib/python3.8/site-packages/django - name: Migrating database shell: | . bin/activate ./manage.py migrate args: chdir: "{{ healthchecks_home }}" changed_when: false register: output - debug: var=output - name: Setting up application assets blockinfile: path: "{{ healthchecks_home }}/uwsgi.ini" block: | [uwsgi] http-socket = 0.0.0.0:8000 enable-threads plugin = python virtualenv = /opt/healthchecks module = hc.wsgi:application static-map = /static=static-collected static-gzip-dir = static-collected/CACHE hook-pre-app = exec:./manage.py collectstatic --noinput hook-pre-app = exec:./manage.py compress --force attach-daemon = ./manage.py sendalerts create: yes - name: Setting up application configuration blockinfile: path: "{{ healthchecks_home }}/hc/local_settings.py" block: | SITE_NAME = "Check" DEBUG = False COMPRESS_ENABLED = True REGISTRATION_OPEN = False SECRET = "{{ secret_key }}" create: yes - name: Performing maintenance shell: | . bin/activate ./manage.py prunepings ./manage.py prunenotifications ./manage.py pruneusers ./manage.py prunetokenbucket ./manage.py pruneflips ./manage.py compress args: chdir: "{{ healthchecks_home }}" changed_when: false register: output - debug: var=output become: true become_user: "{{ healthchecks_user }}" - name: Copying supervisord config file copy: src: supervisord.conf dest: /etc/supervisord.conf mode: '0644' - name: Ensuring supervisord has been started and enabled service: name: supervisord state: restarted enabled: yes changed_when: false - name: Waiting for supervisor to become active wait_for: port: 9100 - name: Waiting for application to become active wait_for: port: 8000 - name: Testing if page exists uri: url: http://0.0.0.0:8000 return_content: yes