summaryrefslogtreecommitdiff
path: root/roles/fathom
diff options
context:
space:
mode:
authorThedro Neely <thedroneely@gmail.com>2019-12-30 02:56:39 -0500
committerThedro Neely <thedroneely@gmail.com>2019-12-30 02:56:39 -0500
commitd9f0c587c12ff28791eacab93e8c04ed49b22221 (patch)
tree6c238bc8d14db7ae36c39ea5bfd0556d0695cda4 /roles/fathom
parentfd8228df2edc46ef3bb507f6346535d3aa8937e8 (diff)
downloadplaybooks-d9f0c587c12ff28791eacab93e8c04ed49b22221.tar.gz
playbooks-d9f0c587c12ff28791eacab93e8c04ed49b22221.tar.bz2
playbooks-d9f0c587c12ff28791eacab93e8c04ed49b22221.zip
roles/fathom/main.yml: Add playbook
Diffstat (limited to 'roles/fathom')
-rw-r--r--roles/fathom/files/env6
-rw-r--r--roles/fathom/files/supervisord.conf30
-rw-r--r--roles/fathom/main.yml78
3 files changed, 114 insertions, 0 deletions
diff --git a/roles/fathom/files/env b/roles/fathom/files/env
new file mode 100644
index 0000000..5ac3985
--- /dev/null
+++ b/roles/fathom/files/env
@@ -0,0 +1,6 @@
+FATHOM_SERVER_ADDR=9000
+FATHOM_GZIP=true
+FATHOM_DEBUG=true
+FATHOM_DATABASE_DRIVER="sqlite3"
+FATHOM_DATABASE_NAME="fathom.db"
+FATHOM_SECRET="random-secret-string"
diff --git a/roles/fathom/files/supervisord.conf b/roles/fathom/files/supervisord.conf
new file mode 100644
index 0000000..22adc5f
--- /dev/null
+++ b/roles/fathom/files/supervisord.conf
@@ -0,0 +1,30 @@
+; Supervisor config file.
+
+[program:fathom]
+command=/opt/fathom/fathom server
+directory=/opt/%(program_name)s
+stopasgroup=true
+stdout_logfile=/var/log/%(program_name)s.log
+stdout_logfile_maxbytes=0
+stdout_logfile_backups=0
+redirect_stderr=true
+user=%(program_name)s
+
+[inet_http_server]
+port = 9100
+username = fathom
+password = fathom
+
+[unix_http_server]
+file=/run/supervisord.sock
+
+[supervisord]
+logfile=/var/log/supervisord.log
+loglevel=info
+user=root
+
+[rpcinterface:supervisor]
+supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
+
+[supervisorctl]
+serverurl=unix:///run/supervisord.sock
diff --git a/roles/fathom/main.yml b/roles/fathom/main.yml
new file mode 100644
index 0000000..0ee4af6
--- /dev/null
+++ b/roles/fathom/main.yml
@@ -0,0 +1,78 @@
+---
+# 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" \ No newline at end of file