add wikijs

This commit is contained in:
Ludovic Cartier 2024-04-25 14:34:20 +02:00
parent deca41d2f6
commit 71f58c376b
5 changed files with 128 additions and 2 deletions

View File

@ -22,6 +22,7 @@ Available services
- Redisinsight
- Gitlab
- [Wireguard](https://github.com/wg-easy/wg-easy)
- wikiJS
Role variables
---------------
@ -59,6 +60,7 @@ Example variables
- redisinsight
- gitlab
- wireguard
- wikijs
watchtower_label_enable: true
@ -72,8 +74,7 @@ Example variables
redisinsight_domain: 'redisinsight.example.com'
redisinsight_whitelist:
- 192.168.1.0/24
- 31.15.24.XX
- 37.58.179.XX
- 10.0.1.0/24
redisinsignt_watchtower_enable: true
gitlab_version: 'latest'
@ -86,6 +87,15 @@ Example variables
# wg-easy webui access:
wireguard_domain: 'wg.example.com'
wireguard_password: 'please-vault-this-too'
wikijs_domain: 'wikijs.example.com'
wikijs_whitelist:
- 192.168.1.0/24
- 10.0.1.0/24
wikijs_db_root_password: 'vault-this-thingy'
wikijs_db_name: db_example
wikijs_db_user: db_user
wikijs_db_password: 'please-vault-this-too'
```
TODO

View File

@ -61,3 +61,10 @@
state: restarted
ignore_errors: '{{ ansible_check_mode }}'
tags: ['docker_wireguard']
- name: wikijs-restart
systemd:
name: docker-compose@wikijs
state: restarted
ignore_errors: '{{ ansible_check_mode }}'
tags: ['docker_wikijs']

39
tasks/wikijs.yml Normal file
View File

@ -0,0 +1,39 @@
---
- name: wikijs | check vars are defined
assert:
that:
- wikijs_domain is defined
- wikijs_db_root_password is defined
- wikijs_db_name is defined
- wikijs_db_user is defined
- wikijs_db_password is defined
tags: ['docker_wikijs']
- include_tasks: base.yml
tags: ['docker_wikijs']
- name: wikijs | copy env file
template:
src: env/wikijs.yml.j2
dest: /opt/docker-compose/wikijs/.env
owner: root
group: root
mode: 0644
notify: wikijs-restart
tags: [ 'docker_wikijs' ]
- name: wikijs | create docker network
docker_network:
name: 'wikijs'
tags:
- wikijs
tags: ['docker_wikijs']
- name: wikijs | create docker volumes
docker_volume:
name: "{{ item }}"
with_items:
- wikijs__config
- wikijs__data
- wikijs_db__var_lib_mysql
tags: ['docker_wikijs']

View File

@ -0,0 +1,64 @@
networks:
traefik:
external: true
wikijs:
external: true
volumes:
wikijs__config:
external: true
wikijs__data:
external: true
wikijs_db__var_lib_mysql:
external: true
services:
wikijs_db:
image: mariadb:latest
container_name: wikijs_db
restart: always
networks:
- wikijs
command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
volumes:
- wikijs_db__var_lib_mysql:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=$DB_ROOT_PASSWORD
- MYSQL_DATABASE=$DB_NAME
- MYSQL_USER=$DB_USER
- MYSQL_PASSWORD=$DB_PASSWORD
labels:
com.centurylinklabs.watchtower.enable: true
wikijs:
image: lscr.io/linuxserver/wikijs:latest
container_name: wikijs
restart: unless-stopped
depends_on:
- wikijs_db
environment:
- PUID=1000
- PGID=1000
- TZ=Europe/Paris
- DB_TYPE=mysql
- DB_HOST=$DB_HOST
- DB_PORT=$DB_PORT
- DB_NAME=$DB_NAME
- DB_USER=$DB_USER
- DB_PASS=$DB_PASSWORD
volumes:
- wikijs__config:/config
- wikijs__data:/data
ports:
- 3001:3000
networks:
- wikijs
- traefik
labels:
traefik.enable: true
traefik.docker.network: traefik
traefik.http.routers.wikijs.rule: "Host(`{{ wikijs_domain }}`){% if wikijs_whitelist is defined %} && ClientIP({% for ip in wikijs_whitelist %}`{{ ip }}`,{% endfor %}){% endif %}"
traefik.http.routers.wikijs.tls: true
traefik.http.routers.wikijs.tls.certresolver: letsencrypt
traefik.http.routers.wikijs.entrypoints: "websecure"
com.centurylinklabs.watchtower.enable: true

6
templates/env/wikijs.env.j2 vendored Normal file
View File

@ -0,0 +1,6 @@
DB_ROOT_PASSWORD="{{ wikijs_db_root_password }}"
DB_HOST=wikijs_db
DB_PORT=3306
DB_NAME="{{ wikijs_db_name }}"
DB_USER="{{ wikijs_db_user }}"
DB_PASSWORD="{{ wikijs_db_password }}"