--- - 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:{{ version }}-apache networks: - name: nextcloud - name: haproxy - name: postgresql volumes: - nextcloud:/var/www/html - /mnt/hdd/nextcloud/data:/var/www/html/data recreate: "{{ cfg.changed }}" loop: [1] - 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