v0.0.1
This commit is contained in:
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
# Generated by MacOS
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
# Generated by Windows
|
||||||
|
Thumbs.db
|
||||||
27
defaults/main.yml
Normal file
27
defaults/main.yml
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
---
|
||||||
|
# defaults file for lsa.wikijs
|
||||||
|
|
||||||
|
wikijs: true
|
||||||
|
|
||||||
|
wikijs_docker_deploy: true
|
||||||
|
wikijs_docker_compose: true
|
||||||
|
|
||||||
|
wikijs_docker_image_default: "ghcr.io/requarks/wiki:latest"
|
||||||
|
wikijs_docker_path_default: "/srv/wikijs"
|
||||||
|
|
||||||
|
wikijs_path_default: "/srv/wikijs"
|
||||||
|
|
||||||
|
# Docker database settings
|
||||||
|
wikijs_docker_db_enabled: false
|
||||||
|
wikijs_docker_db_type: "postgres" # Options: "postgres" or "mariadb"
|
||||||
|
wikijs_docker_db_name: "wikijs-db"
|
||||||
|
wikijs_docker_db_user: "wikijs"
|
||||||
|
wikijs_docker_db_pwd: "wikijs_password"
|
||||||
|
wikijs_docker_db_name_default: "wikijs"
|
||||||
|
wikijs_docker_db_root_pwd: "root_password"
|
||||||
|
wikijs_docker_db_path: "/srv/wikijs/db/data"
|
||||||
|
|
||||||
|
# Native installation settings
|
||||||
|
wikijs_node_path: "/usr/bin/node"
|
||||||
|
wikijs_nvm_path: "/root/.nvm/versions/node/"
|
||||||
|
wikijs_nvm_ver: "22.11.0"
|
||||||
8
handlers/main.yml
Normal file
8
handlers/main.yml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
# handlers file for lsa.wikijs
|
||||||
|
|
||||||
|
- name: restart wikijs
|
||||||
|
systemd:
|
||||||
|
name: "wikijs-{{ item.name | default('default') }}"
|
||||||
|
state: restarted
|
||||||
|
with_items: "{{ wikijs_sites }}"
|
||||||
9
meta/main.yml
Normal file
9
meta/main.yml
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
galaxy_info:
|
||||||
|
author: Michael Hettwer
|
||||||
|
namespace: lsa
|
||||||
|
description: wikijs
|
||||||
|
company: linux-server-admin.com s.r.o
|
||||||
|
license: license (MIT, BSD)
|
||||||
|
min_ansible_version: 2.1
|
||||||
|
galaxy_tags: []
|
||||||
|
dependencies: []
|
||||||
24
tasks/docker.yml
Normal file
24
tasks/docker.yml
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
---
|
||||||
|
# Install & Configure WikiJs for Docker
|
||||||
|
|
||||||
|
- name: Create wikijs directory
|
||||||
|
file:
|
||||||
|
path: "{{ item.path | default (wikijs_docker_path_default) }}"
|
||||||
|
state: directory
|
||||||
|
with_items: "{{ wikijs_docker }}"
|
||||||
|
|
||||||
|
- name: Generate wikijs docker-compose template
|
||||||
|
template:
|
||||||
|
src: "{{ item.compose_template | default ('docker-compose.yml.j2') }}"
|
||||||
|
dest: "{{ item.path | default (wikijs_docker_path_default) }}/docker-compose.yml"
|
||||||
|
when: wikijs_docker_compose
|
||||||
|
with_items: "{{ wikijs_docker }}"
|
||||||
|
|
||||||
|
- name: deploy wikijs
|
||||||
|
community.docker.docker_compose:
|
||||||
|
project_src: "{{ item.path | default (wikijs_docker_path_default) }}"
|
||||||
|
files:
|
||||||
|
- docker-compose.yml
|
||||||
|
build: true
|
||||||
|
when: wikijs_docker_deploy
|
||||||
|
with_items: "{{ wikijs_docker }}"
|
||||||
14
tasks/main.yml
Normal file
14
tasks/main.yml
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
---
|
||||||
|
# tasks file for lsa.wikijs
|
||||||
|
|
||||||
|
- name: "Install & Configure WikiJs for Docker"
|
||||||
|
include_tasks: "docker.yml"
|
||||||
|
when:
|
||||||
|
- wikijs
|
||||||
|
- wikijs_docker is defined
|
||||||
|
|
||||||
|
- name: "Install & Configure WikiJs"
|
||||||
|
include_tasks: "native.yml"
|
||||||
|
when:
|
||||||
|
- wikijs
|
||||||
|
- wikijs_sites is defined
|
||||||
42
tasks/native.yml
Normal file
42
tasks/native.yml
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
---
|
||||||
|
# Install & Configure WikiJs Native
|
||||||
|
|
||||||
|
- name: Create wikijs directory
|
||||||
|
file:
|
||||||
|
path: "{{ item.path | default(wikijs_path_default) }}"
|
||||||
|
state: directory
|
||||||
|
with_items: "{{ wikijs_sites }}"
|
||||||
|
|
||||||
|
- name: Download Wiki.js release
|
||||||
|
get_url:
|
||||||
|
url: "https://github.com/Requarks/wiki/releases/latest/download/wiki-js.tar.gz"
|
||||||
|
dest: "/tmp/wiki-js.tar.gz"
|
||||||
|
mode: "0644"
|
||||||
|
|
||||||
|
- name: Extract Wiki.js release
|
||||||
|
unarchive:
|
||||||
|
src: "/tmp/wiki-js.tar.gz"
|
||||||
|
dest: "{{ item.path | default(wikijs_path_default) }}"
|
||||||
|
remote_src: yes
|
||||||
|
with_items: "{{ wikijs_sites }}"
|
||||||
|
|
||||||
|
- name: Template config.yml
|
||||||
|
template:
|
||||||
|
src: "config.yml.j2"
|
||||||
|
dest: "{{ item.path | default(wikijs_path_default) }}/config.yml"
|
||||||
|
with_items: "{{ wikijs_sites }}"
|
||||||
|
notify: restart wikijs
|
||||||
|
|
||||||
|
- name: Template systemd service
|
||||||
|
template:
|
||||||
|
src: "systemd.j2"
|
||||||
|
dest: "/etc/systemd/system/wikijs-{{ item.name | default('default') }}.service"
|
||||||
|
with_items: "{{ wikijs_sites }}"
|
||||||
|
|
||||||
|
- name: Enable and start Wiki.js service
|
||||||
|
systemd:
|
||||||
|
name: "wikijs-{{ item.name | default('default') }}"
|
||||||
|
enabled: yes
|
||||||
|
state: started
|
||||||
|
daemon_reload: yes
|
||||||
|
with_items: "{{ wikijs_sites }}"
|
||||||
147
templates/config.yml.j2
Normal file
147
templates/config.yml.j2
Normal file
@@ -0,0 +1,147 @@
|
|||||||
|
#######################################################################
|
||||||
|
# Wiki.js - CONFIGURATION Template #
|
||||||
|
#######################################################################
|
||||||
|
# Full documentation + examples:
|
||||||
|
# https://docs.requarks.io/install
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------
|
||||||
|
# Port the server should listen to
|
||||||
|
# ---------------------------------------------------------------------
|
||||||
|
|
||||||
|
port: {{ item.port | default("3000") }}
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------
|
||||||
|
# Database
|
||||||
|
# ---------------------------------------------------------------------
|
||||||
|
# Supported Database Engines:
|
||||||
|
# - postgres = PostgreSQL 9.5 or later
|
||||||
|
# - mysql = MySQL 8.0 or later (5.7.8 partially supported, refer to docs)
|
||||||
|
# - mariadb = MariaDB 10.2.7 or later
|
||||||
|
# - mssql = MS SQL Server 2012 or later
|
||||||
|
# - sqlite = SQLite 3.9 or later
|
||||||
|
|
||||||
|
db:
|
||||||
|
type: {{ item.db.type | default("postgres") }}
|
||||||
|
|
||||||
|
# PostgreSQL / MySQL / MariaDB / MS SQL Server only:
|
||||||
|
host: {{ item.db.host | default("localhost") }}
|
||||||
|
port: {{ item.db.port | default("5432") }}
|
||||||
|
user: {{ item.db.user | default("wikijs") }}
|
||||||
|
pass: {{ item.db.pwd | default("wikijs") }}
|
||||||
|
db: {{ item.db.name | default("wikijs") }}
|
||||||
|
ssl: {{ item.db.ssl | default("false") }}
|
||||||
|
|
||||||
|
# Optional - PostgreSQL / MySQL / MariaDB only:
|
||||||
|
# -> Uncomment lines you need below and set `auto` to false
|
||||||
|
# -> Full list of accepted options: https://nodejs.org/api/tls.html#tls_tls_createsecurecontext_options
|
||||||
|
sslOptions:
|
||||||
|
auto: true
|
||||||
|
# rejectUnauthorized: false
|
||||||
|
# ca: path/to/ca.crt
|
||||||
|
# cert: path/to/cert.crt
|
||||||
|
# key: path/to/key.pem
|
||||||
|
# pfx: path/to/cert.pfx
|
||||||
|
# passphrase: xyz123
|
||||||
|
|
||||||
|
# Optional - PostgreSQL only:
|
||||||
|
#schema: public
|
||||||
|
|
||||||
|
# SQLite only:
|
||||||
|
#storage: path/to/database.sqlite
|
||||||
|
|
||||||
|
#######################################################################
|
||||||
|
# ADVANCED OPTIONS #
|
||||||
|
#######################################################################
|
||||||
|
# Do not change unless you know what you are doing!
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------
|
||||||
|
# SSL/TLS Settings
|
||||||
|
# ---------------------------------------------------------------------
|
||||||
|
# Consider using a reverse proxy (e.g. nginx) if you require more
|
||||||
|
# advanced options than those provided below.
|
||||||
|
|
||||||
|
ssl:
|
||||||
|
enabled: false
|
||||||
|
port: 3443
|
||||||
|
|
||||||
|
# Provider to use, possible values: custom, letsencrypt
|
||||||
|
provider: custom
|
||||||
|
|
||||||
|
# ++++++ For custom only ++++++
|
||||||
|
# Certificate format, either 'pem' or 'pfx':
|
||||||
|
format: pem
|
||||||
|
# Using PEM format:
|
||||||
|
key: path/to/key.pem
|
||||||
|
cert: path/to/cert.pem
|
||||||
|
# Using PFX format:
|
||||||
|
pfx: path/to/cert.pfx
|
||||||
|
# Passphrase when using encrypted PEM / PFX keys (default: null):
|
||||||
|
passphrase: null
|
||||||
|
# Diffie Hellman parameters, with key length being greater or equal
|
||||||
|
# to 1024 bits (default: null):
|
||||||
|
dhparam: null
|
||||||
|
|
||||||
|
# ++++++ For letsencrypt only ++++++
|
||||||
|
domain: wiki.yourdomain.com
|
||||||
|
subscriberEmail: admin@example.com
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------
|
||||||
|
# Database Pool Options
|
||||||
|
# ---------------------------------------------------------------------
|
||||||
|
# Refer to https://github.com/vincit/tarn.js for all possible options
|
||||||
|
|
||||||
|
pool:
|
||||||
|
# min: 2
|
||||||
|
# max: 10
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------
|
||||||
|
# IP address the server should listen to
|
||||||
|
# ---------------------------------------------------------------------
|
||||||
|
# Leave 0.0.0.0 for all interfaces
|
||||||
|
|
||||||
|
bindIP: 0.0.0.0
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------
|
||||||
|
# Log Level
|
||||||
|
# ---------------------------------------------------------------------
|
||||||
|
# Possible values: error, warn, info (default), verbose, debug, silly
|
||||||
|
|
||||||
|
logLevel: {{ item.log.level | default("info") }}
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------
|
||||||
|
# Log Format
|
||||||
|
# ---------------------------------------------------------------------
|
||||||
|
# Output format for logging, possible values: default, json
|
||||||
|
|
||||||
|
logFormat: {{ item.log.format | default("default") }}
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------
|
||||||
|
# Offline Mode
|
||||||
|
# ---------------------------------------------------------------------
|
||||||
|
# If your server cannot access the internet. Set to true and manually
|
||||||
|
# download the offline files for sideloading.
|
||||||
|
|
||||||
|
offline: {{ item.offline | default("false") }}
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------
|
||||||
|
# High-Availability
|
||||||
|
# ---------------------------------------------------------------------
|
||||||
|
# Set to true if you have multiple concurrent instances running off the
|
||||||
|
# same DB (e.g. Kubernetes pods / load balanced instances). Leave false
|
||||||
|
# otherwise. You MUST be using PostgreSQL to use this feature.
|
||||||
|
|
||||||
|
ha: {{ item.ha | default("false") }}
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------
|
||||||
|
# Data Path
|
||||||
|
# ---------------------------------------------------------------------
|
||||||
|
# Writeable data path used for cache and temporary user uploads.
|
||||||
|
dataPath: {{ item.datapath | default("./data") }}
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------
|
||||||
|
# Body Parser Limit
|
||||||
|
# ---------------------------------------------------------------------
|
||||||
|
# Maximum size of API requests body that can be parsed. Does not affect
|
||||||
|
# file uploads.
|
||||||
|
|
||||||
|
bodyParserLimit: {{ item.bodyparserlimit | default("5mb") }}
|
||||||
65
templates/docker-compose.yml.j2
Normal file
65
templates/docker-compose.yml.j2
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
#jinja2: lstrip_blocks: "True", trim_blocks: "True"
|
||||||
|
#
|
||||||
|
# WikiJs
|
||||||
|
# docker-compose managed by ansible
|
||||||
|
version: "3.8"
|
||||||
|
services:
|
||||||
|
{% for item in wikijs_docker %}
|
||||||
|
{{ item.name }}:
|
||||||
|
image: {{ item.image | default (wikijs_docker_image_default) }}
|
||||||
|
container_name: {{ item.name }}
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
environment:
|
||||||
|
DB_TYPE: {{ item.db.type | default("postgres") }}
|
||||||
|
DB_HOST: "{{ item.db.host | default('localhost') }}"
|
||||||
|
DB_PORT: "{{ item.db.port | default ('5432') }}"
|
||||||
|
DB_USER: "{{ item.db.user | default ('wikijs') }}"
|
||||||
|
DB_PASS: "{{ item.db.pwd | default ('wikijs') }}"
|
||||||
|
DB_NAME: "{{ item.db.name | default ('wikijs') }}"
|
||||||
|
{% if wikijs_docker_db_enabled | default(false) %}
|
||||||
|
DB_HOST: db
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
ports:
|
||||||
|
{% if item.ports is defined %}
|
||||||
|
{% for port in item.ports %}
|
||||||
|
- "{{ item.port }}"
|
||||||
|
{% endfor %}
|
||||||
|
{% else %}
|
||||||
|
- "3050:3000"
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if wikijs_docker_db_enabled | default(false) %}
|
||||||
|
depends_on:
|
||||||
|
- db
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
{% if wikijs_docker_db_enabled | default(false) %}
|
||||||
|
{% if wikijs_docker_db_type | default("postgres") == "postgres" %}
|
||||||
|
db:
|
||||||
|
image: postgres:15-alpine
|
||||||
|
container_name: {{ wikijs_docker_db_name | default("wikijs-db") }}
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
POSTGRES_USER: {{ wikijs_docker_db_user | default("wikijs") }}
|
||||||
|
POSTGRES_PASSWORD: {{ wikijs_docker_db_pwd | default("wikijs_password") }}
|
||||||
|
POSTGRES_DB: {{ wikijs_docker_db_name_default | default("wikijs") }}
|
||||||
|
volumes:
|
||||||
|
- {{ wikijs_docker_db_path | default("/srv/wikijs/db/data") }}:/var/lib/postgresql/data
|
||||||
|
{% elif wikijs_docker_db_type | default("postgres") == "mariadb" %}
|
||||||
|
db:
|
||||||
|
image: mariadb:10.11
|
||||||
|
container_name: {{ wikijs_docker_db_name | default("wikijs-db") }}
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
MARIADB_USER: {{ wikijs_docker_db_user | default("wikijs") }}
|
||||||
|
MARIADB_PASSWORD: {{ wikijs_docker_db_pwd | default("wikijs_password") }}
|
||||||
|
MARIADB_DATABASE: {{ wikijs_docker_db_name_default | default("wikijs") }}
|
||||||
|
MARIADB_ROOT_PASSWORD: {{ wikijs_docker_db_root_pwd | default("root_password") }}
|
||||||
|
volumes:
|
||||||
|
- {{ wikijs_docker_db_path | default("/srv/wikijs/db/data") }}:/var/lib/mysql
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
16
templates/systemd.j2
Normal file
16
templates/systemd.j2
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Wiki.js {{ item.name }}
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
ExecStart={{ wikijs_nvm_path }}v{{ wikijs_nvm_ver }}/bin/node server
|
||||||
|
Restart=always
|
||||||
|
# Consider creating a dedicated user for Wiki.js here:
|
||||||
|
#User=wikijs
|
||||||
|
Environment=NODE_ENV=production
|
||||||
|
WorkingDirectory={{ item.path | default(wikijs_path_default) }}
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
|
||||||
2
tests/inventory
Normal file
2
tests/inventory
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
localhost
|
||||||
|
|
||||||
5
tests/test.yml
Normal file
5
tests/test.yml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
- hosts: localhost
|
||||||
|
remote_user: root
|
||||||
|
roles:
|
||||||
|
- lsa.wikijs
|
||||||
2
vars/main.yml
Normal file
2
vars/main.yml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
---
|
||||||
|
# vars file for lsa.wikijs
|
||||||
Reference in New Issue
Block a user