--- # target: alpine3.11 - 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 }}" creates: hc.sqlite - 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 become: true become_user: "{{ healthchecks_user }}" - name: Copying supervisord config file copy: src: supervisord.conf dest: /etc/supervisord.conf mode: '0644' register: supervisorConfig - name: Ensuring supervisord has been started and enabled service: name: supervisord state: started enabled: yes - name: Waiting for supervisor to become active wait_for: port: 9100 - name: Restarting supervisord due to config change service: name: supervisord state: restarted when: supervisorConfig.changed