Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 621d5310a3 | |||
| 6377a56d95 | |||
| dbd72f43a4 | |||
| 9f236b6fa5 | |||
| b4a0874deb | |||
| c51216ff9b | |||
| 7debdfcb93 | |||
| da016343c0 | |||
| bf749ebbde | |||
| 41d509a49d | |||
| f062f6862f | |||
| 2dfc0f734e | |||
| f9211dfa24 | |||
| 8713631e0b | |||
| 01ad4350b0 | |||
| 8a4ce488f1 | |||
| 664cf2956d |
@@ -140,6 +140,14 @@ services:
|
||||
subuid: "100999"
|
||||
manticore:
|
||||
subuid: "100998"
|
||||
affine:
|
||||
domain:
|
||||
public: "affine"
|
||||
internal: "affine.app"
|
||||
ports:
|
||||
http: "3010"
|
||||
redis: "6381"
|
||||
manticore: "9308"
|
||||
|
||||
version:
|
||||
packages:
|
||||
@@ -169,9 +177,10 @@ version:
|
||||
vaultwarden: "1.35.4"
|
||||
gitea: "1.25.5"
|
||||
redis: "8.6.1"
|
||||
immich: "v2.6.3"
|
||||
immich: "v2.7.5"
|
||||
actualbudget: "26.3.0"
|
||||
paperless: "2.20.13"
|
||||
vikunja: "2.2.2"
|
||||
opencloud: "4.0.4"
|
||||
manticore: "25.0.0"
|
||||
affine: "0.26.3"
|
||||
|
||||
@@ -21,5 +21,6 @@ node:
|
||||
config_path: "{{ node.homelab_path }}/config"
|
||||
ssh_san: "console,console.ilnmors.internal"
|
||||
ssh_users: "vmm,fw,infra,auth,app"
|
||||
local_san: "localhost console.ilnmors.internal"
|
||||
# add the hostname of wsl, it is needed to improve the sudo problem
|
||||
local_san: "localhost console.ilnmors.internal surface"
|
||||
# ansible_python_interpreter: "{{ ansible_playbook_python }}"
|
||||
|
||||
@@ -217,6 +217,15 @@
|
||||
tags: ["site", "opencloud"]
|
||||
tags: ["site", "opencloud"]
|
||||
|
||||
- name: Set affine
|
||||
ansible.builtin.include_role:
|
||||
name: "app"
|
||||
tasks_from: "services/set_affine"
|
||||
apply:
|
||||
tags: ["site", "affine"]
|
||||
tags: ["site", "affine"]
|
||||
|
||||
|
||||
- name: Flush handlers right now
|
||||
ansible.builtin.meta: "flush_handlers"
|
||||
|
||||
|
||||
@@ -115,18 +115,10 @@
|
||||
become: true
|
||||
tags: ["init", "site", "install-packages"]
|
||||
|
||||
- name: Install CLI tools
|
||||
- name: Set CLI tools
|
||||
ansible.builtin.include_role:
|
||||
name: "console"
|
||||
tasks_from: "services/set_cli_tools"
|
||||
apply:
|
||||
tags: ["init", "site", "tools"]
|
||||
tags: ["init", "site", "tools"]
|
||||
|
||||
- name: Install chromium with font
|
||||
ansible.builtin.include_role:
|
||||
name: "console"
|
||||
tasks_from: "services/set_chromium"
|
||||
apply:
|
||||
tags: ["init", "site", "chromium"]
|
||||
tags: ["init", "site", "chromium"]
|
||||
|
||||
@@ -83,7 +83,19 @@
|
||||
enabled: true
|
||||
daemon_reload: true
|
||||
scope: "user"
|
||||
when: not (is_opencloud_init_run | default(false))
|
||||
when: is_opencloud_init.stat.exists
|
||||
changed_when: false
|
||||
listen: "notification_restart_opencloud"
|
||||
ignore_errors: true # noqa: ignore-errors
|
||||
|
||||
- name: Restart affine
|
||||
ansible.builtin.systemd:
|
||||
name: "affine.service"
|
||||
state: "restarted"
|
||||
enabled: true
|
||||
daemon_reload: true
|
||||
scope: "user"
|
||||
when: is_affine_init.stat.exists
|
||||
changed_when: false
|
||||
listen: "notification_restart_affine"
|
||||
ignore_errors: true # noqa: ignore-errors
|
||||
|
||||
163
ansible/roles/app/tasks/services/set_affine.yaml
Normal file
163
ansible/roles/app/tasks/services/set_affine.yaml
Normal file
@@ -0,0 +1,163 @@
|
||||
---
|
||||
- name: Set manticore service name
|
||||
ansible.builtin.set_fact:
|
||||
manticore_service: "affine"
|
||||
|
||||
- name: Create manticore directory
|
||||
ansible.builtin.file:
|
||||
path: "{{ node['home_path'] }}/{{ item }}"
|
||||
state: "directory"
|
||||
owner: "{{ services['manticore']['subuid'] }}"
|
||||
group: "svadmins"
|
||||
mode: "0770"
|
||||
loop:
|
||||
- "data/containers/manticore"
|
||||
- "data/containers/manticore/{{ manticore_service }}"
|
||||
become: true
|
||||
|
||||
- name: Deploy manticore.container file
|
||||
ansible.builtin.template:
|
||||
src: "{{ hostvars['console']['node']['config_path'] }}/services/containers/app/manticore/manticore.container.j2"
|
||||
dest: "{{ node['home_path'] }}/.config/containers/systemd/manticore_{{ manticore_service }}.container"
|
||||
owner: "{{ ansible_user }}"
|
||||
group: "svadmins"
|
||||
mode: "0644"
|
||||
register: "is_manticore_containerfile"
|
||||
|
||||
- name: Enable (Restart) manticore.service
|
||||
ansible.builtin.systemd:
|
||||
name: "manticore_{{ manticore_service }}.service"
|
||||
state: "restarted"
|
||||
enabled: true
|
||||
daemon_reload: true
|
||||
scope: "user"
|
||||
when: is_manticore_containerfile.changed # noqa: no-handler
|
||||
|
||||
- name: Set redis service name
|
||||
ansible.builtin.set_fact:
|
||||
redis_service: "affine"
|
||||
|
||||
- name: Create redis_affine directory
|
||||
ansible.builtin.file:
|
||||
path: "{{ node['home_path'] }}/{{ item }}"
|
||||
state: "directory"
|
||||
owner: "{{ services['redis']['subuid'] }}"
|
||||
group: "svadmins"
|
||||
mode: "0770"
|
||||
loop:
|
||||
- "containers/redis"
|
||||
- "containers/redis/{{ redis_service }}"
|
||||
- "containers/redis/{{ redis_service }}/data"
|
||||
become: true
|
||||
|
||||
- name: Deploy redis config file
|
||||
ansible.builtin.template:
|
||||
src: "{{ hostvars['console']['node']['config_path'] }}/services/containers/app/redis/redis.conf.j2"
|
||||
dest: "{{ node['home_path'] }}/containers/redis/{{ redis_service }}/redis.conf"
|
||||
owner: "{{ ansible_user }}"
|
||||
group: "svadmins"
|
||||
mode: "0644"
|
||||
register: "is_redis_conf"
|
||||
|
||||
- name: Deploy redis container file
|
||||
ansible.builtin.template:
|
||||
src: "{{ hostvars['console']['node']['config_path'] }}/services/containers/app/redis/redis.container.j2"
|
||||
dest: "{{ node['home_path'] }}/.config/containers/systemd/redis_{{ redis_service }}.container"
|
||||
owner: "{{ ansible_user }}"
|
||||
group: "svadmins"
|
||||
mode: "0644"
|
||||
register: "is_redis_containerfile"
|
||||
|
||||
- name: Enable (Restart) redis service
|
||||
ansible.builtin.systemd:
|
||||
name: "redis_{{ redis_service }}.service"
|
||||
state: "restarted"
|
||||
enabled: true
|
||||
daemon_reload: true
|
||||
scope: "user"
|
||||
when: is_redis_conf.changed or is_redis_containerfile.changed # noqa: no-handler
|
||||
|
||||
- name: Create affine directory
|
||||
ansible.builtin.file:
|
||||
path: "{{ node['home_path'] }}/{{ item }}"
|
||||
state: "directory"
|
||||
owner: "{{ ansible_user }}"
|
||||
group: "svadmins"
|
||||
mode: "0770"
|
||||
loop:
|
||||
- "data/containers/affine"
|
||||
- "containers/affine"
|
||||
- "containers/affine/ssl"
|
||||
- "containers/affine/config"
|
||||
|
||||
- name: Deploy root certificate
|
||||
ansible.builtin.copy:
|
||||
content: |
|
||||
{{ hostvars['console']['ca']['root']['crt'] }}
|
||||
dest: "{{ node['home_path'] }}/containers/affine/ssl/{{ root_cert_filename }}"
|
||||
owner: "{{ ansible_user }}"
|
||||
group: "svadmins"
|
||||
mode: "0440"
|
||||
notify: "notification_restart_affine"
|
||||
no_log: true
|
||||
|
||||
- name: Register secret value to podman secret
|
||||
containers.podman.podman_secret:
|
||||
name: "{{ item.name }}"
|
||||
data: "{{ item.value }}"
|
||||
state: "present"
|
||||
force: true
|
||||
loop:
|
||||
- name: "AFFINE_PRIVATE_KEY"
|
||||
value: "{{ hostvars['console']['affine']['secret_key'] }}"
|
||||
- name: "AFFINE_DATABASE_URL"
|
||||
value: "postgresql://affine:{{ hostvars['console']['postgresql']['password']['affine'] | urlencode | replace('/', '%2F') }}\
|
||||
@{{ services['postgresql']['domain'] }}.{{ domain['internal'] }}/affine_db?sslmode=verify-full&\
|
||||
sslrootcert=/etc/ssl/affine/{{ root_cert_filename }}"
|
||||
notify: "notification_restart_affine"
|
||||
no_log: true
|
||||
|
||||
- name: Check data directory empty
|
||||
ansible.builtin.stat:
|
||||
path: "{{ node['home_path'] }}/data/containers/affine/.init"
|
||||
register: "is_affine_init"
|
||||
|
||||
- name: Initialize affine
|
||||
when: not is_affine_init.stat.exists
|
||||
block:
|
||||
- name: Execute init command (Including pulling image)
|
||||
containers.podman.podman_container:
|
||||
name: "affine_init"
|
||||
image: "ghcr.io/toeverything/affine:{{ version['containers']['affine'] }}"
|
||||
command: ['sh', '-c', 'node ./scripts/self-host-predeploy.js']
|
||||
state: "started"
|
||||
rm: true
|
||||
detach: false
|
||||
secrets:
|
||||
- "AFFINE_DATABASE_URL,type=env,target=DATABASE_URL"
|
||||
no_log: true
|
||||
|
||||
- name: Create .init file
|
||||
ansible.builtin.file:
|
||||
path: "{{ node['home_path'] }}/data/containers/affine/.init"
|
||||
state: "touch"
|
||||
mode: "0644"
|
||||
owner: "{{ ansible_user }}"
|
||||
group: "svadmins"
|
||||
|
||||
- name: Deploy affine.container file
|
||||
ansible.builtin.template:
|
||||
src: "{{ hostvars['console']['node']['config_path'] }}/services/containers/app/affine/affine.container.j2"
|
||||
dest: "{{ node['home_path'] }}/.config/containers/systemd/affine.container"
|
||||
owner: "{{ ansible_user }}"
|
||||
group: "svadmins"
|
||||
mode: "0644"
|
||||
notify: "notification_restart_affine"
|
||||
|
||||
- name: Enable affine.service
|
||||
ansible.builtin.systemd:
|
||||
name: "affine.service"
|
||||
state: "started"
|
||||
enabled: true
|
||||
daemon_reload: true
|
||||
scope: "user"
|
||||
@@ -12,15 +12,13 @@
|
||||
become: true
|
||||
|
||||
- name: Check data directory empty
|
||||
ansible.builtin.find:
|
||||
paths: "{{ node['home_path'] }}/data/containers/opencloud/"
|
||||
hidden: true
|
||||
file_type: "any"
|
||||
ansible.builtin.stat:
|
||||
path: "{{ node['home_path'] }}/data/containers/opencloud/.init"
|
||||
become: true
|
||||
register: "is_data_dir_empty"
|
||||
register: "is_opencloud_init"
|
||||
|
||||
- name: Initialize opencloud
|
||||
when: is_data_dir_empty.matched == 0
|
||||
when: not is_opencloud_init.stat.exists
|
||||
block:
|
||||
- name: Execute init command (Including pulling image)
|
||||
containers.podman.podman_container:
|
||||
@@ -39,9 +37,13 @@
|
||||
- "{{ node['home_path'] }}/data/containers/opencloud:/var/lib/opencloud:rw"
|
||||
no_log: true
|
||||
|
||||
- name: Set is_opencloud_init_run
|
||||
ansible.builtin.set_fact:
|
||||
is_opencloud_init_run: true
|
||||
- name: Create .init file
|
||||
ansible.builtin.file:
|
||||
path: "{{ node['home_path'] }}/data/containers/opencloud/.init"
|
||||
state: "touch"
|
||||
mode: "0644"
|
||||
owner: "{{ ansible_user }}"
|
||||
group: "svadmins"
|
||||
|
||||
- name: Deploy configuration files
|
||||
ansible.builtin.template:
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
state: "directory"
|
||||
mode: "0700"
|
||||
|
||||
- name: Create contaienr data directory for app
|
||||
- name: Create container data directory for app
|
||||
ansible.builtin.file:
|
||||
path: "{{ node['home_path'] }}/data/containers"
|
||||
owner: "{{ ansible_user }}"
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
- name: Reload postgresql
|
||||
ansible.builtin.command:
|
||||
/usr/bin/podman exec -u postgres postgresql sh -c "pg_ctl reload"
|
||||
when: not (is_postgresql_init_run | default(false))
|
||||
when: is_postgresql_init.stat.exists
|
||||
changed_when: false
|
||||
listen: "notification_reload_postgresql"
|
||||
ignore_errors: true # noqa: ignore-errors
|
||||
@@ -24,7 +24,7 @@
|
||||
enabled: true
|
||||
daemon_reload: true
|
||||
scope: "user"
|
||||
when: not (is_postgresql_init_run | default(false))
|
||||
when: is_postgresql_init.stat.exists
|
||||
changed_when: false
|
||||
listen: "notification_restart_postgresql"
|
||||
ignore_errors: true # noqa: ignore-errors
|
||||
|
||||
@@ -55,6 +55,8 @@
|
||||
no_log: true
|
||||
|
||||
- name: Initiate ldap (When = false, If DB data does not exist in postgresql, activate this block)
|
||||
# The reason why this task doesn't use the way to check ".init" file is this tasks can override original database.
|
||||
# Absent of ".init" file cannot guarantee DB is empty.
|
||||
when: false
|
||||
become: true
|
||||
block:
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
- "immich"
|
||||
- "paperless"
|
||||
- "vikunja"
|
||||
- "affine"
|
||||
|
||||
- name: Create postgresql directory
|
||||
ansible.builtin.file:
|
||||
@@ -87,15 +88,13 @@
|
||||
no_log: true
|
||||
|
||||
- name: Check data directory empty
|
||||
ansible.builtin.find:
|
||||
paths: "{{ node['home_path'] }}/containers/postgresql/data/"
|
||||
hidden: true
|
||||
file_type: "any"
|
||||
ansible.builtin.stat:
|
||||
path: "{{ node['home_path'] }}/containers/postgresql/data/.init"
|
||||
become: true
|
||||
register: "is_data_dir_empty"
|
||||
register: "is_postgresql_init"
|
||||
|
||||
- name: Prepare initiating DB
|
||||
when: is_data_dir_empty.matched == 0
|
||||
when: not is_postgresql_init.stat.exists
|
||||
become: true
|
||||
block:
|
||||
# `init/pg_cluster.sql` should be fetched from postgresql's backup directory before running initiating
|
||||
@@ -117,9 +116,14 @@
|
||||
loop: "{{ connected_services }}"
|
||||
loop_control:
|
||||
index_var: index_num
|
||||
- name: Set is_postgresql_init_run
|
||||
ansible.builtin.set_fact:
|
||||
is_postgresql_init_run: true
|
||||
|
||||
- name: Create .init file
|
||||
ansible.builtin.file:
|
||||
path: "{{ node['home_path'] }}/containers/postgresql/data/.init"
|
||||
state: "touch"
|
||||
mode: "0644"
|
||||
owner: "{{ ansible_user }}"
|
||||
group: "svadmins"
|
||||
|
||||
- name: Deploy container file
|
||||
ansible.builtin.template:
|
||||
|
||||
@@ -118,6 +118,7 @@ postgresql:
|
||||
immich: ENC[AES256_GCM,data:11jvxTKA/RL0DGL6y2/X092hnDohj6yTrYGK4IVojqBd1gCOBnDvUjgmx14=,iv:oBfHxsx9nxhyKY/WOuWfybxEX2bf+lHEtsaifFRS9lg=,tag:tAfkBdgQ8ZEkLIFcDICKDw==,type:str]
|
||||
paperless: ENC[AES256_GCM,data:6VBrBbjVoam7SkZCSvoBTdrfkUoDghdGTiBmFLul04X/okXOHeC5zusJffY=,iv:iZumcJ3TWwZD77FzYx8THwCqC+EbnXUBrEKuPh3zgV8=,tag:u2m8SppAdxZ/duNdpuS3oQ==,type:str]
|
||||
vikunja: ENC[AES256_GCM,data:/+wQdoFPTBG2elI9kZbAVWrHZ0DhMaYr4dc+2z9QNdb3TcDS2PEia0JuSAg=,iv:MViZTyUD8YqMmxSTWCQpJ30f/KQdQGOzPlRHHsQ8lAw=,tag:zov3POno139dkMxFDpj2gg==,type:str]
|
||||
affine: ENC[AES256_GCM,data:XPXrcszsV06YqCJZ7CDqc4rCwqqNlbtLCFYfLAQ8jamLtft8L2UVrMA4WZo=,iv:vrWdBeckxB9tmEE628j4jhU+hSpE6TXYMGt0hh1Cg84=,tag:hlWwWUGht8NqWTZREMsa1Q==,type:str]
|
||||
#ENC[AES256_GCM,data:ODXFUxxxdQ==,iv:s9zJVx6wo6x517tbNvC+FZ0dFzqbjqeLI6rXBq72hQA=,tag:bXoV2I3LbpmQyddJrtS3Qg==,type:comment]
|
||||
#
|
||||
#
|
||||
@@ -243,6 +244,17 @@ opencloud:
|
||||
#ENC[AES256_GCM,data:ODXFUxxxdQ==,iv:s9zJVx6wo6x517tbNvC+FZ0dFzqbjqeLI6rXBq72hQA=,tag:bXoV2I3LbpmQyddJrtS3Qg==,type:comment]
|
||||
#
|
||||
#
|
||||
#ENC[AES256_GCM,data:k55osvepVeB1RC5hZ4IF,iv:AlhfmWwn/DiSESWc+ULJSOLUhnrKAIfWr7MeiwV8qc8=,tag:hOgptwUcY6nVxPIhu+DYgw==,type:comment]
|
||||
affine:
|
||||
secret_key: ENC[AES256_GCM,data:LLX78DpYnha1JWhgw0sHLzIVq/oIzvT+nB7zgli4mroGbnt7WZaXCx34zKkYRwYj/+0L4IFFVdkzKtK5DO84SgFkS2Bk2iNdCMqIx80CpyiD8IWAcyRu5d6hh82PlgyxU80T/4nbLbIn0GLubPTTeUX8GC3VxRU=,iv:DnmvbhlygSHes0jAkIm4+WXMUQLzr4R4dNa33rO67v8=,tag:+2wlh+/ekiTyShWM4XBbUw==,type:str]
|
||||
il:
|
||||
password: ENC[AES256_GCM,data:4zxiQAzXTR+fraRjYT657BIwSqrih3lMPFFSibQdardRMjskAbuRYIQA6mo=,iv:ub3giRG9vCFSuwRXDazYTqWbjENzQUWR36290Kruj1o=,tag:C2Ixd2eTEgzBvUNCNBtJuA==,type:str]
|
||||
oidc:
|
||||
secret: ENC[AES256_GCM,data:eRDBrqLZR7MFLlsUwk7Wg7FzxDov7vJLIWQRuKq7vrXbPSJkMcy9jfG2rL4=,iv:UaSoi7gODXgjzihJIDVIdDHJcSAZNV8UKfGeM6YzxqI=,tag:cOUDblcMStP8E4fp+s1WRQ==,type:str]
|
||||
hash: ENC[AES256_GCM,data:jE1CvFo+mjb/Xc3Ft5ky7on03vcnv79cw/5g/xaldXsv94VRrIjmfGMgHAj07r8j5mDpP34A5bYO1PSe9DYrwRcsXa9OUQuzm/8avFy9wVZDhBUUAGR+jiW1BP9hc6nmSpPVPtle+3sbqOB0ZMjXWwlcAcuknOtuhH1mzwmaDP9yf+M=,iv:CSSaXY/6MpHBMhPLUWPkabIeJ9zpZkcVjiEhxVF0zJM=,tag:f72ekkjJs7Qmh1K9wC8L9w==,type:str]
|
||||
#ENC[AES256_GCM,data:ODXFUxxxdQ==,iv:s9zJVx6wo6x517tbNvC+FZ0dFzqbjqeLI6rXBq72hQA=,tag:bXoV2I3LbpmQyddJrtS3Qg==,type:comment]
|
||||
#
|
||||
#
|
||||
#ENC[AES256_GCM,data:T4Wtn49AAxPd2QUFTR+q,iv:bH5goGWBDqumAat9dUv2OwfCUJUpuVqncTMqMBZUXhI=,tag:G+W6hHA+yftQ+4RJpXrxHg==,type:comment]
|
||||
switch:
|
||||
password: ENC[AES256_GCM,data:qu0f9L7A0eFq/UCpaRs=,iv:W8LLOp3MSfd/+EfNEZNf91K8GgI5eUfVPoWTRES2C0Y=,tag:Q5FlAOfwqwJwPvd7k6i+0g==,type:str]
|
||||
@@ -272,7 +284,7 @@ sops:
|
||||
UmliaFNxVTBqRkI1QWJpWGpTRWxETW8KEY/8AfU73UOzCGhny1cNnd5dCNv7bHXt
|
||||
k+uyWPPi+enFkVaceSwMFrA66uaWWrwAj11sXEB7yzvGFPrnAGezjQ==
|
||||
-----END AGE ENCRYPTED FILE-----
|
||||
lastmodified: "2026-04-03T08:39:32Z"
|
||||
mac: ENC[AES256_GCM,data:Lcv2BK6nhGhMrWBfcTXC0zzi1cAPxCU/Rwlxck1Uz6tN6b1SQi0Xq5LcmXUOFhFAYNg7Bd6njspYzdJ1MRI85bR/RKye7XcY+Nmdk8ZWDouxd8a8zKsWDCPXbLbIn1/ZiKZlS0Rd46xGVv8nbyxq0smp34RAzCzkxCGjob/LcF0=,iv:7wn7kfC9aSOAELHKaPby8nCVy3H++tY9bkV+STWS1vo=,tag:eRvsZ+L1+lUAdtHOrCR0LQ==,type:str]
|
||||
lastmodified: "2026-04-06T14:32:22Z"
|
||||
mac: ENC[AES256_GCM,data:OFiSsBBAzOUoOwnAwhaplQQ8k2kUo+Avzk475BpaiOJoaB2c0wsJ3siP15tcLMrav4Qw8boZFo64v+rjdMoNI/MRo1EOYWNr1ZRMqHzwmQeaiMH2QcfoRZ0oLqrn5ekQztuPR9ULjDYZb63AwVGmzseUf4R5lGXgdgN5tjU/pH4=,iv:hqzDwryMuJ7JnkBazzDSznw05m7k61Sk61aPgO3JtpU=,tag:Lhhlgwy+YuQ1S0hkbsjecg==,type:str]
|
||||
unencrypted_suffix: _unencrypted
|
||||
version: 3.12.1
|
||||
|
||||
49
config/services/containers/app/affine/affine.container.j2
Normal file
49
config/services/containers/app/affine/affine.container.j2
Normal file
@@ -0,0 +1,49 @@
|
||||
[Quadlet]
|
||||
DefaultDependencies=false
|
||||
|
||||
[Unit]
|
||||
Description=AFFiNE
|
||||
|
||||
After=redis_affine.service manticore_affine.service
|
||||
Wants=redis_affine.service manticore_affine.service
|
||||
|
||||
[Container]
|
||||
Image=ghcr.io/toeverything/affine:{{ version['containers']['affine'] }}
|
||||
ContainerName=affine
|
||||
HostName=affine
|
||||
|
||||
PublishPort={{ services['affine']['ports']['http'] }}:3010
|
||||
|
||||
Volume=%h/data/containers/affine:/root/.affine/storage:rw
|
||||
Volume=%h/containers/affine/config:/root/.affine/config
|
||||
Volume=%h/containers/affine/ssl:/etc/ssl/affine:ro
|
||||
|
||||
# General
|
||||
Environment="TZ=Asia/Seoul"
|
||||
## OIDC callback URIs
|
||||
Environment="AFFINE_SERVER_HOST={{ services['affine']['domain']['public'] }}.{{ domain['public'] }}"
|
||||
Environment="AFFINE_SERVER_EXTERNAL_URL=https://{{ services['affine']['domain']['public'] }}.{{ domain['public'] }}"
|
||||
Environment="AFFINE_SERVER_HTTPS=true"
|
||||
|
||||
Secret=AFFINE_PRIVATE_KEY,type=env
|
||||
|
||||
# Database
|
||||
Secret=AFFINE_DATABASE_URL,type=env,target=DATABASE_URL
|
||||
## Enable AI function: this needs pgvector
|
||||
|
||||
# Redis
|
||||
Environment="REDIS_SERVER_HOST=host.containers.internal"
|
||||
Environment="REDIS_SERVER_PORT={{ services['affine']['ports']['redis'] }}"
|
||||
|
||||
# Indexer
|
||||
Environment="AFFINE_INDEXER_ENABLED=true"
|
||||
Environment="AFFINE_INDEXER_SEARCH_ENDPOINT=http://host.containers.internal:{{ services['affine']['ports']['manticore'] }}"
|
||||
|
||||
[Service]
|
||||
ExecStartPre=/usr/bin/nc -zv {{ services['postgresql']['domain'] }}.{{ domain['internal'] }} {{ services['postgresql']['ports']['tcp'] }}
|
||||
Restart=always
|
||||
RestartSec=10s
|
||||
TimeoutStopSec=120
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
||||
@@ -13,7 +13,7 @@ Image=docker.io/gitea/gitea:{{ version['containers']['gitea'] }}
|
||||
ContainerName=gitea
|
||||
HostName=gitea
|
||||
|
||||
PublishPort=3000:3000/tcp
|
||||
PublishPort={{ services['gitea']['ports']['http'] }}:3000/tcp
|
||||
|
||||
Volume=%h/data/containers/gitea:/data:rw
|
||||
Volume=%h/containers/gitea/ssl:/etc/ssl/gitea:ro
|
||||
|
||||
@@ -25,6 +25,10 @@ Volume=%h/containers/immich/ssl:/etc/ssl/immich:ro
|
||||
|
||||
# Environment
|
||||
Environment="TZ=Asia/Seoul"
|
||||
# The new environment from version 2.7.0 to enable CSP
|
||||
Environment="IMMICH_HELMET_FILE=true"
|
||||
|
||||
# Redis
|
||||
Environment="REDIS_HOSTNAME=host.containers.internal"
|
||||
Environment="REDIS_PORT={{ services['immich']['ports']['redis'] }}"
|
||||
Environment="REDIS_DBINDEX=0"
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
DefaultDependencies=false
|
||||
|
||||
[Unit]
|
||||
Description=Manticore
|
||||
Description=Manticore - {{ manticore_service }}
|
||||
|
||||
[Container]
|
||||
Image=docker.io/manticoresearch/manticore:{{ version['containers']['manticore'] }}
|
||||
|
||||
@@ -10,7 +10,7 @@ theme: 'auto'
|
||||
# Server configuration
|
||||
server:
|
||||
# TLS will be applied on caddy
|
||||
address: 'tcp://:9091/'
|
||||
address: 'tcp://:{{ services['authelia']['ports']['http'] }}/'
|
||||
|
||||
# Log configuration
|
||||
log:
|
||||
@@ -110,7 +110,7 @@ identity_providers:
|
||||
key: {{ secret "/run/secrets/AUTHELIA_JWKS_RS256" | mindent 10 "|" | msquote }}
|
||||
- algorithm: 'ES256'
|
||||
use: 'sig'
|
||||
key: {{ secret "/run/secrets/AUTHELIA_JWKS_ES256" | mindent 10 "|" | msquote }}{% endraw %}
|
||||
key: {{ secret "/run/secrets/AUTHELIA_JWKS_ES256" | mindent 10 "|" | msquote }}{% endraw %}
|
||||
clients:
|
||||
# https://www.authelia.com/integration/openid-connect/clients/synology-dsm/
|
||||
- client_id: 'dsm'
|
||||
@@ -344,3 +344,24 @@ identity_providers:
|
||||
access_token_signed_response_alg: 'RS256'
|
||||
userinfo_signed_response_alg: 'none'
|
||||
token_endpoint_auth_method: 'none'
|
||||
# https://docs.affine.pro/self-host-affine/administer/oauth-2-0
|
||||
- client_id: 'affine'
|
||||
client_name: 'Affine'
|
||||
client_secret: '{{ hostvars['console']['affine']['oidc']['hash'] }}'
|
||||
public: false
|
||||
authorization_policy: 'one_factor'
|
||||
require_pkce: false
|
||||
pkce_challenge_method: ''
|
||||
redirect_uris:
|
||||
- 'https://{{ services['affine']['domain']['public'] }}.{{ domain['public'] }}/oauth/callback'
|
||||
scopes:
|
||||
- 'openid'
|
||||
- 'profile'
|
||||
- 'email'
|
||||
response_types:
|
||||
- 'code'
|
||||
grant_types:
|
||||
- 'authorization_code'
|
||||
access_token_signed_response_alg: 'none'
|
||||
userinfo_signed_response_alg: 'none'
|
||||
token_endpoint_auth_method: 'client_secret_post'
|
||||
|
||||
@@ -71,3 +71,9 @@
|
||||
header_up Host {http.request.header.X-Forwarded-Host}
|
||||
}
|
||||
}
|
||||
{{ services['affine']['domain']['internal'] }}.{{ domain['internal'] }} {
|
||||
import private_tls
|
||||
reverse_proxy host.containers.internal:{{ services['affine']['ports']['http'] }} {
|
||||
header_up Host {http.request.header.X-Forwarded-Host}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@
|
||||
import crowdsec_log
|
||||
route {
|
||||
crowdsec
|
||||
reverse_proxy host.containers.internal:9091
|
||||
reverse_proxy host.containers.internal:{{ services['authelia']['ports']['http'] }}
|
||||
}
|
||||
}
|
||||
# test.ilnmors.com {
|
||||
@@ -127,6 +127,15 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
{{ services['affine']['domain']['public'] }}.{{ domain['public'] }} {
|
||||
import crowdsec_log
|
||||
route {
|
||||
crowdsec
|
||||
reverse_proxy https://{{ services['affine']['domain']['internal'] }}.{{ domain['internal'] }} {
|
||||
header_up Host {http.reverse_proxy.upstream.host}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Internal domain
|
||||
{{ node['name'] }}.{{ domain['internal'] }} {
|
||||
|
||||
@@ -203,12 +203,11 @@ loki.relabel "caddy_relabel" {
|
||||
loki.process "journal_parser" {
|
||||
forward_to = [loki.write.loki.receiver]
|
||||
// Severity parsing
|
||||
// If content of log includes "level" information, change the level
|
||||
stage.logfmt {
|
||||
mapping = {
|
||||
"content_level" = "level",
|
||||
}
|
||||
stage.regex {
|
||||
// Regex to extract the log level from the content.
|
||||
expression = "(?i)(?:level[\"\\s:=]+|\\[|\\s|^)(?P<content_level>info|warn|warning|error|debug|fatal|critical|trace)(?:[\"\\]\\s]|$)"
|
||||
}
|
||||
|
||||
stage.labels {
|
||||
values = {
|
||||
"level" = "content_level",
|
||||
|
||||
@@ -21,9 +21,9 @@ ProtectHome=tmpfs
|
||||
InaccessiblePaths=/boot /root
|
||||
|
||||
{% if node['name'] == 'infra' %}
|
||||
BindReadOnlyPaths=/home/infra/containers/postgresql/backups
|
||||
BindReadOnlyPaths=%h/containers/postgresql/backups
|
||||
{% elif node['name'] == 'app' %}
|
||||
BindReadOnlyPaths=/home/app/data
|
||||
BindReadOnlyPaths=%h/data
|
||||
{% endif %}
|
||||
# In root namescope, %u always bring 0
|
||||
BindPaths=/etc/kopia
|
||||
|
||||
@@ -1,5 +1,26 @@
|
||||
# Git configuration
|
||||
|
||||
## Convention
|
||||
|
||||
- `type(scope): subject`
|
||||
|
||||
- type:
|
||||
- feat: Append the new feature
|
||||
- fix: Fix the bug or errors
|
||||
- docs: Fix the documentations
|
||||
- refactor: Modify code structure without functional changes
|
||||
- perf: Improve the performance
|
||||
- chore: Modify system, package manager, etc configuration
|
||||
- style: Fix code formatting, etc...
|
||||
|
||||
## Commit and tags
|
||||
|
||||
- In this homelab, `[Infra_structure_change]:[Services_change]:[Documents_and_configuration_change]` is the tagging rule.
|
||||
- Tagging and commit should be distinguished.
|
||||
- The change which affects system: tagging
|
||||
- The change which doesn't affect system: commit
|
||||
- `git commit -m "docs(git): define git convention"`
|
||||
|
||||
## Local git
|
||||
|
||||
```bash
|
||||
@@ -29,14 +50,8 @@ git add .
|
||||
# Check git changes
|
||||
git status
|
||||
git commit -m "1.0.0: Release IaaS baseline"
|
||||
# git commit -m "docs: update 07-git.md to add the way to manage git system"
|
||||
# Make current documents as snapshot
|
||||
git tag -a 1.0.0 -m "IaaS baseline"
|
||||
# Make special changes
|
||||
# In this homelab, [Infra_structure_change]:[Services_change]:[Documents_and_configuration_change]
|
||||
# Tagging and commit should be distinguished.
|
||||
# The change which affects system: tagging
|
||||
# The change which doesn't affect system: commit
|
||||
|
||||
|
||||
# Commands
|
||||
git status # What files are changed
|
||||
|
||||
122
docs/services/app/affine.md
Normal file
122
docs/services/app/affine.md
Normal file
@@ -0,0 +1,122 @@
|
||||
# affine
|
||||
|
||||
## Prerequisite
|
||||
|
||||
### Create database
|
||||
|
||||
- Create the password with `openssl rand -base64 32`
|
||||
- Save this value in secrets.yaml in `postgresql.password.affine`
|
||||
- Access infra server to create affine_db with `podman exec -it postgresql psql -U postgres`
|
||||
|
||||
```SQL
|
||||
CREATE USER affine WITH PASSWORD 'postgresql.password.affine';
|
||||
CREATE DATABASE affine_db;
|
||||
ALTER DATABASE affine_db OWNER TO affine;
|
||||
\connect affine_db
|
||||
CREATE EXTENSION IF NOT EXISTS vector;
|
||||
\dx
|
||||
-- Check the extension is activated with `\dx`
|
||||
-- postgresql image is built with `pgvector` and `vectorchord` already
|
||||
```
|
||||
|
||||
### Create oidc secret and hash
|
||||
|
||||
- Create the secret with `openssl rand -base64 32`
|
||||
- access to auth vm
|
||||
- `podman exec -it authelia sh`
|
||||
- `authelia crypto hash generate pbkdf2 --password 'affine.oidc.secret'`
|
||||
- Save this value in secrets.yaml in `affine.oidc.secret` and `affine.oidc.hash`
|
||||
|
||||
### Create secret key value
|
||||
|
||||
- Create the secret with `openssl genpkey -algorithm ed25519 -outform PEM`
|
||||
- Save this value in secrets.yaml in `affine.secret_key`
|
||||
|
||||
### Create admin password
|
||||
|
||||
- Create the secret with `openssl rand -base64 32`
|
||||
- Save this value in secrets.yaml in `affine.il.password`
|
||||
|
||||
### Add postgresql dump backup list
|
||||
|
||||
- [set_postgresql.yaml](../../../ansible/roles/infra/tasks/services/set_postgresql.yaml)
|
||||
|
||||
```yaml
|
||||
- name: Set connected services list
|
||||
ansible.builtin.set_fact:
|
||||
connected_services:
|
||||
- ...
|
||||
- "affine"
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
### About community edition limitation
|
||||
|
||||
- Workspace seats
|
||||
- The number of members itself \(account\) are unlimited.
|
||||
- However the number of members who work on the same workspace simultaneously \(seats\) are designated as 10 members.
|
||||
- Workspace storage quota
|
||||
- Originally, self-hosted version has no limitation in storage quota and uploading file size.
|
||||
- Now, there is some limitation even in the self-hosted version.
|
||||
- It will be changed when the application is updating
|
||||
|
||||
### Following feature which will be applied in this system
|
||||
|
||||
- Linking local caldav vaikal or radicale ...
|
||||
- Apply AI function with API
|
||||
|
||||
### Access to affine
|
||||
|
||||
- https://affine.ilnmors.com
|
||||
- Getting started
|
||||
- admin name
|
||||
- admin E-mail
|
||||
- admin password
|
||||
- Initial setting allows only 32 digit password, now just set temporary password
|
||||
|
||||
### Server configuration
|
||||
- https://affine.ilnmors.com/admin
|
||||
|
||||
#### Server
|
||||
|
||||
- A recognizable name for the server. Will be shown when connected with AFFiNE Desktop.
|
||||
- Ilnmors
|
||||
|
||||
#### Auth
|
||||
|
||||
- [ ] Whether allow new registrations
|
||||
- [x] Whether allow new registration via configured oauth
|
||||
- Minimum length requirement of password: 8
|
||||
- Maximum length requirement of password: 50
|
||||
- save
|
||||
|
||||
#### Oauth configuration
|
||||
|
||||
```ini
|
||||
# These options are required
|
||||
## OIDC callback URIs
|
||||
Environment="AFFINE_SERVER_HOST={{ services['affine']['domain']['public'] }}.{{ domain['public'] }}"
|
||||
Environment="AFFINE_SERVER_EXTERNAL_URL=https://{{ services['affine']['domain']['public'] }}.{{ domain['public'] }}"
|
||||
Environment="AFFINE_SERVER_HTTPS=true"
|
||||
```
|
||||
- OIDC Oauth provider config
|
||||
|
||||
```json
|
||||
{
|
||||
"clientId":"affine",
|
||||
"clientSecret":"affine.oidc.secret",
|
||||
"issuer":"https://authelia.ilnmors.com",
|
||||
"args":{
|
||||
"scope": "openid profile email"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
- save
|
||||
|
||||
#### Flags
|
||||
|
||||
- [ ] Whether allow guest users to create demo workspaces
|
||||
- save
|
||||
|
||||
@@ -119,10 +119,11 @@
|
||||
- [x] Immich
|
||||
- [x] Actual budget
|
||||
- [x] Paperless-ngx
|
||||
- [x] vikunja
|
||||
- OpenCloud \(with Radicale, Collabora Web Office\)
|
||||
- Outline
|
||||
- Wiki.js
|
||||
- [x] vikunja - When affine is verified to substitute kanban board and etc, then disable this service.
|
||||
- [x] OpenCloud
|
||||
- [x] affine \(Notion substitution\)
|
||||
- [ ] Radicale
|
||||
- [ ] Collabora office
|
||||
- WriteFreely
|
||||
- MediaCMS
|
||||
- Funkwhale
|
||||
|
||||
Reference in New Issue
Block a user