Skip to content

Commit

Permalink
✨ Add Firefly Pico (#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
anarion80 authored May 17, 2024
1 parent c9dbd6c commit 73f9311
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 6 deletions.
26 changes: 26 additions & 0 deletions roles/firefly/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,26 @@
firefly_enabled: false
firefly_available_externally: false
firefly_importer_enabled: false
firefly_pico_enabled: false

# directories
firefly_data_directory: "{{ docker_home }}/firefly"

# network
firefly_hostname: "firefly"
firefly_importer_hostname: "firefly-importer"
firefly_pico_hostname: "firefly-pico"
firefly_port: "8066"
firefly_pico_port: "8143"
firefly_importer_port: "8067"
firefly_network_name: "firefly"

# specs
firefly_memory: "1g"
firefly_mysql_memory: "1g"
firefly_importer_memory: "1g"
firefly_pico_memory: "1g"
firefly_pico_db_memory: "1g"

# docker
firefly_container_name: firefly
Expand All @@ -29,6 +34,12 @@ firefly_mysql_image_tag: "10.9"
firefly_importer_container_name: firefly-importer
firefly_importer_image_name: fireflyiii/data-importer
firefly_importer_image_tag: latest
firefly_pico_container_name: firefly-pico
firefly_pico_image_name: cioraneanu/firefly-pico
firefly_pico_image_tag: latest
firefly_pico_db_container_name: firefly-pico-db
firefly_pico_db_image_name: postgres
firefly_pico_db_image_tag: latest

# firefly
firefly_mysql_database: "firefly"
Expand All @@ -53,6 +64,12 @@ firefly_mail_password: "null"
firefly_mail_encryption: "null"
firefly_mail_destination: ""

firefly_pico_db_connection: pgsql
firefly_pico_db_port: "5432"
firefly_pico_db_database: "firefly-pico"
firefly_pico_db_user: "firefly-pico"
firefly_pico_db_password: "firefly-pico"

firefly_env:
APP_URL: "https://{{ firefly_hostname }}.{{ ansible_nas_domain }}"
TRUSTED_PROXIES: "**"
Expand Down Expand Up @@ -85,3 +102,12 @@ firefly_importer_env:
MYSQL_PASSWORD: "{{ firefly_mysql_password }}"
MYSQL_ROOT_PASSWORD: "{{ firefly_mysql_root_password }}"
MAIL_DESTINATION: "{{ firefly_mail_destination }}"
firefly_pico_env:
FIREFLY_URL: "https://{{ firefly_hostname }}.{{ ansible_nas_domain }}"
DB_CONNECTION: "{{ firefly_pico_db_connection }}"
DB_HOST: "{{ firefly_pico_db_container_name }}"
DB_PORT: "{{ firefly_pico_db_port }}"
DB_DATABASE: "{{ firefly_pico_db_database }}"
DB_USERNAME: "{{ firefly_pico_db_user }}"
DB_PASSWORD: "{{ firefly_pico_db_password }}"
TZ: "{{ ansible_nas_timezone }}"
1 change: 1 addition & 0 deletions roles/firefly/molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ provisioner:
all:
firefly_enabled: true
firefly_importer_enabled: true
firefly_pico_enabled: true
14 changes: 14 additions & 0 deletions roles/firefly/molecule/default/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@
name: "{{ firefly_importer_container_name }}"
register: result_importer

- name: Get firefly pico db container state
community.docker.docker_container_info:
name: "{{ firefly_pico_db_container_name }}"
register: result_pico_db

- name: Get firefly pico container state
community.docker.docker_container_info:
name: "{{ firefly_pico_container_name }}"
register: result_pico

- name: Check Firefly is running
ansible.builtin.assert:
that:
Expand All @@ -31,3 +41,7 @@
- result_mysql.container['State']['Restarting'] == false
- result_importer.container['State']['Status'] == "running"
- result_importer.container['State']['Restarting'] == false
- result_pico_db.container['State']['Status'] == "running"
- result_pico_db.container['State']['Restarting'] == false
- result_pico.container['State']['Status'] == "running"
- result_pico.container['State']['Restarting'] == false
14 changes: 14 additions & 0 deletions roles/firefly/molecule/default/verify_stopped.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,23 @@
state: absent
register: result_importer

- name: Try and stop and remove Firefly Pico
community.docker.docker_container:
name: "{{ firefly_pico_container_name }}"
state: absent
register: result_pico

- name: Try and stop and remove Firefly Pico Db
community.docker.docker_container:
name: "{{ firefly_pico_db_container_name }}"
state: absent
register: result_pico_db

- name: Check Firefly is stopped
ansible.builtin.assert:
that:
- not result.changed
- not result_mysql.changed
- not result_importer.changed
- not result_pico.changed
- not result_pico_db.changed
65 changes: 59 additions & 6 deletions roles/firefly/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@
labels:
traefik.enable: "{{ firefly_available_externally | string }}"
traefik.http.routers.firefly.rule: "Host(`{{ firefly_hostname }}.{{ ansible_nas_domain }}`)"
# traefik.http.routers.firefly.tls.certresolver: "letsencrypt"
# traefik.http.routers.firefly.tls.domains[0].main: "{{ ansible_nas_domain }}"
# traefik.http.routers.firefly.tls.domains[0].sans: "*.{{ ansible_nas_domain }}"
traefik.http.routers.firefly.tls.certresolver: "letsencrypt"
traefik.http.routers.firefly.tls.domains[0].main: "{{ ansible_nas_domain }}"
traefik.http.routers.firefly.tls.domains[0].sans: "*.{{ ansible_nas_domain }}"
traefik.http.services.firefly.loadbalancer.server.port: "8080"

- name: Create Firefly III Data Importer container
Expand All @@ -81,11 +81,54 @@
labels:
traefik.enable: "{{ firefly_available_externally | string }}"
traefik.http.routers.firefly-importer.rule: "Host(`{{ firefly_importer_hostname }}.{{ ansible_nas_domain }}`)"
# traefik.http.routers.firefly-importer.tls.certresolver: "letsencrypt"
# traefik.http.routers.firefly-importer.tls.domains[0].main: "{{ ansible_nas_domain }}"
# traefik.http.routers.firefly-importer.tls.domains[0].sans: "*.{{ ansible_nas_domain }}"
traefik.http.routers.firefly-importer.tls.certresolver: "letsencrypt"
traefik.http.routers.firefly-importer.tls.domains[0].main: "{{ ansible_nas_domain }}"
traefik.http.routers.firefly-importer.tls.domains[0].sans: "*.{{ ansible_nas_domain }}"
traefik.http.services.firefly-importer.loadbalancer.server.port: "8080"
when: firefly_importer_enabled is true

- name: Install Firefly Pico
block:
- name: Create Firefly III Pico Db container
community.docker.docker_container:
name: "{{ firefly_pico_db_container_name }}"
image: "{{ firefly_pico_db_image_name }}:{{ firefly_pico_db_image_tag }}"
networks:
- name: "{{ firefly_network_name }}"
network_mode: "{{ firefly_network_name }}"
pull: true
volumes:
- "{{ firefly_data_directory }}/pico-db:/var/lib/postgresql/data:rw"
env:
POSTGRES_DB: "{{ firefly_pico_db_database }}"
POSTGRES_USER: "{{ firefly_pico_db_user }}"
POSTGRES_PASSWORD: "{{ firefly_pico_db_password }}"
restart_policy: unless-stopped
memory: "{{ firefly_pico_db_memory }}"
labels:
traefik.enable: "false"

- name: Create Firefly III Pico container
community.docker.docker_container:
name: "{{ firefly_pico_container_name }}"
image: "{{ firefly_pico_image_name }}:{{ firefly_pico_image_tag }}"
networks:
- name: "{{ firefly_network_name }}"
network_mode: "{{ firefly_network_name }}"
pull: true
ports:
- "{{ firefly_pico_port }}:80"
env: "{{ firefly_pico_optional_env | default({}) | combine(firefly_pico_env) }}"
restart_policy: unless-stopped
memory: "{{ firefly_pico_memory }}"
labels:
traefik.enable: "{{ firefly_available_externally | string }}"
traefik.http.routers.firefly-pico.rule: "Host(`{{ firefly_pico_hostname }}.{{ ansible_nas_domain }}`)"
traefik.http.routers.firefly-pico.tls.certresolver: "letsencrypt"
traefik.http.routers.firefly-pico.tls.domains[0].main: "{{ ansible_nas_domain }}"
traefik.http.routers.firefly-pico.tls.domains[0].sans: "*.{{ ansible_nas_domain }}"
traefik.http.services.firefly-pico.loadbalancer.server.port: "80"
when: firefly_pico_enabled is true
when: firefly_enabled is true

- name: Stop Firefly
Expand All @@ -104,4 +147,14 @@
community.docker.docker_container:
name: "{{ firefly_importer_container_name }}"
state: absent

- name: Stop Firefly Pico Db
community.docker.docker_container:
name: "{{ firefly_pico_db_container_name }}"
state: absent

- name: Stop Firefly Pico
community.docker.docker_container:
name: "{{ firefly_pico_container_name }}"
state: absent
when: firefly_enabled is false
2 changes: 2 additions & 0 deletions website/docs/applications/other/firefly.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ Set `firefly_enabled: true` in your `inventories/<your_inventory>/group_vars/nas
The Firefly III web interface can be found at [http://ansible_nas_host_or_ip:8066](http://ansible_nas_host_or_ip:8066).

Optionally, you can install [Firefly Data Importer](https://github.com/firefly-iii/data-importer) by creating a Personal Access Token in Firefly, copying it into `firefly_access_token` variable, setting `firefly_importer_enabled` to `true` and re-running the playbook.

You can also install [Firefly Pico](https://github.com/cioraneanu/firefly-pico) setting `firefly_pico_enabled` to `true` and re-running the playbook.

0 comments on commit 73f9311

Please sign in to comment.