Another batch: from paperless-ng to portainer

This commit is contained in:
Anarion 2023-03-10 14:18:19 +01:00
parent e253f0a5d0
commit 2cddba35c4
No known key found for this signature in database
GPG key ID: 6C9E149718A7D4EB
32 changed files with 434 additions and 253 deletions

View file

@ -1,5 +1,6 @@
--- ---
paperless_ng_enabled: false paperless_ng_enabled: false
paperless_ng_available_externally: false
# directories # directories
paperless_ng_config_directory: "{{ docker_home }}/paperless_ng" paperless_ng_config_directory: "{{ docker_home }}/paperless_ng"
@ -14,6 +15,7 @@ paperless_ng_consume_directory: "{{ paperless_ng_files_directory }}/consume"
# network # network
paperless_ng_port: "16922" paperless_ng_port: "16922"
paperless_ng_hostname: "paperless_ng" paperless_ng_hostname: "paperless_ng"
paperless_ng_network_name: "paperless_ng"
# postgres # postgres
paperless_ng_postgres_db: "paperless" paperless_ng_postgres_db: "paperless"
@ -21,10 +23,18 @@ paperless_ng_postgres_user: "paperless"
paperless_ng_postgres_password: "paperless" paperless_ng_postgres_password: "paperless"
# container names # container names
paperless_ng_container_network_name: "paperless_ng_network"
paperless_ng_container_name_redis: "paperless_ng_redis" paperless_ng_redis_container_name: "paperless-redis"
paperless_ng_container_name_postgres: "paperless_ng_postgres" paperless_ng_redis_image_name: "redis"
paperless_ng_container_name_uiserver: "paperless_ng_uiserver" paperless_ng_redis_image_version: "6.0"
paperless_ng_db_container_name: "paperless-db"
paperless_ng_db_image_name: "postgres"
paperless_ng_db_image_version: "13"
paperless_ng_uiserver_container_name: "paperless-uiserver"
paperless_ng_uiserver_image_name: "jonaswinkler/paperless-ng"
paperless_ng_uiserver_image_version: "latest"
# uid/guid # uid/guid
paperless_ng_user_id: "1000" paperless_ng_user_id: "1000"

View file

@ -0,0 +1,23 @@
# Paperless-ng
Homepage: <https://github.com/jonaswinkler/paperless-ng>
Paperless is an application by Daniel Quinn and contributors that indexes your scanned documents and allows you to easily search for documents and store metadata alongside your documents.
Paperless-ng is a fork of the original project, adding a new interface and many other changes under the hood
## Usage
Set `paperless_ng_enabled: true` in your `inventories/<your_inventory>/nas.yml` file.
The paperless-ng web interface can be found at <http://ansible_nas_host_or_ip:16922>.
### Create the superuser
To be able to login, you will need a super user. To create it, execute the following command:
```bash
docker exec -it paperless_ng_uiserver python manage.py createsuperuser
```
This will prompt you to set a username, an optional e-mail address and finally a password (at least 8 characters).

View file

@ -1,11 +0,0 @@
# Trilium
Homepage: <https://github.com/zadam/trilium>
A hierarchical note taking application with focus on building large personal knowledge bases.
## Usage
Set `trilium_enabled: true` in your `inventories/<your_inventory>/nas.yml` file.
Trilium web interface can be found at <http://ansible_nas_host_or_ip:8105>.

View file

@ -3,4 +3,4 @@ provisioner:
inventory: inventory:
group_vars: group_vars:
all: all:
trilium_enabled: true paperless_ng_enabled: true

View file

@ -7,4 +7,4 @@
ansible.builtin.include_role: ansible.builtin.include_role:
name: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }}" name: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }}"
vars: vars:
trilium_enabled: false paperless_ng_enabled: false

View file

@ -7,13 +7,27 @@
ansible.builtin.include_vars: ansible.builtin.include_vars:
file: ../../defaults/main.yml file: ../../defaults/main.yml
- name: Get trilium container state - name: Get paperless_ng redis container state
community.docker.docker_container: community.docker.docker_container:
name: "{{ trilium_container_name }}" name: "{{ paperless_ng_redis_container_name }}"
register: result_redis
- name: Get paperless_ng db container state
community.docker.docker_container:
name: "{{ paperless_ng_db_container_name }}"
register: result_db
- name: Get paperless_ng container state
community.docker.docker_container:
name: "{{ paperless_ng_uiserver_container_name }}"
register: result register: result
- name: Check if trilium containers are running - name: Check if paperless_ng containers are running
ansible.builtin.assert: ansible.builtin.assert:
that: that:
- result_redis.container['State']['Status'] == "running"
- result_redis.container['State']['Restarting'] == false
- result_db.container['State']['Status'] == "running"
- result_db.container['State']['Restarting'] == false
- result.container['State']['Status'] == "running" - result.container['State']['Status'] == "running"
- result.container['State']['Restarting'] == false - result.container['State']['Restarting'] == false

View file

@ -7,13 +7,27 @@
ansible.builtin.include_vars: ansible.builtin.include_vars:
file: ../../defaults/main.yml file: ../../defaults/main.yml
- name: Try and stop and remove trilium - name: Try and stop and remove paperless_ng
community.docker.docker_container: community.docker.docker_container:
name: "{{ trilium_container_name }}" name: "{{ paperless_ng_uiserver_container_name }}"
state: absent state: absent
register: result register: result
- name: Check if trilium is stopped - name: Try and stop and remove paperless_ng db
community.docker.docker_container:
name: "{{ paperless_ng_db_container_name }}"
state: absent
register: result_db
- name: Try and stop and remove paperless_ng redis
community.docker.docker_container:
name: "{{ paperless_ng_redis_container_name }}"
state: absent
register: result_redis
- name: Check if paperless_ng is stopped
ansible.builtin.assert: ansible.builtin.assert:
that: that:
- not result.changed - not result.changed
- not result_db.changed
- not result_redis.changed

View file

@ -1,67 +1,96 @@
--- ---
- name: Create paperless_ng directories - name: Start paperless_ng
file: block:
path: "{{ item }}" - name: Create paperless_ng directories
state: directory ansible.builtin.file:
with_items: path: "{{ item }}"
- "{{ paperless_ng_config_directory }}" state: directory
- "{{ paperless_ng_files_directory }}" with_items:
- "{{ paperless_ng_postgres_directory }}" - "{{ paperless_ng_config_directory }}"
- "{{ paperless_ng_data_directory }}" - "{{ paperless_ng_files_directory }}"
- "{{ paperless_ng_export_directory }}" - "{{ paperless_ng_postgres_directory }}"
- "{{ paperless_ng_media_directory }}" - "{{ paperless_ng_data_directory }}"
- "{{ paperless_ng_consume_directory }}" - "{{ paperless_ng_export_directory }}"
- "{{ paperless_ng_media_directory }}"
- "{{ paperless_ng_consume_directory }}"
- name: Create paperless_ng network
community.docker.docker_network:
name: "{{ paperless_ng_network_name }}"
- name: Create paperless_ng network - name: Create paperless_ng redis broker
docker_network: community.docker.docker_container:
name: "{{ paperless_ng_container_network_name }}" container_default_behavior: no_defaults
name: "{{ paperless_ng_redis_container_name }}"
image: "{{ paperless_ng_redis_image_name }}:{{ paperless_ng_redis_image_version }}"
pull: true
restart_policy: unless-stopped
memory: "{{ paperless_ng_redis_memory }}"
networks:
- name: "{{ paperless_ng_network_name }}"
network_mode: "{{ paperless_ng_network_name }}"
- name: Create paperless_ng redis broker - name: Create paperless_ng postgres Docker Container
docker_container: community.docker.docker_container:
name: "{{ paperless_ng_container_name_redis }}" name: "{{ paperless_ng_db_container_name }}"
image: redis:6.0 image: "{{ paperless_ng_db_image_name }}:{{ paperless_ng_db_image_version }}"
pull: true pull: true
restart_policy: unless-stopped volumes:
memory: "{{ paperless_ng_redis_memory }}" - "{{ paperless_ng_postgres_directory }}:/var/lib/postgresql/data"
networks: env:
- name: "{{ paperless_ng_container_network_name }}" POSTGRES_DB: "{{ paperless_ng_postgres_db }}"
POSTGRES_USER: "{{ paperless_ng_postgres_user }}"
POSTGRES_PASSWORD: "{{ paperless_ng_postgres_password }}"
restart_policy: unless-stopped
memory: "{{ paperless_ng_postgres_memory }}"
networks:
- name: "{{ paperless_ng_network_name }}"
network_mode: "{{ paperless_ng_network_name }}"
- name: Create paperless_ng postgres Docker Container - name: Create paperless_ng UI Docker Container
docker_container: community.docker.docker_container:
name: "{{ paperless_ng_container_name_postgres }}" name: "{{ paperless_ng_uiserver_container_name }}"
image: postgres:13 image: "{{ paperless_ng_uiserver_image_name }}:{{ paperless_ng_uiserver_image_version }}"
pull: true pull: true
volumes: volumes:
- "{{ paperless_ng_postgres_directory }}:/var/lib/postgresql/data" - "{{ paperless_ng_data_directory }}:/usr/src/paperless/data"
env: - "{{ paperless_ng_media_directory }}:/usr/src/paperless/media"
POSTGRES_DB: "{{ paperless_ng_postgres_db }}" - "{{ paperless_ng_export_directory }}:/usr/src/paperless/export"
POSTGRES_USER: "{{ paperless_ng_postgres_user }}" - "{{ paperless_ng_consume_directory }}:/usr/src/paperless/consume"
POSTGRES_PASSWORD: "{{ paperless_ng_postgres_password }}" ports:
restart_policy: unless-stopped - "{{ paperless_ng_port }}:8000"
memory: "{{ paperless_ng_postgres_memory }}" env:
networks: PAPERLESS_REDIS: "redis://{{ paperless_ng_redis_container_name | string }}:6379"
- name: "{{ paperless_ng_container_network_name }}" PAPERLESS_DBHOST: "{{ paperless_ng_db_container_name | string }}"
USERMAP_UID: "{{ paperless_ng_user_id }}"
USERMAP_GID: "{{ paperless_ng_group_id }}"
PAPERLESS_OCR_LANGUAGES: "{{ paperless_ng_languages }}"
restart_policy: unless-stopped
memory: "{{ paperless_ng_ui_memory }}"
networks:
- name: "{{ paperless_ng_network_name }}"
network_mode: "{{ paperless_ng_network_name }}"
labels:
traefik.enable: "{{ paperless_ng_available_externally | string }}"
traefik.http.routers.paperless_ng.rule: "Host(`{{ paperless_ng_hostname }}.{{ ansible_nas_domain }}`)"
traefik.http.routers.paperless_ng.tls.certresolver: "letsencrypt"
traefik.http.routers.paperless_ng.tls.domains[0].main: "{{ ansible_nas_domain }}"
traefik.http.routers.paperless_ng.tls.domains[0].sans: "*.{{ ansible_nas_domain }}"
traefik.http.services.paperless_ng.loadbalancer.server.port: "8080"
when: paperless_ng_enabled is true
- name: Create paperless_ng UI Docker Container - name: Stop paperless_ng
docker_container: block:
name: "{{ paperless_ng_container_name_uiserver }}" - name: Stop paperless_ng
image: jonaswinkler/paperless-ng:latest community.docker.docker_container:
pull: true name: "{{ paperless_ng_uiserver_container_name }}"
volumes: state: absent
- "{{ paperless_ng_data_directory }}:/usr/src/paperless/data" - name: Stop paperless_ng redis
- "{{ paperless_ng_media_directory }}:/usr/src/paperless/media" community.docker.docker_container:
- "{{ paperless_ng_export_directory }}:/usr/src/paperless/export" name: "{{ paperless_ng_redis_container_name }}"
- "{{ paperless_ng_consume_directory }}:/usr/src/paperless/consume" state: absent
ports: - name: Stop paperless_ng db
- "{{ paperless_ng_port }}:8000" community.docker.docker_container:
env: name: "{{ paperless_ng_db_container_name }}"
PAPERLESS_REDIS: "redis://{{ paperless_ng_container_name_redis | string }}:6379" state: absent
PAPERLESS_DBHOST: "{{ paperless_ng_container_name_postgres | string }}" when: paperless_ng_enabled is false
USERMAP_UID: "{{ paperless_ng_user_id }}"
USERMAP_GID: "{{ paperless_ng_group_id }}"
PAPERLESS_OCR_LANGUAGES: "{{ paperless_ng_languages }}"
restart_policy: unless-stopped
memory: "{{ paperless_ng_ui_memory }}"
networks:
- name: "{{ paperless_ng_container_network_name }}"

View file

@ -18,8 +18,17 @@ piwigo_photos_permission: "rw"
# network # network
piwigo_hostname: "piwigo" piwigo_hostname: "piwigo"
piwigo_network_name: "piwigo"
piwigo_port: "16923" piwigo_port: "16923"
# docker
piwigo_db_container_name: "piwigo-db"
piwigo_db_image_name: "mysql"
piwigo_db_image_version: "5.7"
piwigo_container_name: "piwigo"
piwigo_image_name: "linuxserver/piwigo"
piwigo_image_version: "latest"
# specs # specs
piwigo_memory: "1g" piwigo_memory: "1g"
piwigo_mysql_memory: "1g" piwigo_mysql_memory: "1g"

View file

@ -0,0 +1,28 @@
# Piwigo
Homepage: [Piwigo.org](https://piwigo.org)
Piwigo is open source photo gallery software for the web. Designed for organisations, teams and individuals.
## Usage
Set `piwigo_enabled: true` in your `inventories/<your_inventory>/nas.yml` file.
If you want to access Piwigo externally, set `piwigo_available_externally: true` in your `inventories/<your_inventory>/nas.yml` file.
The Piwigo web interface can be found at <http://ansible_nas_host_or_ip:16923>.
## Specific Configuration
Optional configurations:
- Set `piwigo_mysql_user` in `inventories/<your_inventory>/group_vars/nas.yml` before installing Piwigo, this defaults to "piwigo".
- Set `piwigo_mysql_password` in `inventories/<your_inventory>/group_vars/nas.yml` before installing Piwigo, this defaults to "piwigo".
- Set `piwigo_mysql_root_password` in `inventories/<your_inventory>/group_vars/nas.yml` before installing Piwigo, this defaults to "piwigo".
- On first run you'll need to enter database details:
- Host: `db:3306`
- Username: the value of piwigo_mysql_user, defaults to "piwigo"
- Password: the value of piwigo_password, defaults to "piwigo"
- Database Name: `piwigo`
- Database tables prefix: should be prefilled with `piwigo_`

View file

@ -1,11 +0,0 @@
# Trilium
Homepage: <https://github.com/zadam/trilium>
A hierarchical note taking application with focus on building large personal knowledge bases.
## Usage
Set `trilium_enabled: true` in your `inventories/<your_inventory>/nas.yml` file.
Trilium web interface can be found at <http://ansible_nas_host_or_ip:8105>.

View file

@ -3,4 +3,4 @@ provisioner:
inventory: inventory:
group_vars: group_vars:
all: all:
trilium_enabled: true piwigo_enabled: true

View file

@ -7,4 +7,4 @@
ansible.builtin.include_role: ansible.builtin.include_role:
name: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }}" name: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }}"
vars: vars:
trilium_enabled: false piwigo_enabled: false

View file

@ -7,13 +7,20 @@
ansible.builtin.include_vars: ansible.builtin.include_vars:
file: ../../defaults/main.yml file: ../../defaults/main.yml
- name: Get trilium container state - name: Get piwigo db container state
community.docker.docker_container: community.docker.docker_container:
name: "{{ trilium_container_name }}" name: "{{ piwigo_db_container_name }}"
register: result_db
- name: Get piwigo container state
community.docker.docker_container:
name: "{{ piwigo_container_name }}"
register: result register: result
- name: Check if trilium containers are running - name: Check if piwigo containers are running
ansible.builtin.assert: ansible.builtin.assert:
that: that:
- result.container['State']['Status'] == "running" - result.container['State']['Status'] == "running"
- result.container['State']['Restarting'] == false - result.container['State']['Restarting'] == false
- result_db.container['State']['Status'] == "running"
- result_db.container['State']['Restarting'] == false

View file

@ -7,13 +7,20 @@
ansible.builtin.include_vars: ansible.builtin.include_vars:
file: ../../defaults/main.yml file: ../../defaults/main.yml
- name: Try and stop and remove trilium - name: Try and stop and remove piwigo
community.docker.docker_container: community.docker.docker_container:
name: "{{ trilium_container_name }}" name: "{{ piwigo_container_name }}"
state: absent state: absent
register: result register: result
- name: Check if trilium is stopped - name: Try and stop and remove piwigo db
community.docker.docker_container:
name: "{{ piwigo_db_container_name }}"
state: absent
register: result_db
- name: Check if piwigo is stopped
ansible.builtin.assert: ansible.builtin.assert:
that: that:
- not result.changed - not result.changed
- not result_db.changed

View file

@ -1,51 +1,76 @@
--- ---
- name: Create Piwigo Directories - name: Start Piwigo
file: block:
path: "{{ item }}" - name: Create Piwigo Directories
state: directory ansible.builtin.file:
with_items: path: "{{ item }}"
- "{{ piwigo_config_directory }}" state: directory
- "{{ piwigo_data_directory }}" with_items:
- "{{ piwigo_photos }}" - "{{ piwigo_config_directory }}"
- "{{ piwigo_data_directory }}"
- "{{ piwigo_photos }}"
- name: Create MySQL container for Piwigo - name: Create Piwigo network
docker_container: community.docker.docker_network:
name: piwigo-mysql name: "{{ piwigo_network_name }}"
image: mysql:5.7
pull: true
volumes:
- "{{ piwigo_data_directory }}/mysql:/var/lib/mysql:rw"
env:
MYSQL_DATABASE: "piwigo"
MYSQL_USER: "{{ piwigo_mysql_user }}"
MYSQL_PASSWORD: "{{ piwigo_mysql_password }}"
MYSQL_ROOT_PASSWORD: "{{ piwigo_mysql_root_password }}"
restart_policy: unless-stopped
memory: "{{ piwigo_mysql_memory }}"
- name: Piwigo Docker Container - name: Create MySQL container for Piwigo
docker_container: community.docker.docker_container:
name: piwigo container_default_behavior: no_defaults
image: linuxserver/piwigo name: "{{ piwigo_db_container_name }}"
pull: true image: "{{ piwigo_db_image_name }}:{{ piwigo_db_image_version }}"
volumes: pull: true
- "{{ piwigo_config_directory }}:/config:rw" volumes:
- "{{ piwigo_photos }}:/gallery:rw" - "{{ piwigo_data_directory }}/mysql:/var/lib/mysql:rw"
links: env:
- piwigo-mysql:db MYSQL_DATABASE: "piwigo"
ports: MYSQL_USER: "{{ piwigo_mysql_user }}"
- "{{ piwigo_port }}:80" MYSQL_PASSWORD: "{{ piwigo_mysql_password }}"
env: MYSQL_ROOT_PASSWORD: "{{ piwigo_mysql_root_password }}"
TZ: "{{ ansible_nas_timezone }}" restart_policy: unless-stopped
PUID: "{{ piwigo_user_id }}" memory: "{{ piwigo_mysql_memory }}"
PGID: "{{ piwigo_group_id }}" networks:
VERSION: "{{ piwigo_version }}" - name: "{{ piwigo_network_name }}"
restart_policy: unless-stopped network_mode: "{{ piwigo_network_name }}"
memory: "{{ piwigo_memory }}"
labels: - name: Piwigo Docker Container
traefik.enable: "{{ piwigo_available_externally | string }}" community.docker.docker_container:
traefik.http.routers.piwigo.rule: "Host(`{{ piwigo_hostname }}.{{ ansible_nas_domain }}`)" container_default_behavior: no_defaults
traefik.http.routers.piwigo.tls.certresolver: "letsencrypt" name: "{{ piwigo_container_name }}"
traefik.http.routers.piwigo.tls.domains[0].main: "{{ ansible_nas_domain }}" image: "{{ piwigo_image_name }}:{{ piwigo_image_version }}"
traefik.http.routers.piwigo.tls.domains[0].sans: "*.{{ ansible_nas_domain }}" pull: true
traefik.http.services.piwigo.loadbalancer.server.port: "80" volumes:
- "{{ piwigo_config_directory }}:/config:rw"
- "{{ piwigo_photos }}:/gallery:rw"
ports:
- "{{ piwigo_port }}:80"
env:
TZ: "{{ ansible_nas_timezone }}"
PUID: "{{ piwigo_user_id }}"
PGID: "{{ piwigo_group_id }}"
VERSION: "{{ piwigo_version }}"
restart_policy: unless-stopped
memory: "{{ piwigo_memory }}"
networks:
- name: "{{ piwigo_network_name }}"
network_mode: "{{ piwigo_network_name }}"
labels:
traefik.enable: "{{ piwigo_available_externally | string }}"
traefik.http.routers.piwigo.rule: "Host(`{{ piwigo_hostname }}.{{ ansible_nas_domain }}`)"
traefik.http.routers.piwigo.tls.certresolver: "letsencrypt"
traefik.http.routers.piwigo.tls.domains[0].main: "{{ ansible_nas_domain }}"
traefik.http.routers.piwigo.tls.domains[0].sans: "*.{{ ansible_nas_domain }}"
traefik.http.services.piwigo.loadbalancer.server.port: "80"
when: piwigo_enabled is true
- name: Stop Piwigo
block:
- name: Stop Piwigo
community.docker.docker_container:
name: "{{ piwigo_container_name }}"
state: absent
- name: Stop Piwigo Db
community.docker.docker_container:
name: "{{ piwigo_db_container_name }}"
state: absent
when: piwigo_enabled is false

View file

@ -28,6 +28,11 @@ plex_audiobooks_permissions: "rw"
# network # network
plex_hostname: "plex" plex_hostname: "plex"
# docker
plex_container_name: "plex"
plex_image_name: "linuxserver/plex"
plex_image_version: "latest"
# specs # specs
plex_memory: "2g" plex_memory: "2g"

16
roles/plex/docs/plex.md Normal file
View file

@ -0,0 +1,16 @@
# Plex
Homepage: <https://www.plex.tv/>
Plex is a personal media server that also provides access to several external movie, web show, and podcast services. Allows you to stream music too. Apps for many devices, including e.g. chromecast integration.
## Usage
Set `plex_enabled: true` in your `inventories/<your_inventory>/nas.yml` file.
The Plex web interface can be found at <http://ansible_nas_host_or_ip:32400/web/index.html>.
## Specific Configuration
You'll need to log in with a plex account, (or possibly claim your server).
You'll need to set up your local file store - go to settings > Manage > Libraries, and add your libraries. These are mounted in the root directory by default.

View file

@ -1,11 +0,0 @@
# Trilium
Homepage: <https://github.com/zadam/trilium>
A hierarchical note taking application with focus on building large personal knowledge bases.
## Usage
Set `trilium_enabled: true` in your `inventories/<your_inventory>/nas.yml` file.
Trilium web interface can be found at <http://ansible_nas_host_or_ip:8105>.

View file

@ -3,4 +3,4 @@ provisioner:
inventory: inventory:
group_vars: group_vars:
all: all:
trilium_enabled: true plex_enabled: true

View file

@ -7,4 +7,4 @@
ansible.builtin.include_role: ansible.builtin.include_role:
name: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }}" name: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }}"
vars: vars:
trilium_enabled: false plex_enabled: false

View file

@ -7,12 +7,12 @@
ansible.builtin.include_vars: ansible.builtin.include_vars:
file: ../../defaults/main.yml file: ../../defaults/main.yml
- name: Get trilium container state - name: Get plex container state
community.docker.docker_container: community.docker.docker_container:
name: "{{ trilium_container_name }}" name: "{{ plex_container_name }}"
register: result register: result
- name: Check if trilium containers are running - name: Check if plex containers are running
ansible.builtin.assert: ansible.builtin.assert:
that: that:
- result.container['State']['Status'] == "running" - result.container['State']['Status'] == "running"

View file

@ -7,13 +7,13 @@
ansible.builtin.include_vars: ansible.builtin.include_vars:
file: ../../defaults/main.yml file: ../../defaults/main.yml
- name: Try and stop and remove trilium - name: Try and stop and remove plex
community.docker.docker_container: community.docker.docker_container:
name: "{{ trilium_container_name }}" name: "{{ plex_container_name }}"
state: absent state: absent
register: result register: result
- name: Check if trilium is stopped - name: Check if plex is stopped
ansible.builtin.assert: ansible.builtin.assert:
that: that:
- not result.changed - not result.changed

View file

@ -1,40 +1,52 @@
--- ---
- name: Create Plex Directories - name: Start Plex
file: block:
path: "{{ item }}" - name: Create Plex Directories
state: directory ansible.builtin.file:
# mode: 0755 path: "{{ item }}"
with_items: state: directory
- "{{ plex_config_directory }}" # mode: 0755
- "{{ plex_logs }}" with_items:
- "{{ plex_config_directory }}"
- "{{ plex_logs }}"
- name: Create Plex Docker Container - name: Create Plex Docker Container
docker_container: community.docker.docker_container:
name: plex container_default_behavior: no_defaults
image: linuxserver/plex name: "{{ plex_container_name }}"
pull: true image: "{{ plex_image_name }}:{{ plex_image_version }}"
volumes: pull: true
- "{{ plex_config_directory }}:/config:rw" volumes:
- "{{ plex_logs }}:/opt/plex/Library/Application Support/Plex Media Server/Logs:rw" - "{{ plex_config_directory }}:/config:rw"
- "{{ plex_movies_directory }}:/movies:{{ plex_movies_permissions }}" - "{{ plex_logs }}:/opt/plex/Library/Application Support/Plex Media Server/Logs:rw"
- "{{ plex_tv_directory }}:/tv:{{ plex_tv_permissions }}" - "{{ plex_movies_directory }}:/movies:{{ plex_movies_permissions }}"
- "{{ plex_photos_directory }}:/photos:{{ plex_photos_permissions }}" - "{{ plex_tv_directory }}:/tv:{{ plex_tv_permissions }}"
- "{{ plex_podcasts_directory }}:/podcasts:{{ plex_podcasts_permissions }}" - "{{ plex_photos_directory }}:/photos:{{ plex_photos_permissions }}"
- "{{ plex_music_directory }}:/music:{{ plex_music_permissions }}" - "{{ plex_podcasts_directory }}:/podcasts:{{ plex_podcasts_permissions }}"
- "{{ plex_audiobooks_directory }}:/audiobooks:{{ plex_audiobooks_permissions }}" - "{{ plex_music_directory }}:/music:{{ plex_music_permissions }}"
network_mode: "host" - "{{ plex_audiobooks_directory }}:/audiobooks:{{ plex_audiobooks_permissions }}"
devices: "{{ plex_devices | default(omit) }}" network_mode: "host"
env: devices: "{{ plex_devices | default(omit) }}"
TZ: "{{ ansible_nas_timezone }}" env:
PUID: "{{ plex_user_id }}" TZ: "{{ ansible_nas_timezone }}"
PGID: "{{ plex_group_id }}" PUID: "{{ plex_user_id }}"
VERSION: "{{ plex_version }}" PGID: "{{ plex_group_id }}"
restart_policy: unless-stopped VERSION: "{{ plex_version }}"
memory: "{{ plex_memory }}" restart_policy: unless-stopped
labels: memory: "{{ plex_memory }}"
traefik.enable: "{{ plex_available_externally | string }}" labels:
traefik.http.routers.plex.rule: "Host(`{{ plex_hostname }}.{{ ansible_nas_domain }}`)" traefik.enable: "{{ plex_available_externally | string }}"
traefik.http.routers.plex.tls.certresolver: "letsencrypt" traefik.http.routers.plex.rule: "Host(`{{ plex_hostname }}.{{ ansible_nas_domain }}`)"
traefik.http.routers.plex.tls.domains[0].main: "{{ ansible_nas_domain }}" traefik.http.routers.plex.tls.certresolver: "letsencrypt"
traefik.http.routers.plex.tls.domains[0].sans: "*.{{ ansible_nas_domain }}" traefik.http.routers.plex.tls.domains[0].main: "{{ ansible_nas_domain }}"
traefik.http.services.plex.loadbalancer.server.port: "32400" traefik.http.routers.plex.tls.domains[0].sans: "*.{{ ansible_nas_domain }}"
traefik.http.services.plex.loadbalancer.server.port: "32400"
when: plex_enabled is true
- name: Stop Plex
block:
- name: Stop Plex
community.docker.docker_container:
name: "{{ plex_container_name }}"
state: absent
when: plex_enabled is false

View file

@ -9,5 +9,10 @@ portainer_data_directory: "{{ docker_home }}/portainer/config"
portainer_port: "9000" portainer_port: "9000"
portainer_hostname: "portainer" portainer_hostname: "portainer"
# docker
portainer_container_name: "portainer"
portainer_image_name: "portainer/portainer-ce"
portainer_image_version: "latest"
# specs # specs
portainer_memory: 1g portainer_memory: 1g

View file

@ -0,0 +1,9 @@
# Portainer
Homepage: <https://docs.portainer.io/start/install/server/docker>
## Usage
Set `portainer_enabled: true` in your `inventories/<your_inventory>/nas.yml` file.
The Portainer web interface can be found at <http://ansible_nas_host_or_ip:9000>.

View file

@ -1,11 +0,0 @@
# Trilium
Homepage: <https://github.com/zadam/trilium>
A hierarchical note taking application with focus on building large personal knowledge bases.
## Usage
Set `trilium_enabled: true` in your `inventories/<your_inventory>/nas.yml` file.
Trilium web interface can be found at <http://ansible_nas_host_or_ip:8105>.

View file

@ -3,4 +3,4 @@ provisioner:
inventory: inventory:
group_vars: group_vars:
all: all:
trilium_enabled: true portainer_enabled: true

View file

@ -7,4 +7,4 @@
ansible.builtin.include_role: ansible.builtin.include_role:
name: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }}" name: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }}"
vars: vars:
trilium_enabled: false portainer_enabled: false

View file

@ -7,12 +7,12 @@
ansible.builtin.include_vars: ansible.builtin.include_vars:
file: ../../defaults/main.yml file: ../../defaults/main.yml
- name: Get trilium container state - name: Get portainer container state
community.docker.docker_container: community.docker.docker_container:
name: "{{ trilium_container_name }}" name: "{{ portainer_container_name }}"
register: result register: result
- name: Check if trilium containers are running - name: Check if portainer containers are running
ansible.builtin.assert: ansible.builtin.assert:
that: that:
- result.container['State']['Status'] == "running" - result.container['State']['Status'] == "running"

View file

@ -7,13 +7,13 @@
ansible.builtin.include_vars: ansible.builtin.include_vars:
file: ../../defaults/main.yml file: ../../defaults/main.yml
- name: Try and stop and remove trilium - name: Try and stop and remove portainer
community.docker.docker_container: community.docker.docker_container:
name: "{{ trilium_container_name }}" name: "{{ portainer_container_name }}"
state: absent state: absent
register: result register: result
- name: Check if trilium is stopped - name: Check if portainer is stopped
ansible.builtin.assert: ansible.builtin.assert:
that: that:
- not result.changed - not result.changed

View file

@ -1,28 +1,40 @@
--- ---
- name: Create Portainer Directories - name: Start Portainer
file: block:
path: "{{ item }}" - name: Create Portainer Directories
state: directory ansible.builtin.file:
with_items: path: "{{ item }}"
- "{{ portainer_data_directory }}" state: directory
with_items:
- "{{ portainer_data_directory }}"
- name: Portainer Docker Container - name: Portainer Docker Container
docker_container: community.docker.docker_container:
name: portainer container_default_behavior: no_defaults
image: portainer/portainer-ce name: "{{ portainer_container_name }}"
pull: true image: "{{ portainer_image_name }}:{{ portainer_image_version }}"
volumes: pull: true
- "{{ portainer_data_directory }}:/data:rw" volumes:
- "/var/run/docker.sock:/var/run/docker.sock:ro" - "{{ portainer_data_directory }}:/data:rw"
- "/etc/timezone:/etc/timezone:ro" - "/var/run/docker.sock:/var/run/docker.sock:ro"
ports: - "/etc/timezone:/etc/timezone:ro"
- "{{ portainer_port }}:9000" ports:
restart_policy: unless-stopped - "{{ portainer_port }}:9000"
memory: "{{ portainer_memory }}" restart_policy: unless-stopped
labels: memory: "{{ portainer_memory }}"
traefik.enable: "{{ portainer_available_externally | string }}" labels:
traefik.http.routers.portainer.rule: "Host(`{{ portainer_hostname }}.{{ ansible_nas_domain }}`)" traefik.enable: "{{ portainer_available_externally | string }}"
traefik.http.routers.portainer.tls.certresolver: "letsencrypt" traefik.http.routers.portainer.rule: "Host(`{{ portainer_hostname }}.{{ ansible_nas_domain }}`)"
traefik.http.routers.portainer.tls.domains[0].main: "{{ ansible_nas_domain }}" traefik.http.routers.portainer.tls.certresolver: "letsencrypt"
traefik.http.routers.portainer.tls.domains[0].sans: "*.{{ ansible_nas_domain }}" traefik.http.routers.portainer.tls.domains[0].main: "{{ ansible_nas_domain }}"
traefik.http.services.portainer.loadbalancer.server.port: "9000" traefik.http.routers.portainer.tls.domains[0].sans: "*.{{ ansible_nas_domain }}"
traefik.http.services.portainer.loadbalancer.server.port: "9000"
when: portainer_enabled is true
- name: Stop Portainer
block:
- name: Stop Portainer
community.docker.docker_container:
name: "{{ portainer_container_name }}"
state: absent
when: portainer_enabled is false