commit 546fbf4f2e8fa018eda9fd76c063a1939735d534 Author: Kuba Orlik Date: Sun Aug 23 15:39:59 2026 +0200 Initial commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..0825c22 --- /dev/null +++ b/README.md @@ -0,0 +1,32 @@ +```yml +- name: "Install nextcloud" + hosts: czynna1 + vars: + domain: "cloud.strona-czynna.pl" + nextcloud_admin_port: 8342 + nextcloud_ui_port: 8343 + nextcloud_file_storage_path: /mnt/juice/nextcloud + nextcloud_workdir: /var/www/nextcloud + nextcloud_domain: "{{ domain }}" + roles: + - role: nextcloud + tags: + - nextcloud + - role: sealcode.nginx.proxies + tags: + - nextcloud + vars: + - nginx_proxies: + - domain: "cloud-admin.strona-czynna.pl" + site_name: "nextcloud-admin" + upstream: "https://127.0.0.1:{{nextcloud_admin_port}}" + auth_enabled: true + auth_message: "Please log in" + auth_user: "admin" + auth_password: password + - domain: "{{ domain }}" + site_name: "nextcloud" + upstream: "http://127.0.0.1:{{nextcloud_ui_port}}" + max_upload_size: "32G" + disable_ratelimit: true +``` diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..0cf1526 --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,5 @@ +nextcloud_admin_port: 8342 +nextcloud_ui_port: 8343 +nextcloud_file_storage_path: /mnt/juice/nextcloud +nextcloud_workdir: /var/www/nextcloud +nextcloud_domain: "cloud.example.com" diff --git a/meta/main.yml b/meta/main.yml new file mode 100644 index 0000000..0126d0e --- /dev/null +++ b/meta/main.yml @@ -0,0 +1,17 @@ +--- +galaxy_info: + author: kuba + description: nextcloud-docker + license: MIT + min_ansible_version: "2.12" + platforms: + - name: Debian + versions: + - bullseye + - bookworm + - name: Ubuntu + versions: + - focal + - jammy + +dependencies: [] diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..8fcda2e --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,35 @@ +- name: "docker compose down" + community.docker.docker_compose_v2: + state: "absent" + project_src: "{{nextcloud_workdir}}" + register: compose_result + failed_when: > + compose_result.failed and + ("is not a directory" not in compose_result.msg) and + ("does not contain compose.yaml" not in compose_result.msg) + +- name: "Create the nextcloud directory" + file: + path: "{{ nextcloud_workdir }}" + state: "directory" + +- name: Create docker-compose.yml file for Nextcloud + template: + src: docker-compose.yml.j2 + dest: "{{ nextcloud_workdir }}/docker-compose.yml" + +- name: "docker compose up -d nextcloud" + community.docker.docker_compose_v2: + state: "present" + pull: missing + project_src: "{{ nextcloud_workdir }}" + +- ansible.builtin.lineinfile: + path: "/backup-dirs" + line: "{{ nextcloud_file_storage_path }}" + +- ufw: + rule: "allow" + port: "{{item}}" + loop: + - 3478 # nextcloud talk diff --git a/templates/docker-compose.yml.j2 b/templates/docker-compose.yml.j2 new file mode 100644 index 0000000..20aa564 --- /dev/null +++ b/templates/docker-compose.yml.j2 @@ -0,0 +1,49 @@ +# from https://github.com/nextcloud/all-in-one/blob/3fc84ee78438fc7c07e8d/compose.yaml, cleaned up + +name: nextcloud-aio +services: + nextcloud-aio-mastercontainer: + image: nextcloud/all-in-one:latest + container_name: nextcloud-aio-mastercontainer + restart: unless-stopped + + ports: + - "127.0.0.1:{{ nextcloud_admin_port }}:8080" + + environment: + APACHE_PORT: {{ nextcloud_ui_port }} + APACHE_IP_BINDING: 127.0.0.1 + + NEXTCLOUD_DATADIR: "/mnt/ncdata" + + SKIP_DOMAIN_VALIDATION: "true" + TALK_PORT: 3478 + + NEXTCLOUD_ENABLE_DRI_DEVICE: "false" + + NEXTCLOUD_MEMORY_LIMIT: 2048M + NEXTCLOUD_UPLOAD_LIMIT: 16G + NEXTCLOUD_MAX_TIME: 99999 + + OVERWRITEPROTOCOL: https + OVERWRITEHOST: {{ nextcloud_domain }} + + # Optional: + # WATCHTOWER_DOCKER_SOCKET_PATH: /var/run/docker.sock + + volumes: + - /var/run/docker.sock:/var/run/docker.sock:ro + - nextcloud_aio_mastercontainer:/mnt/docker-aio-config + - "{{ nextcloud_file_storage_path }}/data:/mnt/ncdata" + - "{{ nextcloud_file_storage_path }}/backups:/mnt/backup" + + networks: + - nextcloud-aio + +volumes: # If you want to store the data on a different drive, see https://github.com/nextcloud/all-in-one#how-to-store-the-filesinstallation-on-a-separate-drive + nextcloud_aio_mastercontainer: + name: nextcloud_aio_mastercontainer + +networks: + nextcloud-aio: + name: nextcloud-aio