aboutsummaryrefslogtreecommitdiff
path: root/roles/services/containers/firefly
diff options
context:
space:
mode:
Diffstat (limited to 'roles/services/containers/firefly')
-rw-r--r--roles/services/containers/firefly/handlers/main.yml4
-rw-r--r--roles/services/containers/firefly/tasks/main.yml172
2 files changed, 176 insertions, 0 deletions
diff --git a/roles/services/containers/firefly/handlers/main.yml b/roles/services/containers/firefly/handlers/main.yml
new file mode 100644
index 0000000..5463835
--- /dev/null
+++ b/roles/services/containers/firefly/handlers/main.yml
@@ -0,0 +1,4 @@
1- name: restart nginx
2 service:
3 name: nginx
4 state: restarted
diff --git a/roles/services/containers/firefly/tasks/main.yml b/roles/services/containers/firefly/tasks/main.yml
new file mode 100644
index 0000000..ab389e2
--- /dev/null
+++ b/roles/services/containers/firefly/tasks/main.yml
@@ -0,0 +1,172 @@
1- name: set image fact
2 set_fact:
3 image: fireflyiii/core:version-6.0.13
4
5- name: set other facts
6 vars:
7 array: "{{ image.split('/', 1) }}"
8 set_fact:
9 repo_tag: "{{ array.1 }}"
10 custom_registry: "{{ docker_registry_url + '/' + docker_registry_username }}"
11
12- name: create firefly directory
13 file:
14 path: "{{ docker_home }}/firefly"
15 state: directory
16 owner: "{{ docker_username }}"
17 group: "{{ docker_username }}"
18 mode: '0755'
19
20- name: create data directory
21 file:
22 path: "{{ docker_home }}/firefly/data"
23 state: directory
24 owner: "{{ docker_username }}"
25 group: "{{ docker_username }}"
26 mode: '0755'
27
28- name: create db directory
29 file:
30 path: "{{ docker_home }}/firefly/db"
31 state: directory
32 owner: "{{ docker_username }}"
33 group: "{{ docker_username }}"
34 mode: '0755'
35
36- name: create firefly docker network
37 become: yes
38 become_user: "{{ docker_username }}"
39 docker_network:
40 name: "{{ firefly_network_name }}"
41 docker_host: "unix://run/user/{{ docker_uid }}/docker.sock"
42 driver: bridge
43 ipam_config:
44 - subnet: "{{ firefly_subnet }}"
45 gateway: "{{ firefly_gateway }}"
46
47- name: create and deploy firefly db
48 become: yes
49 become_user: "{{ docker_username }}"
50 environment:
51 XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}"
52 docker_container:
53 name: "firefly-db"
54 hostname: "firefly-db"
55 image: postgres:alpine
56 docker_host: "unix://run/user/{{ docker_uid }}/docker.sock"
57 purge_networks: yes
58 networks:
59 - name: "{{ firefly_network_name }}"
60 ipv4_address: "{{ firefly_db_ipv4 }}"
61 volumes:
62 - "{{ docker_home }}/firefly/data:/var/lib/postgresql/data"
63 env:
64 "POSTGRES_USER": "{{ firefly_postgres_user }}"
65 "POSTGRES_PASSWORD": "{{ firefly_postgres_password }}"
66 "POSTGRES_DB": "{{ firefly_postgres_db }}"
67 state: 'started'
68 recreate: yes
69 restart_policy: unless-stopped
70
71- name: create and deploy firefly container
72 become: yes
73 become_user: "{{ docker_username }}"
74 environment:
75 XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}"
76 docker_container:
77 name: "firefly"
78 hostname: "firefly"
79 image: "{{ image }}"
80 docker_host: "unix://run/user/{{ docker_uid }}/docker.sock"
81 purge_networks: yes
82 networks:
83 - name: "{{ firefly_network_name }}"
84 ipv4_address: "{{ firefly_ipv4 }}"
85 ports:
86 - "127.0.0.1:{{ firefly_external_port }}:8080"
87 volumes:
88 - "{{ docker_home }}/firefly/upload:/var/www/html/storage/upload"
89 env:
90 "TZ": "{{ timezone }}"
91 "APP_KEY": "{{ firefly_app_key }}"
92 "STATIC_CRON_TOKEN": "{{ firefly_cron_token }}"
93 "DB_HOST": "firefly-db"
94 "DB_PORT": "5432"
95 "DB_CONNECTION": "pgsql"
96 "DB_USERNAME": "{{ firefly_postgres_user }}"
97 "DB_PASSWORD": "{{ firefly_postgres_password }}"
98 "DB_DATABASE": "{{ firefly_postgres_db }}"
99 "AUTHENTICATION_GUARD": "remote_user_guard"
100 "AUTHENTICATION_GUARD_HEADER": "HTTP_REMOTE_USER"
101 "AUTHENTICATION_GUARD_EMAIL": "HTTP_REMOTE_EMAIL"
102 "APP_URL": "https://{{ firefly_server_name }}"
103 "TRUSTED_PROXIES": "*"
104 state: 'started'
105 recreate: yes
106 restart_policy: unless-stopped
107
108- name: create and deploy firefly importer container
109 become: yes
110 become_user: "{{ docker_username }}"
111 environment:
112 XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}"
113 docker_container:
114 name: "firefly-importer"
115 hostname: "firefly-importer"
116 image: "fireflyiii/data-importer:version-1.3.0"
117 docker_host: "unix://run/user/{{ docker_uid }}/docker.sock"
118 purge_networks: yes
119 networks:
120 - name: "{{ firefly_network_name }}"
121 ipv4_address: "{{ firefly_importer_ipv4 }}"
122 ports:
123 - "127.0.0.1:{{ firefly_importer_external_port }}:8080"
124 env:
125 "TZ": "{{ timezone }}"
126 "FIREFLY_III_URL": "http://firefly:8080"
127 "FIREFLY_III_ACCESS_TOKEN": "{{ firefly_access_token }}"
128 "VANITY_URL": "https://{{ firefly_server_name }}"
129 "TRUSTED_PROXIES": "*"
130 state: 'started'
131 recreate: yes
132 restart_policy: unless-stopped
133
134- name: create and deploy firefly cron container
135 become: yes
136 become_user: "{{ docker_username }}"
137 environment:
138 XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}"
139 docker_container:
140 name: "firefly-cron"
141 hostname: "firefly-cron"
142 image: alpine
143 docker_host: "unix://run/user/{{ docker_uid }}/docker.sock"
144 purge_networks: yes
145 networks:
146 - name: "{{ firefly_network_name }}"
147 ipv4_address: "{{ firefly_cron_ipv4 }}"
148 env:
149 "POSTGRES_USER": "{{ firefly_postgres_user }}"
150 "POSTGRES_PASSWORD": "{{ firefly_postgres_password }}"
151 "POSTGRES_DB": "{{ firefly_postgres_db }}"
152 command: 'sh -c "echo \"0 3 * * * wget -qO- http://firefly:8080/api/v1/cron/{{ firefly_cron_token }}\" | crontab - && crond -f -L /dev/stdout"'
153 state: 'started'
154 recreate: yes
155 restart_policy: unless-stopped
156
157- name: deploy nginx configuration
158 notify: restart nginx
159 template:
160 src: "{{ firefly_nginx_config }}"
161 dest: /etc/nginx/sites-available/firefly.conf
162 owner: root
163 group: root
164 mode: '0644'
165
166- name: symlink site
167 file:
168 src: /etc/nginx/sites-available/firefly.conf
169 dest: /etc/nginx/sites-enabled/firefly.conf
170 owner: root
171 group: root
172 state: link