summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThedro Neely <thedroneely@gmail.com>2020-03-23 06:27:23 -0400
committerThedro Neely <thedroneely@gmail.com>2020-03-23 06:27:23 -0400
commitf9c1847253530a395163da702c1585cf6e4a0c10 (patch)
tree1478a30950ff1b99a6d3f446ff1c14db34325635
parent1a41bb8551cc2cdcd6509faefe792aa9150a6232 (diff)
downloadplaybooks-f9c1847253530a395163da702c1585cf6e4a0c10.tar.gz
playbooks-f9c1847253530a395163da702c1585cf6e4a0c10.tar.bz2
playbooks-f9c1847253530a395163da702c1585cf6e4a0c10.zip
roles/fathom/main: Bootstrap container
-rw-r--r--roles/fathom/main.yml51
-rw-r--r--roles/variables.yml4
2 files changed, 40 insertions, 15 deletions
diff --git a/roles/fathom/main.yml b/roles/fathom/main.yml
index 0ee4af6..9174bb9 100644
--- a/roles/fathom/main.yml
+++ b/roles/fathom/main.yml
@@ -1,23 +1,33 @@
---
-# Target: alpine3.10
+- name: Container Setup
+
+ vars:
+ lxc_base: ansible-alpine3.11
+ lxc_name: fathom
+
+ import_playbook: ../common/tasks/lxc.yml
+
- name: Install Fathom Web Analytics
hosts: fathom
- vars:
- username: fathom
- deploy_path: "/opt/{{ username }}"
- version: 1.2.1
+
+ vars_files:
+ - ../variables.yml
+
tasks:
+
- name: Ensuring group exists
group:
- name: "{{ username }}"
+ name: "{{ fathom_user }}"
state: present
+
- name: Creating user and making home directory
user:
system: yes
state: present
- name: "{{ username }}"
- groups: "{{ username }}"
- home: "{{ deploy_path }}"
+ name: "{{ fathom_user }}"
+ groups: "{{ fathom_user }}"
+ home: "{{ fathom_home }}"
+
- name: Installing the required dependencies
apk:
state: present
@@ -26,53 +36,64 @@
- 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 }}"
+ src: "https://github.com/usefathom/fathom/releases/download/v{{ fathom_version }}/fathom_{{ fathom_version }}_linux_amd64.tar.gz"
+ dest: "{{ fathom_home }}"
remote_src: yes
+
- name: Copying the environment file
copy:
src: env
- dest: "{{ deploy_path }}/.env"
+ dest: "{{ fathom_home }}/.env"
mode: '0644'
register: fathomConfig
become: true
- become_user: "{{ username }}"
+ become_user: "{{ fathom_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
+
- 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
+ chdir: "{{ fathom_home }}"
+ creates: "{{ fathom_home }}/.user_created"
diff --git a/roles/variables.yml b/roles/variables.yml
index e420bfc..912e72c 100644
--- a/roles/variables.yml
+++ b/roles/variables.yml
@@ -20,3 +20,7 @@ isso_repository: https://github.com/tdro/isso
isso_version: bb9d947c7656663f3963880bd9cd961dad874ee3
docker_registry_version: 2.7.1
+
+fathom_user: fathom
+fathom_home: "/opt/{{ fathom_user }}"
+fathom_version: 1.2.1