homelab/roles/nextcloud/tasks/main.yml

52 lines
1.3 KiB
YAML

---
- name: Create docker volume
become: true
community.docker.docker_volume:
name: nextcloud
- name: Create redis container
include_role:
name: redis
vars:
preset: persistent
container_name: nextcloud-redis
docker_networks:
- name: nextcloud
docker_volume: nextcloud-redis
- name: Copy nextcloud config
become: true
ansible.builtin.template:
src: config.php.j2
dest: "/var/lib/docker/volumes/nextcloud/_data/config/config.php"
owner: "33"
group: "33"
register: cfg
- name: Run nextcloud container
become: true
community.docker.docker_container:
name: nextcloud-{{ item }}
image: nextcloud:30.0.1-apache
networks:
- name: nextcloud
- name: haproxy
- name: postgresql
volumes:
- nextcloud:/var/www/html
- /mnt/hdd/nextcloud/data:/var/www/html/data
recreate: "{{ cfg.changed }}"
restart_policy: unless-stopped
healthcheck:
test: ["CMD", "curl", "--fail", "http://127.0.0.1/status.php"]
interval: 30s
timeout: 10s
retries: 3
start_period: 30s
# TODO: enable after ansible update
# state: healthy
loop: [1, 2]
- name: Schedule background jobs
become: true
ansible.builtin.cron:
name: nextcloud
minute: "*/5"
job: "docker exec --user www-data nextcloud-1 php cron.php"
user: root