Skip to content

Commit

Permalink
✨ Add SiYuan (#117)
Browse files Browse the repository at this point in the history
  • Loading branch information
anarion80 authored Apr 27, 2024
1 parent 0f064c9 commit a4cc737
Show file tree
Hide file tree
Showing 11 changed files with 156 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ If you have a spare domain name you can configure applications to be accessible
* [Shaarli](https://github.com/shaarli/Shaarli) - Personal, minimalist, super-fast, database free, bookmarking service
* [Sickchill](https://sickchill.github.io/) - for managing TV episodes
* [Silverbullet](https://silverbullet.md) - Note-taking application optimized for people with a hacker mindset
* [SiYuan](https://github.com/siyuan-note/siyuan) - A privacy-first, self-hosted, fully open source personal knowledge management software
* [Snipe-IT](https://snipeitapp.com/) - A free open source IT asset/license management system
* [Sonarr](https://sonarr.tv/) - for downloading and managing TV episodes
* [Speedtest-Tracker](https://github.com/henrywhitaker3/Speedtest-Tracker) - Continuously track your internet speed
Expand Down
4 changes: 4 additions & 0 deletions nas.yml
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,10 @@
tags:
- silverbullet

- role: siyuan
tags:
- siyuan

- role: snipeit
tags:
- snipeit
Expand Down
23 changes: 23 additions & 0 deletions roles/siyuan/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
siyuan_enabled: false
siyuan_available_externally: false

# directories
siyuan_data_directory: "{{ docker_home }}/siyuan"

# network
siyuan_port: "8134"
siyuan_hostname: "siyuan"

# specs
siyuan_memory: 1g

# docker
siyuan_container_name: siyuan
siyuan_image_name: "b3log/siyuan"
siyuan_image_version: latest
siyuan_user_id: "1000"
siyuan_group_id: "1000"

# siyuan
siyuan_access_auth_code: "change_me"
11 changes: 11 additions & 0 deletions roles/siyuan/docs/siyuan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Siyuan

Homepage: [https://github.com/siyuan-note/siyuan](https://github.com/siyuan-note/siyuan)

SiYuan is a privacy-first personal knowledge management system, support fine-grained block-level reference and Markdown WYSIWYG.

## Usage

Set `siyuan_enabled: true` in your `inventories/<your_inventory>/group_vars/nas.yml` file.

Siyuan web interface can be found at [http://ansible_nas_host_or_ip:8134](http://ansible_nas_host_or_ip:8134).
6 changes: 6 additions & 0 deletions roles/siyuan/molecule/default/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
provisioner:
inventory:
group_vars:
all:
siyuan_enabled: true
10 changes: 10 additions & 0 deletions roles/siyuan/molecule/default/side_effect.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
- name: Stop
hosts: all
become: true
tasks:
- name: "Include {{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }} role"
ansible.builtin.include_role:
name: "{{ lookup('env', 'MOLECULE_PROJECT_DIRECTORY') | basename }}"
vars:
siyuan_enabled: false
19 changes: 19 additions & 0 deletions roles/siyuan/molecule/default/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
- name: Verify
hosts: all
gather_facts: false
tasks:
- name: Include vars
ansible.builtin.include_vars:
file: ../../defaults/main.yml

- name: Get siyuan container state
community.docker.docker_container:
name: "{{ siyuan_container_name }}"
register: result

- name: Check if siyuan containers are running
ansible.builtin.assert:
that:
- result.container['State']['Status'] == "running"
- result.container['State']['Restarting'] == false
19 changes: 19 additions & 0 deletions roles/siyuan/molecule/default/verify_stopped.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
- name: Verify
hosts: all
gather_facts: false
tasks:
- name: Include vars
ansible.builtin.include_vars:
file: ../../defaults/main.yml

- name: Try and stop and remove siyuan
community.docker.docker_container:
name: "{{ siyuan_container_name }}"
state: absent
register: result

- name: Check if siyuan is stopped
ansible.builtin.assert:
that:
- not result.changed
1 change: 1 addition & 0 deletions roles/siyuan/requirements.yml
48 changes: 48 additions & 0 deletions roles/siyuan/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
- name: Start Siyuan
block:
- name: Create Siyuan Directories
ansible.builtin.file:
path: "{{ item }}"
state: directory
owner: "{{ siyuan_user_id }}"
group: "{{ siyuan_group_id }}"
with_items:
- "{{ siyuan_data_directory }}"
- "{{ siyuan_data_directory }}/workspace"

- name: Create Siyuan Docker Container
community.docker.docker_container:
container_default_behavior: no_defaults
name: "{{ siyuan_container_name }}"
image: "{{ siyuan_image_name }}:{{ siyuan_image_version }}"
pull: true
command: ['--workspace=/siyuan/workspace/', '--accessAuthCode={{ siyuan_access_auth_code }}']
user: "{{ siyuan_user_id | quote }}:{{ siyuan_group_id | quote }}"
volumes:
- "{{ siyuan_data_directory }}/workspace:/siyuan/workspace/"
ports:
- "{{ siyuan_port }}:6806"
env:
TZ: "{{ ansible_nas_timezone }}"
PUID: "{{ siyuan_user_id | quote }}"
PGID: "{{ siyuan_group_id | quote }}"
DOCKER_ENABLE_SECURITY: "false"
restart_policy: unless-stopped
memory: "{{ siyuan_memory }}"
labels:
traefik.enable: "{{ siyuan_available_externally | string }}"
traefik.http.routers.siyuan.rule: "Host(`{{ siyuan_hostname }}.{{ ansible_nas_domain }}`)"
traefik.http.routers.siyuan.tls.certresolver: "letsencrypt"
traefik.http.routers.siyuan.tls.domains[0].main: "{{ ansible_nas_domain }}"
traefik.http.routers.siyuan.tls.domains[0].sans: "*.{{ ansible_nas_domain }}"
traefik.http.services.siyuan.loadbalancer.server.port: "6806"
when: siyuan_enabled is true

- name: Stop Siyuan
block:
- name: Stop Stirling-PDF
community.docker.docker_container:
name: "{{ siyuan_container_name }}"
state: absent
when: siyuan_enabled is false
14 changes: 14 additions & 0 deletions website/docs/applications/content-management/siyuan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
title: "Siyuan"
description: "A privacy-first, self-hosted, fully open source personal knowledge management software"
---

Homepage: [https://github.com/siyuan-note/siyuan](https://github.com/siyuan-note/siyuan)

SiYuan is a privacy-first personal knowledge management system, support fine-grained block-level reference and Markdown WYSIWYG.

## Usage

Set `siyuan_enabled: true` in your `inventories/<your_inventory>/group_vars/nas.yml` file.

Siyuan web interface can be found at [http://ansible_nas_host_or_ip:8134](http://ansible_nas_host_or_ip:8134).

0 comments on commit a4cc737

Please sign in to comment.