Skip to content

Commit

Permalink
✨ Add Richy
Browse files Browse the repository at this point in the history
  • Loading branch information
anarion80 committed Oct 9, 2024
1 parent c291017 commit 5105870
Show file tree
Hide file tree
Showing 11 changed files with 560 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ If you have a spare domain name you can configure applications to be accessible
* [Readeck](https://codeberg.org/readeck/readeck) - a simple web application that lets you save the precious readable content of web pages you like and want to keep forever.
* [Releasebell](https://github.com/anarion80/releasebell) - Starred GitHub repositories notifications
* [Restic](https://restic.net/) - A modern backup program
* [Richy](https://gitlab.com/imn1/richy) - Application that helps you to manage your investing portfolio
* [Romm](https://github.com/zurdi15/romm) - A game library manager focused on retro gaming
* [Route53 DDNS](https://crazymax.dev/ddns-route53/) - Automatically update AWS Route53 with your IP address
* [RSS-Bridge](https://rss-bridge.github.io/rss-bridge/) - The RSS feed for websites missing it
Expand Down
4 changes: 4 additions & 0 deletions nas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,10 @@
tags:
- restic

- role: richy
tags:
- richy

- role: romm
tags:
- romm
Expand Down
72 changes: 72 additions & 0 deletions roles/richy/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
richy_enabled: false
richy_available_externally: false

# directories
richy_data_directory: "{{ docker_home }}/richy"

# network
richy_port: "8176"
richy_hostname: "richy"
richy_network_name: "richy"

# specs
richy_memory: 1g
richy_db_memory: 1g
richy_nginx_memory: 1g
richy_redis_memory: 1g
richy_worker_memory: 1g
richy_worker_slow_memory: 1g
richy_worker_fast_memory: 1g
richy_beat_memory: 1g

# docker
richy_container_name: richy
richy_image_name: "n1cz/richy"
richy_image_version: latest
richy_db_container_name: richy-db
richy_db_image_name: "postgres"
richy_db_image_version: 16-alpine
richy_nginx_container_name: richy-nginx
richy_nginx_image_name: "nginx"
richy_nginx_image_version: 1.23-alpine
richy_redis_container_name: richy-redis
richy_redis_image_name: redis
richy_redis_image_version: 7-alpine
richy_worker_container_name: richy-worker
richy_worker_image_name: "n1cz/richy"
richy_worker_image_version: latest
richy_worker_slow_container_name: richy-worker-slow
richy_worker_slow_image_name: "n1cz/richy"
richy_worker_slow_image_version: latest
richy_worker_fast_container_name: richy-worker-fast
richy_worker_fast_image_name: "n1cz/richy"
richy_worker_fast_image_version: latest
richy_beat_container_name: richy-beat
richy_beat_image_name: "n1cz/richy"
richy_beat_image_version: latest
richy_user_id: "1000"
richy_group_id: "1000"

# richy
richy_db_user: richy
richy_db_name: richy
richy_db_pass: tralala256
richy_sentry_url: ""
richy_sentry_enable: "false"
richy_base_url: "https://{{ richy_hostname }}.{{ ansible_nas_domain }}"
richy_domain: "{{ richy_hostname }}.{{ ansible_nas_domain }}"
richy_redis_url: "{{ richy_redis_container_name }}:6379"

# main env dictionary for the container and for merging with optional environment variables
richy_env:
DB_PASSWORD: "{{ richy_db_pass }}"
DB_HOST: "{{ richy_db_container_name }}"
DB_NAME: "{{ richy_db_name }}"
DB_USER: "{{ richy_db_user }}"
SENTRY_URL: "{{ richy_sentry_url }}"
SENTRY_ENABLE: "{{ richy_sentry_enable }}"
TZ: "{{ ansible_nas_timezone }}"
BASE_URL: "{{ richy_base_url }}"
DOMAIN: "{{ richy_domain }}"
REDIS_URL: "{{ richy_redis_url }}"
16 changes: 16 additions & 0 deletions roles/richy/molecule/default/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
provisioner:
inventory:
group_vars:
all:
richy_enabled: true
richy_data_directory: "/tmp/richy"
platforms:
- name: instance
image: geerlingguy/docker-ubuntu2204-ansible:latest
volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro
- /var/run/docker.sock:/var/run/docker.sock
- /tmp:/tmp:rw
privileged: true
pre_build_image: true
10 changes: 10 additions & 0 deletions roles/richy/molecule/default/side_effect.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
- name: Stop
hosts: all
become: true
tasks:
- name: "Include {{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }} role"
ansible.builtin.include_role:
name: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }}"
vars:
richy_enabled: false
68 changes: 68 additions & 0 deletions roles/richy/molecule/default/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
- name: Verify
hosts: all
gather_facts: false
tasks:
- name: Include vars
ansible.builtin.include_vars:
file: ../../defaults/main.yml

- name: Get richy db container state
community.docker.docker_container:
name: "{{ richy_db_container_name }}"
register: result_db

- name: Get richy redis container state
community.docker.docker_container:
name: "{{ richy_redis_container_name }}"
register: result_redis

- name: Get richy nginx container state
community.docker.docker_container:
name: "{{ richy_nginx_container_name }}"
register: result_nginx

- name: Get richy worker container state
community.docker.docker_container:
name: "{{ richy_worker_container_name }}"
register: result_worker

- name: Get richy worker slow container state
community.docker.docker_container:
name: "{{ richy_worker_slow_container_name }}"
register: result_worker_slow

- name: Get richy worker fast container state
community.docker.docker_container:
name: "{{ richy_worker_fast_container_name }}"
register: result_worker_fast

- name: Get richy beat container state
community.docker.docker_container:
name: "{{ richy_beat_container_name }}"
register: result_beat

- name: Get richy container state
community.docker.docker_container:
name: "{{ richy_container_name }}"
register: result

- name: Check if richy containers are running
ansible.builtin.assert:
that:
- result_db.container['State']['Status'] == "running"
- result_db.container['State']['Restarting'] == false
- result_redis.container['State']['Status'] == "running"
- result_redis.container['State']['Restarting'] == false
- result_nginx.container['State']['Status'] == "running"
- result_nginx.container['State']['Restarting'] == false
- result_worker.container['State']['Status'] == "running"
- result_worker.container['State']['Restarting'] == false
- result_worker_slow.container['State']['Status'] == "running"
- result_worker_slow.container['State']['Restarting'] == false
- result_worker_fast.container['State']['Status'] == "running"
- result_worker_fast.container['State']['Restarting'] == false
- result_beat.container['State']['Status'] == "running"
- result_beat.container['State']['Restarting'] == false
- result.container['State']['Status'] == "running"
- result.container['State']['Restarting'] == false
68 changes: 68 additions & 0 deletions roles/richy/molecule/default/verify_stopped.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---
- name: Verify
hosts: all
gather_facts: false
tasks:
- name: Include vars
ansible.builtin.include_vars:
file: ../../defaults/main.yml

- name: Try and stop and remove richy
community.docker.docker_container:
name: "{{ richy_container_name }}"
state: absent
register: result

- name: Try and stop and remove richy db
community.docker.docker_container:
name: "{{ richy_db_container_name }}"
state: absent
register: result_db

- name: Try and stop and remove richy redis
community.docker.docker_container:
name: "{{ richy_redis_container_name }}"
state: absent
register: result_redis

- name: Try and stop and remove richy nginx
community.docker.docker_container:
name: "{{ richy_nginx_container_name }}"
state: absent
register: result_nginx

- name: Try and stop and remove richy worker
community.docker.docker_container:
name: "{{ richy_worker_container_name }}"
state: absent
register: result_worker

- name: Try and stop and remove richy worker slow
community.docker.docker_container:
name: "{{ richy_worker_slow_container_name }}"
state: absent
register: result_worker_slow

- name: Try and stop and remove richy worker fast
community.docker.docker_container:
name: "{{ richy_worker_fast_container_name }}"
state: absent
register: result_worker_fast

- name: Try and stop and remove richy beat
community.docker.docker_container:
name: "{{ richy_beat_container_name }}"
state: absent
register: result_beat

- name: Check if richy is stopped
ansible.builtin.assert:
that:
- not result.changed
- not result_db.changed
- not result_redis.changed
- not result_nginx.changed
- not result_worker.changed
- not result_worker_slow.changed
- not result_worker_fast.changed
- not result_beat.changed
1 change: 1 addition & 0 deletions roles/richy/requirements.yml
Loading

0 comments on commit 5105870

Please sign in to comment.