diff --git a/README.md b/README.md index 5a49ef6..4da8829 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/handlers/main.yml b/handlers/main.yml index 867a26f..c5571b1 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -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'] diff --git a/tasks/wikijs.yml b/tasks/wikijs.yml new file mode 100644 index 0000000..efbea4c --- /dev/null +++ b/tasks/wikijs.yml @@ -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'] diff --git a/templates/compose/wikijs.yml.j2 b/templates/compose/wikijs.yml.j2 new file mode 100644 index 0000000..1c95161 --- /dev/null +++ b/templates/compose/wikijs.yml.j2 @@ -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 diff --git a/templates/env/wikijs.env.j2 b/templates/env/wikijs.env.j2 new file mode 100644 index 0000000..edea50e --- /dev/null +++ b/templates/env/wikijs.env.j2 @@ -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 }}"