--- # Target: alpine3.10 - name: Install Fathom Web Analytics hosts: fathom vars: username: fathom deploy_path: "/opt/{{ username }}" version: 1.2.1 tasks: - name: Ensuring group exists group: name: "{{ username }}" state: present - name: Creating user and making home directory user: system: yes state: present name: "{{ username }}" groups: "{{ username }}" home: "{{ deploy_path }}" - name: Installing the required dependencies apk: state: present update_cache: yes name: - sudo - supervisor - tar - block: - name: Downloading and extracting application unarchive: src: "https://github.com/usefathom/fathom/releases/download/v{{ version }}/fathom_{{ version }}_linux_amd64.tar.gz" dest: "{{ deploy_path }}" remote_src: yes - name: Copying the environment file copy: src: env dest: "{{ deploy_path }}/.env" mode: '0644' register: fathomConfig become: true become_user: "{{ username }}" - 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 - name: Ensuring application has been started supervisorctl: name: fathom state: started - name: Waiting for application to become active wait_for: port: 9000 - name: Restarting application due to config change supervisorctl: name: fathom state: restarted when: fathomConfig.changed - name: Creating fathom username and password shell: /opt/fathom/fathom user add --email='test@example.com' --password='fathom' args: chdir: "{{ deploy_path }}" creates: "{{ deploy_path }}/.user_created"