aboutsummaryrefslogtreecommitdiff
path: root/roles/nextcloud
diff options
context:
space:
mode:
authorKumar <kumar@kumardamani.xyz>2021-11-23 14:59:08 +0000
committerKumar Damani <me@kumardamani.net>2022-03-25 19:45:25 +0000
commita857eb82ec9c4a79ad5e41462e2ab82c2660982e (patch)
tree9ca51ddfb551322bd4d2fa3f949fa8898032632d /roles/nextcloud
initial commit
Diffstat (limited to 'roles/nextcloud')
-rw-r--r--roles/nextcloud/defaults/main.yaml17
-rw-r--r--roles/nextcloud/handlers/main.yaml7
-rw-r--r--roles/nextcloud/tasks/main.yaml63
3 files changed, 87 insertions, 0 deletions
diff --git a/roles/nextcloud/defaults/main.yaml b/roles/nextcloud/defaults/main.yaml
new file mode 100644
index 0000000..cd11c66
--- /dev/null
+++ b/roles/nextcloud/defaults/main.yaml
@@ -0,0 +1,17 @@
+# Default Values
+---
+
+nextcloud_uid: "1000"
+nextcloud_gid: "1000"
+nextcloud_tz: 'America/Toronto'
+nextcloud_data_root: ''
+nextcloud_host_port: ''
+
+nextcloud_docker_network_name: 'nextcloud_network'
+
+nextcloud_postgres_db: 'nextcloud_db'
+nextcloud_postgres_user: 'nextcloud'
+nextcloud_postgres_password: ''
+
+nextcloud_container_name: 'nextcloud'
+nextcloud_dashboard_url: 'https://{{ nextcloud_domain }}'
diff --git a/roles/nextcloud/handlers/main.yaml b/roles/nextcloud/handlers/main.yaml
new file mode 100644
index 0000000..7613b54
--- /dev/null
+++ b/roles/nextcloud/handlers/main.yaml
@@ -0,0 +1,7 @@
+---
+
+- name: 'Restart nginx'
+ systemd:
+ name: 'nginx'
+ state: 'restarted'
+ listen: 'nginx_restart'
diff --git a/roles/nextcloud/tasks/main.yaml b/roles/nextcloud/tasks/main.yaml
new file mode 100644
index 0000000..593bfa3
--- /dev/null
+++ b/roles/nextcloud/tasks/main.yaml
@@ -0,0 +1,63 @@
+# https://docs.nextcloud.com/server/19/admin_manual/configuration_server/config_sample_php_parameters.html#default-parameters
+# https://docs.nextcloud.com/server/19/admin_manual/configuration_server/caching_configuration.html#id2
+---
+
+- name: 'Create the nextcloud network'
+ community.docker.docker_network:
+ name: '{{ nextcloud_docker_network_name }}'
+
+- name: Make sure the Postgres container is created and running
+ community.docker.docker_container:
+ name: 'nextcloud-postgres'
+ image: 'postgres:14.1-alpine'
+ pull: true
+ state: 'started'
+ labels:
+ "flame.type": "application"
+ "flame.name": "{{ nextcloud_container_name | title }}"
+ "flame.url": "{{ nextcloud_dashboard_url }}"
+ "flame.icon": "custom"
+ env:
+ "PUID": '{{ nextcloud_uid }}'
+ "PGID": '{{ nextcloud_gid }}'
+ "TZ": '{{ nextcloud_tz }}'
+ "POSTGRES_DB": "{{ nextcloud_postgres_db }}"
+ "POSTGRES_USER": "{{ nextcloud_postgres_user }}"
+ "POSTGRES_PASSWORD": "{{ nextcloud_postgres_password }}"
+ volumes:
+ - '{{ nextcloud_data_root }}/postgres:/var/lib/postgresql/data'
+ restart_policy: 'unless-stopped'
+
+- name: 'Make sure the Redis container is created and running'
+ community.docker.docker_container:
+ name: 'nextcloud-redis'
+ image: 'redis:alpine'
+ pull: true
+ state: 'started'
+ restart_policy: 'unless-stopped'
+
+- name: 'Make sure the Nextcloud container is created and running'
+ community.docker.docker_container:
+ name: '{{ nextcloud_container_name }}'
+ image: 'ghcr.io/linuxserver/nextcloud:php8'
+ pull: true
+ state: 'started'
+ env:
+ "PUID": '{{ nextcloud_uid }}'
+ "PGID": '{{ nextcloud_gid }}'
+ "TZ": '{{ nextcloud_tz }}'
+ volumes:
+ - '{{ nextcloud_data_root }}/config:/config'
+ - '{{ nextcloud_data_root }}/data:/data'
+ ports:
+ - '{{ nextcloud_host_port }}:443'
+ restart_policy: unless-stopped
+
+- name: 'Add {{ nextcloud_container_name }} to the docker network'
+ community.docker.docker_network:
+ name: '{{ nextcloud_docker_network_name }}'
+ connected:
+ - '{{ nextcloud_container_name }}'
+ - '{{ nextcloud_container_name }}-postgres'
+ - '{{ nextcloud_container_name }}-redis'
+ appends: true