From 12281ac62040ad0a6bd9b86afb12b8f19dd7df35 Mon Sep 17 00:00:00 2001 From: David Stephens Date: Tue, 27 Feb 2024 23:31:44 +0000 Subject: [PATCH] =?UTF-8?q?Add=20Romm=20=F0=9F=8E=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 1 + nas.yml | 4 + roles/romm/defaults/main.yml | 44 +++++++++ roles/romm/molecule/default/molecule.yml | 6 ++ roles/romm/molecule/default/side_effect.yml | 10 ++ roles/romm/molecule/default/verify.yml | 18 ++++ .../romm/molecule/default/verify_stopped.yml | 18 ++++ roles/romm/tasks/main.yml | 91 +++++++++++++++++++ .../docs/applications/media-serving/romm.md | 15 +++ .../docs/getting-started/external-access.md | 2 +- 10 files changed, 208 insertions(+), 1 deletion(-) create mode 100644 roles/romm/defaults/main.yml create mode 100644 roles/romm/molecule/default/molecule.yml create mode 100644 roles/romm/molecule/default/side_effect.yml create mode 100644 roles/romm/molecule/default/verify.yml create mode 100644 roles/romm/molecule/default/verify_stopped.yml create mode 100644 roles/romm/tasks/main.yml create mode 100644 website/docs/applications/media-serving/romm.md diff --git a/README.md b/README.md index 6616847547..a3a6e7e978 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,7 @@ If you have a spare domain name you can configure applications to be accessible * [pyLoad](https://pyload.net/) - A download manager with a friendly web-interface * [PyTivo](http://pytivo.org) - An HMO and GoBack server for TiVos. * [Radarr](https://radarr.video/) - for organising and downloading movies +* [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 * [Sabnzbd](https://sabnzbd.org/) - A powerful usenet downloader that FreeNAS provides diff --git a/nas.yml b/nas.yml index 8e208c33bb..adb5b191d7 100644 --- a/nas.yml +++ b/nas.yml @@ -338,6 +338,10 @@ tags: - radarr + - role: romm + tags: + - romm + - role: route53_ddns tags: - route53_ddns diff --git a/roles/romm/defaults/main.yml b/roles/romm/defaults/main.yml new file mode 100644 index 0000000000..1722c2a238 --- /dev/null +++ b/roles/romm/defaults/main.yml @@ -0,0 +1,44 @@ +--- +romm_enabled: false +romm_available_externally: false + +romm_database_username: romm_user +romm_database_password: top_secret +romm_database_root_password: top_top_secret + +# directories +romm_home: "{{ docker_home }}/romm" +romm_data_directory: "{{ romm_home }}/romm" +romm_db_data_directory: "{{ romm_home }}/db" +romm_roms_directory: "{{ roms_root }}" + +# network +romm_port: "8484" +romm_hostname: "romm" + +# docker +romm_container_name: "romm" +romm_image_name: "zurdi15/romm" +romm_image_version: "latest" + +romm_db_container_name: "romm-db" +romm_db_image_name: "mariadb" +romm_db_image_version: "11.2" + +romm_redis_container_name: "romm-redis" +romm_redis_image_name: "redis" +romm_redis_image_version: "alpine" + +# specs +romm_memory: 1g +romm_db_memory: 1g +romm_redis_memory: 1g + +# IGDB auth credentials - see https://github.com/zurdi15/romm/tree/release#-docker for more info +romm_igdb_client_id: "abcd" +romm_igdb_client_secret: "abcd" + +# auth config +romm_auth_secret_key: "aaaabbbbccccdddd" # Generate a key with `openssl rand -hex 32` +romm_auth_username: "admin" +romm_auth_password: "admin" diff --git a/roles/romm/molecule/default/molecule.yml b/roles/romm/molecule/default/molecule.yml new file mode 100644 index 0000000000..e41beb1cd5 --- /dev/null +++ b/roles/romm/molecule/default/molecule.yml @@ -0,0 +1,6 @@ +--- +provisioner: + inventory: + group_vars: + all: + romm_enabled: true diff --git a/roles/romm/molecule/default/side_effect.yml b/roles/romm/molecule/default/side_effect.yml new file mode 100644 index 0000000000..14773fdc8d --- /dev/null +++ b/roles/romm/molecule/default/side_effect.yml @@ -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: + romm_enabled: false diff --git a/roles/romm/molecule/default/verify.yml b/roles/romm/molecule/default/verify.yml new file mode 100644 index 0000000000..b54c81609a --- /dev/null +++ b/roles/romm/molecule/default/verify.yml @@ -0,0 +1,18 @@ +--- +- name: Verify + hosts: all + gather_facts: false + tasks: + - ansible.builtin.include_vars: + file: ../../defaults/main.yml + + - name: Get Romm container state + community.docker.docker_container: + name: "{{ romm_container_name }}" + register: result + + - name: Check if Romm containers are running + ansible.builtin.assert: + that: + - result.container['State']['Status'] == "running" + - result.container['State']['Restarting'] == false diff --git a/roles/romm/molecule/default/verify_stopped.yml b/roles/romm/molecule/default/verify_stopped.yml new file mode 100644 index 0000000000..0ddb28f220 --- /dev/null +++ b/roles/romm/molecule/default/verify_stopped.yml @@ -0,0 +1,18 @@ +--- +- name: Verify + hosts: all + gather_facts: false + tasks: + - ansible.builtin.include_vars: + file: ../../defaults/main.yml + + - name: Try and stop and remove Romm + community.docker.docker_container: + name: "{{ romm_container_name }}" + state: absent + register: result + + - name: Check if joomla is stopped + ansible.builtin.assert: + that: + - not result.changed diff --git a/roles/romm/tasks/main.yml b/roles/romm/tasks/main.yml new file mode 100644 index 0000000000..dbeba12e7d --- /dev/null +++ b/roles/romm/tasks/main.yml @@ -0,0 +1,91 @@ +--- +- name: Start Romm + block: + - name: Create Romm Directories + ansible.builtin.file: + path: "{{ item }}" + state: directory + with_items: + - "{{ romm_data_directory }}/resources" + - "{{ romm_db_data_directory }}" + + - name: MariaDB Docker Container for Romm + community.docker.docker_container: + name: "{{ romm_db_container_name }}" + image: "{{ romm_db_image_name }}:{{ romm_db_image_version }}" + pull: true + volumes: + - "{{ romm_db_data_directory }}/db:/var/lib/mysql" + env: + MYSQL_ROOT_PASSWORD: "{{ romm_database_root_password }}" + MYSQL_DATABASE: "romm" + MYSQL_USER: "{{ romm_database_username }}" + MYSQL_PASSWORD: "{{ romm_database_password }}" + restart_policy: unless-stopped + memory: "{{ romm_db_memory }}" + + - name: Create Romm Redis + community.docker.docker_container: + name: "{{ romm_redis_container_name }}" + image: "{{ romm_redis_image_name }}:{{ romm_redis_image_version }}" + pull: true + restart_policy: unless-stopped + memory: "{{ romm_redis_memory }}" + + - name: Romm Docker Container + community.docker.docker_container: + name: "{{ romm_container_name }}" + image: "{{ romm_image_name }}:{{ romm_image_version }}" + pull: true + volumes: + - "{{ romm_roms_directory }}:/romm/library/roms:rw" + - "{{ romm_data_directory }}/resources:/romm/resources:rw" + ports: + - "{{ romm_port }}:8080" + env: + ROMM_DB_DRIVER: "mariadb" + DB_HOST: "db" + DB_PORT: "3306" + DB_USER: "{{ romm_database_username }}" + DB_PASSWD: "{{ romm_database_password }}" + DB_NAME: "romm" + ROMM_AUTH_ENABLED: "true" + ROMM_AUTH_SECRET_KEY: "{{ romm_auth_secret_key }}" + ENABLE_EXPERIMENTAL_REDIS: "true" + REDIS_HOST: "redis" + REDIS_PORT: "6379" + IGDB_CLIENT_ID: "{{ romm_igdb_client_id }}" + IGDB_CLIENT_SECRET: "{{ romm_igdb_client_secret }}" + ROMM_AUTH_USERNAME: "{{ romm_auth_username }}" + ROMM_AUTH_PASSWORD: "{{ romm_auth_password }}" + restart_policy: unless-stopped + memory: "{{ romm_memory }}" + links: + - "{{ romm_db_container_name }}:db" + - "{{ romm_redis_container_name }}:redis" + labels: + traefik.enable: "{{ romm_available_externally | string }}" + traefik.http.routers.romm.rule: "Host(`{{ romm_hostname }}.{{ ansible_nas_domain }}`)" + traefik.http.routers.romm.tls.certresolver: "letsencrypt" + traefik.http.routers.romm.tls.domains[0].main: "{{ ansible_nas_domain }}" + traefik.http.routers.romm.tls.domains[0].sans: "*.{{ ansible_nas_domain }}" + traefik.http.services.romm.loadbalancer.server.port: "8080" + homepage.group: Media + homepage.name: Romm + homepage.icon: romm + homepage.href: http://{{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }}:{{ romm_port }} + homepage.description: Game library manager + when: romm_enabled is true + +- name: Stop Romm + block: + - name: Stop Romm + community.docker.docker_container: + name: "{{ romm_container_name }}" + state: absent + + - name: Stop Romm DB + community.docker.docker_container: + name: "{{ romm_db_container_name }}" + state: absent + when: romm_enabled is false diff --git a/website/docs/applications/media-serving/romm.md b/website/docs/applications/media-serving/romm.md new file mode 100644 index 0000000000..71417b3711 --- /dev/null +++ b/website/docs/applications/media-serving/romm.md @@ -0,0 +1,15 @@ +--- +title: "Romm" +--- + +Homepage: [https://github.com/zurdi15/romm](https://github.com/zurdi15/romm) + +RomM (ROM Manager) is a game library manager focused on retro gaming. + +It enables you to efficiently manage and organize all your games from a web browser. + +## Usage + +Set `romm_enabled: true` in your `inventories//group_vars/nas.yml` file. + +The Romm web interface can be found at [http://ansible_nas_host_or_ip:8484](http://ansible_nas_host_or_ip:8484). diff --git a/website/docs/getting-started/external-access.md b/website/docs/getting-started/external-access.md index ad7377e299..524785b61c 100644 --- a/website/docs/getting-started/external-access.md +++ b/website/docs/getting-started/external-access.md @@ -31,7 +31,7 @@ Traefik routes traffic from ports 80 (HTTP) and 443 (HTTPS) on your Ansible-NAS Simply set `traefik_enabled: true` in your `all.yml`. By default it listens on ports 80 and 443, but doesn't route any traffic. -Ensure you set the relevant environment variables for your DNS provider in `traefik_environment_variables`. More info at https://doc.traefik.io/traefik/https/acme/. +Ensure you set the relevant environment variables for your DNS provider in `traefik_environment_variables`. More info in the [Traefik ACME docs](https://doc.traefik.io/traefik/https/acme/). ## Router Configuration