From 95b73daa36b23565a8566f71f9b202d3459b685f Mon Sep 17 00:00:00 2001 From: Sam Chudnick Date: Sun, 25 Jun 2023 09:52:36 -0400 Subject: Initial Commit --- roles/services/containers/firefly/tasks/main.yml | 172 +++++++++++++++++++++++ 1 file changed, 172 insertions(+) create mode 100644 roles/services/containers/firefly/tasks/main.yml (limited to 'roles/services/containers/firefly/tasks') 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 @@ +- name: set image fact + set_fact: + image: fireflyiii/core:version-6.0.13 + +- name: set other facts + vars: + array: "{{ image.split('/', 1) }}" + set_fact: + repo_tag: "{{ array.1 }}" + custom_registry: "{{ docker_registry_url + '/' + docker_registry_username }}" + +- name: create firefly directory + file: + path: "{{ docker_home }}/firefly" + state: directory + owner: "{{ docker_username }}" + group: "{{ docker_username }}" + mode: '0755' + +- name: create data directory + file: + path: "{{ docker_home }}/firefly/data" + state: directory + owner: "{{ docker_username }}" + group: "{{ docker_username }}" + mode: '0755' + +- name: create db directory + file: + path: "{{ docker_home }}/firefly/db" + state: directory + owner: "{{ docker_username }}" + group: "{{ docker_username }}" + mode: '0755' + +- name: create firefly docker network + become: yes + become_user: "{{ docker_username }}" + docker_network: + name: "{{ firefly_network_name }}" + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + driver: bridge + ipam_config: + - subnet: "{{ firefly_subnet }}" + gateway: "{{ firefly_gateway }}" + +- name: create and deploy firefly db + become: yes + become_user: "{{ docker_username }}" + environment: + XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}" + docker_container: + name: "firefly-db" + hostname: "firefly-db" + image: postgres:alpine + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + purge_networks: yes + networks: + - name: "{{ firefly_network_name }}" + ipv4_address: "{{ firefly_db_ipv4 }}" + volumes: + - "{{ docker_home }}/firefly/data:/var/lib/postgresql/data" + env: + "POSTGRES_USER": "{{ firefly_postgres_user }}" + "POSTGRES_PASSWORD": "{{ firefly_postgres_password }}" + "POSTGRES_DB": "{{ firefly_postgres_db }}" + state: 'started' + recreate: yes + restart_policy: unless-stopped + +- name: create and deploy firefly container + become: yes + become_user: "{{ docker_username }}" + environment: + XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}" + docker_container: + name: "firefly" + hostname: "firefly" + image: "{{ image }}" + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + purge_networks: yes + networks: + - name: "{{ firefly_network_name }}" + ipv4_address: "{{ firefly_ipv4 }}" + ports: + - "127.0.0.1:{{ firefly_external_port }}:8080" + volumes: + - "{{ docker_home }}/firefly/upload:/var/www/html/storage/upload" + env: + "TZ": "{{ timezone }}" + "APP_KEY": "{{ firefly_app_key }}" + "STATIC_CRON_TOKEN": "{{ firefly_cron_token }}" + "DB_HOST": "firefly-db" + "DB_PORT": "5432" + "DB_CONNECTION": "pgsql" + "DB_USERNAME": "{{ firefly_postgres_user }}" + "DB_PASSWORD": "{{ firefly_postgres_password }}" + "DB_DATABASE": "{{ firefly_postgres_db }}" + "AUTHENTICATION_GUARD": "remote_user_guard" + "AUTHENTICATION_GUARD_HEADER": "HTTP_REMOTE_USER" + "AUTHENTICATION_GUARD_EMAIL": "HTTP_REMOTE_EMAIL" + "APP_URL": "https://{{ firefly_server_name }}" + "TRUSTED_PROXIES": "*" + state: 'started' + recreate: yes + restart_policy: unless-stopped + +- name: create and deploy firefly importer container + become: yes + become_user: "{{ docker_username }}" + environment: + XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}" + docker_container: + name: "firefly-importer" + hostname: "firefly-importer" + image: "fireflyiii/data-importer:version-1.3.0" + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + purge_networks: yes + networks: + - name: "{{ firefly_network_name }}" + ipv4_address: "{{ firefly_importer_ipv4 }}" + ports: + - "127.0.0.1:{{ firefly_importer_external_port }}:8080" + env: + "TZ": "{{ timezone }}" + "FIREFLY_III_URL": "http://firefly:8080" + "FIREFLY_III_ACCESS_TOKEN": "{{ firefly_access_token }}" + "VANITY_URL": "https://{{ firefly_server_name }}" + "TRUSTED_PROXIES": "*" + state: 'started' + recreate: yes + restart_policy: unless-stopped + +- name: create and deploy firefly cron container + become: yes + become_user: "{{ docker_username }}" + environment: + XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}" + docker_container: + name: "firefly-cron" + hostname: "firefly-cron" + image: alpine + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + purge_networks: yes + networks: + - name: "{{ firefly_network_name }}" + ipv4_address: "{{ firefly_cron_ipv4 }}" + env: + "POSTGRES_USER": "{{ firefly_postgres_user }}" + "POSTGRES_PASSWORD": "{{ firefly_postgres_password }}" + "POSTGRES_DB": "{{ firefly_postgres_db }}" + command: 'sh -c "echo \"0 3 * * * wget -qO- http://firefly:8080/api/v1/cron/{{ firefly_cron_token }}\" | crontab - && crond -f -L /dev/stdout"' + state: 'started' + recreate: yes + restart_policy: unless-stopped + +- name: deploy nginx configuration + notify: restart nginx + template: + src: "{{ firefly_nginx_config }}" + dest: /etc/nginx/sites-available/firefly.conf + owner: root + group: root + mode: '0644' + +- name: symlink site + file: + src: /etc/nginx/sites-available/firefly.conf + dest: /etc/nginx/sites-enabled/firefly.conf + owner: root + group: root + state: link -- cgit v1.2.3