Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ansible/playbooks/service_configuration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
when: "'containers' not in group_names"
# KVM-NAS01
- include_role:
name: filebrowser_deployment
name: nextcloud_deployment
when: inventory_hostname == "KVM-NAS01"
# KVM-MONITOR01
- include_role:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ services:
environment:
POSTGRES_USER: "{{ postgres_user }}"
POSTGRES_PASSWORD: "{{ postgres_password }}"
POSTGRES_DB: "{{ postgres_db }}"
POSTGRES_DB: "{{ authentik_postgres_db }}"

redis:
image: docker.io/library/redis:7-alpine
Expand All @@ -39,7 +39,7 @@ services:
AUTHENTIK_POSTGRESQL__HOST: postgresql
AUTHENTIK_POSTGRESQL__USER: "{{ postgres_user }}"
AUTHENTIK_POSTGRESQL__PASSWORD: "{{ postgres_password }}"
AUTHENTIK_POSTGRESQL__NAME: "{{ postgres_db }}"
AUTHENTIK_POSTGRESQL__NAME: "{{ authentik_postgres_db }}"
AUTHENTIK_SECRET_KEY: "{{ authentik_secret_key }}"
volumes:
- ./media:/media
Expand All @@ -63,7 +63,7 @@ services:
AUTHENTIK_POSTGRESQL__HOST: postgresql
AUTHENTIK_POSTGRESQL__USER: "{{ postgres_user }}"
AUTHENTIK_POSTGRESQL__PASSWORD: "{{ postgres_password }}"
AUTHENTIK_POSTGRESQL__NAME: "{{ postgres_db }}"
AUTHENTIK_POSTGRESQL__NAME: "{{ authentik_postgres_db }}"
AUTHENTIK_SECRET_KEY: "{{ authentik_secret_key }}"
volumes:
- ./media:/media
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# + https://github.com/homarr-labs/dashboard-icons/tree/main/png
# + https://simpleicons.org/ (For si- prefix icons)

{% set filebrowser = docker_services | selectattr('name', 'equalto', 'filebrowser') | first %}
{% set nextcloud = (docker_services | selectattr('name', 'equalto', 'nextcloud') | list | first) | default(None) %}
{% set grafana = docker_services | selectattr('name', 'equalto', 'grafana') | first %}
{% set prometheus = docker_services | selectattr('name', 'equalto', 'prometheus') | first %}
{% set npm = docker_services | selectattr('name', 'equalto', 'npm') | first %}
Expand Down Expand Up @@ -88,16 +88,16 @@
{% endfor %}

- Management:
- Filebrowser:
icon: {{ filebrowser.name }}.png
href: {{ filebrowser.forward_scheme | default('http') }}://{{ filebrowser.forward_host }}:{{ filebrowser.forward_port }}
description: Self-hosted file manager
siteMonitor: {{ filebrowser.forward_scheme | default('http') }}://{{ filebrowser.forward_host }}:{{ filebrowser.forward_port }}
- Nextcloud:
icon: si-nextcloud-#0082C9
href: {{ nextcloud.forward_scheme | default('http') }}://{{ nextcloud.forward_host }}:{{ nextcloud.forward_port }}
description: Self-hosted cloud storage & collaboration
siteMonitor: {{ nextcloud.forward_scheme | default('http') }}://{{ nextcloud.forward_host }}:{{ nextcloud.forward_port }}/status.php
widget:
type: {{ filebrowser.name }}
url: {{ filebrowser.forward_scheme | default('http') }}://{{ filebrowser.forward_host }}:{{ filebrowser.forward_port }}
username: {{ ansible_user }}
password: {{ ansible_password }}
type: nextcloud
url: {{ nextcloud.forward_scheme | default('http') }}://{{ nextcloud.forward_host }}:{{ nextcloud.forward_port }}
username: "{{ ansible_user }}"
password: "{{ ansible_password }}"
{% for env in portainer_environments %}
- Portainer ({{ env.name }}):
icon: si-{{ portainer.name }}-#13BEF9
Expand Down
93 changes: 93 additions & 0 deletions ansible/roles/services/nextcloud_deployment/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
---
# Reference: https://github.com/nextcloud/docker
- name: Linux Variables Load
ansible.builtin.include_vars:
file: ../../../variables/os_var/linux_var.yml

- name: CIFS (Common Internet File System) Utilities Installation
ansible.builtin.apt:
name: cifs-utils
state: present

- name: Mount Point Directory Creation
ansible.builtin.file:
name: "{{ nas_mount_dir }}"
state: directory
owner: "{{ www_data_uid }}"
group: "{{ www_data_gid }}"
mode: '0770'

- name: NAS Credentials File Creation
ansible.builtin.template:
src: cifs_credentials.j2
dest: /etc/cifs_credentials
owner: root
group: root
mode: '0600'

- name: Permanent Mount Configuration
ansible.posix.mount:
src: "{{ nas_path }}"
path: "{{ nas_mount_dir }}"
fstype: cifs
opts: "credentials=/etc/cifs_credentials,uid={{ www_data_uid }},gid={{ www_data_gid }},file_mode=0770,dir_mode=0770,iocharset=utf8,vers=3.0,nofail"
state: mounted
register: permanent_mount

- name: Reload to Apply Changes
ansible.builtin.systemd_service:
daemon_reload: true
when: permanent_mount.changed

- name: Mount Execution
ansible.builtin.command:
cmd: mount -a
when: permanent_mount.changed

# - name: Nextcloud Parent & Infrastructure Directories Creation
# ansible.builtin.file:
# path: "{{ item }}"
# state: directory
# owner: "{{ ansible_user }}"
# group: "{{ ansible_user }}"
# mode: '0755'
# loop:
# - "{{ nextcloud_parent_dir }}"
# - "{{ nextcloud_parent_dir }}/postgres_data"
# - "{{ nextcloud_parent_dir }}/redis_data"

- name: Nextcloud Parent & Infrastructure Directories Creation
ansible.builtin.file:
path: "{{ item.path }}"
state: directory
owner: "{{ item.owner }}"
group: "{{ item.group }}"
mode: "{{ item.mode }}"
loop:
- { path: "{{ nextcloud_parent_dir }}", owner: "{{ ansible_user }}", group: "{{ ansible_user }}", mode: '0755' }
- { path: "{{ nextcloud_parent_dir }}/postgres_data", owner: "{{ ansible_user }}", group: "{{ ansible_user }}", mode: '0755' }
- { path: "{{ nextcloud_parent_dir }}/redis_data", owner: '999', group: '999', mode: '0770' }

- name: Nextcloud Web Root Directory Creation (www-data ownership)
ansible.builtin.file:
path: "{{ nextcloud_parent_dir }}/html"
state: directory
owner: "{{ www_data_uid }}"
group: "{{ www_data_gid }}"
mode: '0770'

- name: Docker Compose File Creation
ansible.builtin.template:
src: docker-compose.yml.j2
dest: "{{ nextcloud_parent_dir }}/docker-compose.yml"
owner: "{{ ansible_user }}"
group: "{{ ansible_user }}"
mode: '0644'
register: docker_compose_file

- name: Nextcloud Deployment
community.docker.docker_compose_v2:
project_src: "{{ nextcloud_parent_dir }}"
pull: "{{ docker_image_pull_action }}"
state: present
remove_orphans: true
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
username={{ domain_admin_user.split('@') | first }}
password={{ domain_admin_password }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
services:
postgresql:
image: docker.io/library/postgres:16-alpine
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "pg_isready -d $${POSTGRES_DB} -U $${POSTGRES_USER}"]
start_period: 20s
interval: 30s
retries: 5
timeout: 5s
volumes:
- ./postgres_data:/var/lib/postgresql/data
environment:
POSTGRES_USER: "{{ postgres_user }}"
POSTGRES_PASSWORD: "{{ postgres_password }}"
POSTGRES_DB: "{{ nextcloud_postgres_db }}"

redis:
image: docker.io/library/redis:7-alpine
command: redis-server --save "" --appendonly no --loglevel warning
restart: unless-stopped
healthcheck:
test: ["CMD-SHELL", "redis-cli ping | grep PONG"]
start_period: 20s
interval: 30s
retries: 5
timeout: 5s
volumes:
- ./redis_data:/data

app:
image: docker.io/library/nextcloud:{{ nextcloud_version }}
restart: unless-stopped
ports:
- "8080:80"
environment:
POSTGRES_HOST: postgresql
POSTGRES_USER: "{{ postgres_user }}"
POSTGRES_PASSWORD: "{{ postgres_password }}"
POSTGRES_DB: "{{ nextcloud_postgres_db }}"
REDIS_HOST: redis
NEXTCLOUD_ADMIN_USER: "{{ ansible_user }}"
NEXTCLOUD_ADMIN_PASSWORD: "{{ ansible_password }}"
NEXTCLOUD_TRUSTED_DOMAINS: "nextcloud.khangvum.com nextcloud.{{ domain_name }} {{ hostvars['KVM-NAS01'].ansible_host }} localhost 127.0.0.1"
volumes:
- ./html:/var/www/html
- "{{ nas_mount_dir }}:/var/www/html/data"
depends_on:
postgresql:
condition: service_healthy
redis:
condition: service_healthy

cron:
image: docker.io/library/nextcloud:{{ nextcloud_version }}
restart: unless-stopped
entrypoint: /cron.sh
environment:
POSTGRES_HOST: postgresql
POSTGRES_USER: "{{ postgres_user }}"
POSTGRES_PASSWORD: "{{ postgres_password }}"
POSTGRES_DB: "{{ nextcloud_postgres_db }}"
REDIS_HOST: redis
volumes:
- ./html:/var/www/html
- "{{ nas_mount_dir }}:/var/www/html/data"
depends_on:
postgresql:
condition: service_healthy
redis:
condition: service_healthy
2 changes: 1 addition & 1 deletion ansible/variables/docker_var/iam_var.template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ authentik_version: "2026.5.2"

postgres_user: "{{ ansible_user }}"
postgres_password: "{{ ansible_password }}"
postgres_db: "authentik"
authentik_postgres_db: "authentik"
authentik_secret_key: {{ AUTHENTIK_SECRET_KEY }}
37 changes: 19 additions & 18 deletions ansible/variables/docker_var/iam_var.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
$ANSIBLE_VAULT;1.1;AES256
63313539363865306537653766353039323132373736323462303238356434343762616638346538
6139306631366464356639613937393362303661313765310a666265623631366336653965356332
63326161383337313764356166383464626364623432386430316632626635323737326135653532
3731383662393863300a336465643535353265656261623338643439353533323336383231663238
35663265636661313030626332623062326162313261306230383065613935623833333135333639
64333030356537306232373564303633303666633966346464393161346561373737333935353966
36393130363233326137383339376661373737386339373538613034383462366231643465393830
33303065343666646435336338323437313737323463323638646238376234613134643433626432
64363538353364306336323238343762363939313862373735323330663932306262326137373966
39663537633035663863353530346638653231373330386562656239376465663465666635663062
62623362313865643636313833656634376433376564333334363031643832333064663962326538
65666234643662623731633637663639396138383566396530316338653162356364326631323664
32376338656632343934303339343030636663646239653232343164623865343033346137313862
35356439613431623466613165613431663834623865313236326262643631326663303437636534
63366435653864303566336565356636636534616165343863363032616266643163353965626435
36316436633136306233323261333039333331333161663333643337393464376238313634383839
62653337336636363061653433306136346163313865373633363835313637643138656564343165
6461313338343264386533636439646433656336383438306663
30613365383964393565333136303463396537393631393233316362303139313938303266363231
6265336534326239343432326536666632633930323764390a646266353862646664646638613065
35623031373863356532353565613034363134646632396136333961663731653534633836383936
3033316464323232320a613637323161393438353738613365616434356233323564353834306535
39396132626336663762393930333031636631353033346137653431373332393664313330643737
34396663333037313239383635666263366130616639373663636231333662383835653138366137
32646263666234623266366636336333366236336134373539363964346338363862666535316366
34326464626233333635396664343265363638343763336231346439383664613830643663626561
30626664316463613264363532666637373864383436643431303535333732356664396434333239
33623163396132663435623530646530346434636461323530353438663837336330636465393765
30313036666534306234663535633330643937393439646238326237316664636232356631323132
36376234643636613939633437343233653534316362373935383636383666346164643830396633
62663632393134373635646361383939373337356135393864366536616363373266656435633433
38303064633532613465303839356330623534353934393637386334316461623831333362656461
34663930313363653931663533333163376338633935643439346461313535613562643230643230
31393235366638313939396636323663326164313534313130306365363036313336393839343037
66383963313261376336616535353537346339646633396232356262346135316662333761663264
39316433646361653036303462656266336533353237393161653761613736336633393536663730
336562326637396536626137666661646532
2 changes: 2 additions & 0 deletions ansible/variables/docker_var/media_var.template.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
media_mount_dir: /mnt/nas/media
media_path: "//{{ hostvars['KVM-SRV01'].ansible_host }}/NAS/media"
administrator_uid: 1000
administrator_gid: 1000

# Jellyfin
jellyfin_parent_dir: "/home/{{ ansible_user }}/docker/jellyfin"
Expand Down
36 changes: 19 additions & 17 deletions ansible/variables/docker_var/media_var.yml
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
$ANSIBLE_VAULT;1.1;AES256
32623335393339313961353062633837643261643162613366633139306633363538626538316434
6438653765333336363630383633326535313965396636330a383939626333373339333132366165
30356165323930653234336531666632353039613337393238316162303565346165646235366437
3334366238326433350a613837306266336461363063363630313438633266356435373561383862
35323830313636363266316565616234366364613264623166626161313930363836613630636639
36613035613635393463646464353261356138336531373339323562333133366230373230363463
31306538656536343735396437323336306666656237326137383163663662626561323662643833
63633432373565626130663831313433343835336466323061353734363433623566323965373465
63653264623038656130646638343937376531386435616265366132643962336561303766356463
66316631633334393236663836386563343930303135363635343037376638343162616364396633
66643265366635376463373535306237313934633237663039363762623866303936363733316234
30303062396665343565393962393638383039356634376461633833613261666164386534363737
37316137353166663739366666313033326262316433346265643036353430353761323833663263
33396462353563323435346361343963383039653537363765356465386465643734333165653434
65663637336530343663353030653239623439313563623062333761376132663630393830643934
64666331613663356261303033323565323163353534646134633835326339343031666130373834
3965
35636538333261623963333530653761363463356163363238663432643031623564306330666661
3135333635303834376235373332323034386337366134650a616163633430353132386636356634
34393764653265313038356237366562646433353631626537346665373133303836386563316136
3738613639376561390a363862313631653937323436656533366435316566383565306361313633
36306333613436643065316337386434353862643161313863636532313138326565303139633832
36666463633662396162626531353937393137633265363963346434616437393632383534636639
33333964353961366165333236323464393633623663616131313162666663343533633831653735
65613536623131646463356262303533656561313866346632383534653537383339626361393337
36396461333365303762373731326236376164646132306463303135626261303462623966616163
38663363663330646433623634313530383561323366613536353933326236303161343130666666
30626535623466633834376263663931383536643232306161633536333661613032643964306665
37643837393566623738336135666232323134633632366265636661363635633864666166656662
37356530623233343633666634343934373161393863386166306530653739303466306433396432
36656261396266353363396136636433313462613930653434336464306131323639656637333532
36633165616433306662636134343230653034626564323430623833646161313634313062353463
66376433303366333164653737373030326130313637363732383866353233613531303065643338
31326635663435356139653130383537666133643338326630333663633564613061363463616633
66393830633833373835303163306438643337653165306235643965313738316238393034666363
636430386633386530326263353230383932
8 changes: 5 additions & 3 deletions ansible/variables/docker_var/nas_var.template.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
---
filebrowser_parent_dir: "/home/{{ ansible_user }}/docker/filebrowser"
nextcloud_parent_dir: "/home/{{ ansible_user }}/docker/nextcloud"
nextcloud_postgres_db: "nextcloud"
nextcloud_version: "34.0.3"
nas_mount_dir: /mnt/nas
nas_path: "//{{ hostvars['KVM-SRV01'].ansible_host }}/NAS"

administrator_uid: 1000
administrator_gid: 1000
www_data_uid: 33
www_data_gid: 33
31 changes: 17 additions & 14 deletions ansible/variables/docker_var/nas_var.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
$ANSIBLE_VAULT;1.1;AES256
64366164636138633532316566636532393565633766383164666232633733383361303639303564
6531383133303361376162336663306235653066363665650a663263333063656264646238323162
30343837633063616561306435323839616139303932663539333534323431353839393062393136
3231396365333064620a616261383433316232316662346335306630636164326632336362633864
32363937643035666531623661613864356431626536306563306531363230333939636234646264
37383937373630646436396638346130333734303031626365666464373766363336393839303231
61633662363632336134393233643361323937363934343966323433393833663061313335643831
30666664666462316235626266623332656436306530373062396533666366333362336330323466
65383539323363353438316438393438323164653165646632346132356231326162366662623361
61383564323134306335383965633864333233316131386539356434306438643163366666656162
36363435643966646638636239326533373734373939383934313037663664663166373166356634
39383364313437363364336461656639656332653839343363303437333463363763636565663465
38333266633132363165666339353265323364336131663135363866353139663236633466656262
6264383434363332363664613038633530343261646566363339
64353566373164383033353764646533373233343561303963306539653662663335343463393962
6531356466353639613039376665383834303535303566310a623764613863663563613465313039
35383738353162663039336636356265663364636366616161663035613462653163373834613835
3237326664356234300a393032346534336261643132343831356365646464373935623532333935
64666638336439616133623436333634376661653166366235356562643961326632323065656561
38613039373435383432633736633964343032616434653132653861373066663832633833363735
30613834626665616334386664613836643233363462353263623230386532633432353138366666
62356362646638633864313230383431653734336138616438643433316464663366303230656566
62313233363164616330666265373238613638353764373234313661626664326630613539623639
64613436663330333963313264626639343035366361303132316239353430313663323361363235
65333462353733346530303066343338353830326537653834373833386263313238323565333630
37323436313132336237616466653834356233376430633566386532633362373138633133633939
64343939373363396164336631386635373235303961353139366431313333386438646535633139
34303136323839343732373836316137386333326631343739646438393735373862323237393832
64653165356536666465353130323933343061303738333131396265383135623639613031613635
62326438643333303432663938346231663463386532653333393966363539646434326565393830
3734
4 changes: 2 additions & 2 deletions ansible/variables/docker_var/vpn_var.template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ docker_services:
- name: authentik
forward_host: "{{ hostvars['KVM-IAM01'].ansible_host }}"
forward_port: 9000
- name: filebrowser
- name: nextcloud
forward_host: "{{ hostvars['KVM-NAS01'].ansible_host }}"
forward_port: 8095
forward_port: 8080
- name: grafana
forward_host: "{{ hostvars['KVM-MONITOR01'].ansible_host }}"
forward_port: 3000
Expand Down
Loading
Loading