Skip to content

Commit

Permalink
jellystat: New Role
Browse files Browse the repository at this point in the history
closes #253
  • Loading branch information
saltydk committed Dec 26, 2023
1 parent 6af13e1 commit ef315cd
Show file tree
Hide file tree
Showing 3 changed files with 219 additions and 0 deletions.
162 changes: 162 additions & 0 deletions roles/jellystat/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
##########################################################################
# Title: Sandbox: Jellystat | Default Variables #
# Author(s): salty #
# URL: https://github.com/saltyorg/Sandbox #
# -- #
##########################################################################
# GNU General Public License v3.0 #
##########################################################################
---
################################
# Basics
################################

jellystat_name: jellystat

################################
# Paths
################################

jellystat_paths_folder: "{{ jellystat_name }}"
jellystat_paths_location: "{{ server_appdata_path }}/{{ jellystat_paths_folder }}"
jellystat_paths_jwt_secret_file: "{{ jellystat_paths_location }}/jwt_secret.txt"
jellystat_paths_folders_list:
- "{{ jellystat_paths_location }}"

################################
# Web
################################

jellystat_web_subdomain: "{{ jellystat_name }}"
jellystat_web_domain: "{{ user.domain }}"
jellystat_web_port: "3000"
jellystat_web_url: "{{ 'https://' + (lookup('vars', jellystat_name + '_web_subdomain', default=jellystat_web_subdomain) + '.' + lookup('vars', jellystat_name + '_web_domain', default=jellystat_web_domain)
if (lookup('vars', jellystat_name + '_web_subdomain', default=jellystat_web_subdomain) | length > 0)
else lookup('vars', jellystat_name + '_web_domain', default=jellystat_web_domain)) }}"

################################
# DNS
################################

jellystat_dns_record: "{{ lookup('vars', jellystat_name + '_web_subdomain', default=jellystat_web_subdomain) }}"
jellystat_dns_zone: "{{ lookup('vars', jellystat_name + '_web_domain', default=jellystat_web_domain) }}"
jellystat_dns_proxy: "{{ dns.proxied }}"

################################
# Settings
################################

jellystat_log_level: "INFO"
jellystat_emby: false

################################
# Traefik
################################

jellystat_traefik_sso_middleware: "{{ traefik_default_sso_middleware }}"
jellystat_traefik_middleware_default: "{{ traefik_default_middleware }}"
jellystat_traefik_middleware_custom: ""
jellystat_traefik_certresolver: "{{ traefik_default_certresolver }}"
jellystat_traefik_enabled: true
jellystat_traefik_api_enabled: false
jellystat_traefik_api_endpoint: ""

################################
# Docker
################################

# Container
jellystat_docker_container: "{{ jellystat_name }}"

# Image
jellystat_docker_image_pull: true
jellystat_docker_image_repo: "cyfershepard/jellystat"
jellystat_docker_image_tag: "latest"
jellystat_docker_image: "{{ lookup('vars', jellystat_name + '_docker_image_repo', default=jellystat_docker_image_repo)
+ ':' + lookup('vars', jellystat_name + '_docker_image_tag', default=jellystat_docker_image_tag) }}"

# Ports
jellystat_docker_ports_defaults: []
jellystat_docker_ports_custom: []
jellystat_docker_ports: "{{ lookup('vars', jellystat_name + '_docker_ports_defaults', default=jellystat_docker_ports_defaults)
+ lookup('vars', jellystat_name + '_docker_ports_custom', default=jellystat_docker_ports_custom) }}"

# Envs
jellystat_docker_envs_default:
POSTGRES_USER: "{{ postgres_docker_env_user }}"
POSTGRES_PASSWORD: "{{ postgres_docker_env_password }}"
POSTGRES_IP: "{{ jellystat_name }}-postgres"
POSTGRES_PORT: "5432"
JWT_SECRET: "{{ jwt_token.stdout }}"
jellystat_docker_envs_custom: {}
jellystat_docker_envs: "{{ lookup('vars', jellystat_name + '_docker_envs_default', default=jellystat_docker_envs_default)
| combine(lookup('vars', jellystat_name + '_docker_envs_custom', default=jellystat_docker_envs_custom)) }}"

# Commands
jellystat_docker_commands_default: []
jellystat_docker_commands_custom: []
jellystat_docker_commands: "{{ lookup('vars', jellystat_name + '_docker_commands_default', default=jellystat_docker_commands_default)
+ lookup('vars', jellystat_name + '_docker_commands_custom', default=jellystat_docker_commands_custom) }}"

# Volumes
jellystat_docker_volumes_default:
- "{{ jellystat_paths_location }}:/app/backend/backup-data"
jellystat_docker_volumes_custom: []
jellystat_docker_volumes: "{{ lookup('vars', jellystat_name + '_docker_volumes_default', default=jellystat_docker_volumes_default)
+ lookup('vars', jellystat_name + '_docker_volumes_custom', default=jellystat_docker_volumes_custom) }}"

# Devices
jellystat_docker_devices_default: []
jellystat_docker_devices_custom: []
jellystat_docker_devices: "{{ lookup('vars', jellystat_name + '_docker_devices_default', default=jellystat_docker_devices_default)
+ lookup('vars', jellystat_name + '_docker_devices_custom', default=jellystat_docker_devices_custom) }}"

# Hosts
jellystat_docker_hosts_default: []
jellystat_docker_hosts_custom: []
jellystat_docker_hosts: "{{ docker_hosts_common
| combine(lookup('vars', jellystat_name + '_docker_hosts_default', default=jellystat_docker_hosts_default))
| combine(lookup('vars', jellystat_name + '_docker_hosts_custom', default=jellystat_docker_hosts_custom)) }}"

# Labels
jellystat_docker_labels_default: {}
jellystat_docker_labels_custom: {}
jellystat_docker_labels: "{{ docker_labels_common
| combine(lookup('vars', jellystat_name + '_docker_labels_default', default=jellystat_docker_labels_default))
| combine(lookup('vars', jellystat_name + '_docker_labels_custom', default=jellystat_docker_labels_custom)) }}"

# Hostname
jellystat_docker_hostname: "{{ jellystat_name }}"

# Network Mode
jellystat_docker_network_mode_default: "{{ docker_networks_name_common }}"
jellystat_docker_network_mode: "{{ lookup('vars', jellystat_name + '_docker_network_mode_default', default=jellystat_docker_network_mode_default) }}"

# Networks
jellystat_docker_networks_alias: "{{ jellystat_name }}"
jellystat_docker_networks_default: []
jellystat_docker_networks_custom: []
jellystat_docker_networks: "{{ docker_networks_common
+ lookup('vars', jellystat_name + '_docker_networks_default', default=jellystat_docker_networks_default)
+ lookup('vars', jellystat_name + '_docker_networks_custom', default=jellystat_docker_networks_custom) }}"

# Capabilities
jellystat_docker_capabilities_default: []
jellystat_docker_capabilities_custom: []
jellystat_docker_capabilities: "{{ lookup('vars', jellystat_name + '_docker_capabilities_default', default=jellystat_docker_capabilities_default)
+ lookup('vars', jellystat_name + '_docker_capabilities_custom', default=jellystat_docker_capabilities_custom) }}"

# Security Opts
jellystat_docker_security_opts_default: []
jellystat_docker_security_opts_custom: []
jellystat_docker_security_opts: "{{ lookup('vars', jellystat_name + '_docker_security_opts_default', default=jellystat_docker_security_opts_default)
+ lookup('vars', jellystat_name + '_docker_security_opts_custom', default=jellystat_docker_security_opts_custom) }}"

# Restart Policy
jellystat_docker_restart_policy: unless-stopped

# State
jellystat_docker_state: started

# User
jellystat_docker_user: "{{ uid }}:{{ gid }}"
56 changes: 56 additions & 0 deletions roles/jellystat/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#########################################################################
# Title: Sandbox: Jellystat #
# Author(s): salty #
# URL: https://github.com/saltyorg/Sandbox #
# -- #
#########################################################################
# GNU General Public License v3.0 #
#########################################################################
---
- name: Add DNS record
ansible.builtin.include_tasks: "{{ resources_tasks_path }}/dns/tasker.yml"
vars:
dns_record: "{{ lookup('vars', role_name + '_dns_record') }}"
dns_zone: "{{ lookup('vars', role_name + '_dns_zone') }}"
dns_proxy: "{{ lookup('vars', role_name + '_dns_proxy') }}"

- name: Remove existing Docker container
ansible.builtin.include_tasks: "{{ resources_tasks_path }}/docker/remove_docker_container.yml"

- name: Create directories
ansible.builtin.include_tasks: "{{ resources_tasks_path }}/directories/create_directories.yml"

- name: Check if JWT secret file exists
ansible.builtin.stat:
path: "{{ jellystat_paths_jwt_secret_file }}"
register: jwt_file

- name: Generate JWT Token Secret
ansible.builtin.shell: openssl rand -base64 32
register: jwt_secret
when: not jwt_file.stat.exists

- name: Store JWT Token Secret in a file
ansible.builtin.copy:
content: "{{ jwt_secret.stdout }}"
dest: "{{ jellystat_paths_jwt_secret_file }}"
owner: "{{ user.name }}"
group: "{{ user.name }}"
mode: "0664"
when: not jwt_file.stat.exists

- name: Read JWT Token Secret from file
ansible.builtin.shell: cat "{{ jellystat_paths_jwt_secret_file }}"
register: jwt_token
changed_when: False

- name: PostgreSQL Role
ansible.builtin.include_role:
name: postgres
vars:
postgres_instances: ["{{ jellystat_name }}-postgres"]
postgres_docker_env_db: "jfstat"
postgres_docker_image_tag: "15.2-alpine"

- name: Create Docker container
ansible.builtin.include_tasks: "{{ resources_tasks_path }}/docker/create_docker_container.yml"
1 change: 1 addition & 0 deletions sandbox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
- { role: invoiceninjav5, tags: ['invoiceninja'] }
- { role: jdownloader2, tags: ['jdownloader2'] }
- { role: jellyseerr, tags: ['jellyseerr'] }
- { role: jellystat, tags: ['jellystat'] }
- { role: jirafeau, tags: ['jirafeau'] }
- { role: joplin, tags: ['joplin'] }
- { role: kavita, tags: ['kavita'] }
Expand Down

0 comments on commit ef315cd

Please sign in to comment.