|
@@ -0,0 +1,97 @@
|
|
1
|
+- name: Create temporary fathom directory
|
|
2
|
+ file: state=directory path=/root/fathom
|
|
3
|
+
|
|
4
|
+- name: Download fathom {{ fathom_version }} release
|
|
5
|
+ get_url:
|
|
6
|
+ url="{{ fathom_release }}"
|
|
7
|
+ dest=/root/fathom/fathom-{{ fathom_version }}.tar.gz
|
|
8
|
+
|
|
9
|
+- name: Decompress fathom release
|
|
10
|
+ unarchive: src=/root/fathom/fathom-{{ fathom_version }}.tar.gz
|
|
11
|
+ dest=/root/fathom copy=no
|
|
12
|
+ creates=/root/fathom/fathom
|
|
13
|
+
|
|
14
|
+- name: Create /usr/local/bin
|
|
15
|
+ file: state=directory path=/usr/local/bin
|
|
16
|
+
|
|
17
|
+- name: Stop old fathom instance
|
|
18
|
+ service: name=fathom-stats state=stopped
|
|
19
|
+
|
|
20
|
+- name: Copy fathom binary to /usr/local/bin
|
|
21
|
+ shell: cp fathom/fathom /usr/local/bin/fathom chdir=/root
|
|
22
|
+
|
|
23
|
+- name: Remove downloaded temporary fathom files
|
|
24
|
+ file: state=absent path=/root/fathom
|
|
25
|
+
|
|
26
|
+- name: Create fathom working directory
|
|
27
|
+ file: state=directory path=/home/{{ main_user_name }}/fathom-stats
|
|
28
|
+
|
|
29
|
+- name: Create fathom config file
|
|
30
|
+ template:
|
|
31
|
+ src=home_user_fathom-stats_env.j2
|
|
32
|
+ dest=/home/{{ main_user_name }}/fathom-stats/.env
|
|
33
|
+ owner={{ main_user_name }}
|
|
34
|
+ group=root
|
|
35
|
+
|
|
36
|
+- name: Add fathom postgres user
|
|
37
|
+ postgresql_user:
|
|
38
|
+ login_host=localhost
|
|
39
|
+ login_user={{ db_admin_username }}
|
|
40
|
+ login_password="{{ db_admin_password }}"
|
|
41
|
+ name={{ fathom_db_username }}
|
|
42
|
+ password="{{ fathom_db_password }}"
|
|
43
|
+ encrypted=yes
|
|
44
|
+ state=present
|
|
45
|
+
|
|
46
|
+- name: Create fathom database
|
|
47
|
+ postgresql_db:
|
|
48
|
+ login_host=localhost
|
|
49
|
+ login_user={{ db_admin_username }}
|
|
50
|
+ login_password="{{ db_admin_password }}"
|
|
51
|
+ name={{ fathom_db_database }}
|
|
52
|
+ state=present
|
|
53
|
+ owner={{ fathom_db_username }}
|
|
54
|
+
|
|
55
|
+- name: Delete old fathom admin user account
|
|
56
|
+ become: true
|
|
57
|
+ become_user: "{{ main_user_name }}"
|
|
58
|
+ shell: fathom user delete --email="{{ fathom_admin_username }}"
|
|
59
|
+ args:
|
|
60
|
+ chdir: /home/{{ main_user_name }}/fathom-stats
|
|
61
|
+
|
|
62
|
+- name: Create fathom admin user account
|
|
63
|
+ become: true
|
|
64
|
+ become_user: "{{ main_user_name }}"
|
|
65
|
+ shell: fathom user add --email="{{ fathom_admin_username }}" --password="{{ fathom_admin_password }}"
|
|
66
|
+ args:
|
|
67
|
+ chdir: /home/{{ main_user_name }}/fathom-stats
|
|
68
|
+
|
|
69
|
+- name: Add systemd service to start fathom automatically
|
|
70
|
+ template:
|
|
71
|
+ src=etc_systemd_system_fathom-stats.j2
|
|
72
|
+ dest=/etc/systemd/system/fathom-stats.service
|
|
73
|
+ owner=root
|
|
74
|
+ group=root
|
|
75
|
+
|
|
76
|
+- name: Register new fathom service
|
|
77
|
+ systemd: name=fathom-stats daemon_reload=yes enabled=yes
|
|
78
|
+
|
|
79
|
+- name: Start new fathom instance
|
|
80
|
+ service: name=fathom-stats state=started
|
|
81
|
+
|
|
82
|
+- name: Create the Apache Fathom sites config files
|
|
83
|
+ template:
|
|
84
|
+ src=etc_apache2_sites-available_fathom.j2
|
|
85
|
+ dest=/etc/apache2/sites-available/fathom_{{ item.name }}.conf
|
|
86
|
+ owner=root
|
|
87
|
+ group=root
|
|
88
|
+ with_items: "{{ virtual_domains }}"
|
|
89
|
+
|
|
90
|
+- name: Remove old sites-enabled symlinks (new ones will be created by a2ensite)
|
|
91
|
+ file: path=/etc/apache2/sites-enabled/fathom_{{ item }}.conf state=absent
|
|
92
|
+ with_items: "{{ virtual_domains | json_query('[*].name') }}"
|
|
93
|
+
|
|
94
|
+- name: Enable Apache sites (creates new sites-enabled symlinks)
|
|
95
|
+ command: a2ensite fathom_{{ item }}.conf creates=/etc/apache2/sites-enabled/fathom_{{ item }}.conf
|
|
96
|
+ notify: restart apache
|
|
97
|
+ with_items: "{{ virtual_domains | json_query('[*].name') }}"
|