2021-10-13 13:46:46 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
- name: Create nextcloud user
|
|
|
|
user:
|
|
|
|
name: "{{ nextcloud_user }}"
|
|
|
|
state: present
|
|
|
|
system: yes
|
|
|
|
register: nextcloud_user_info
|
|
|
|
|
|
|
|
- name: Ensure nextcloud directories exist and have correct permissions
|
|
|
|
file:
|
|
|
|
path: "{{ item.path }}"
|
|
|
|
state: directory
|
|
|
|
mode: "{{ item.mode }}"
|
|
|
|
owner: "{{ item.owner }}"
|
|
|
|
group: "{{ item.group }}"
|
|
|
|
loop: "{{ nextcloud_paths }}"
|
|
|
|
|
|
|
|
- name: Ensure docker container for nextcloud is pulled
|
|
|
|
docker_image:
|
|
|
|
name: "{{ nextcloud_container_image_ref }}"
|
|
|
|
state: present
|
|
|
|
source: pull
|
|
|
|
force_source: "{{ nextcloud_container_image_force_source }}"
|
|
|
|
|
|
|
|
- name: Template OpCache configuration
|
|
|
|
template:
|
|
|
|
src: nextcloud-fpm-opcache.ini.j2
|
|
|
|
dest: "{{ nextcloud_fpm_config_path }}/opcache.ini"
|
|
|
|
mode: "0640"
|
|
|
|
owner: "root"
|
|
|
|
group: "root"
|
|
|
|
notify:
|
|
|
|
- reload-nextcloud
|
|
|
|
|
|
|
|
- name: Template PHP FPM configuration
|
|
|
|
template:
|
|
|
|
src: nextcloud-fpm.ini.j2
|
|
|
|
dest: "{{ nextcloud_fpm_config_path }}/fpm.ini"
|
|
|
|
mode: "0640"
|
|
|
|
owner: "root"
|
|
|
|
group: "root"
|
|
|
|
notify:
|
|
|
|
- reload-nextcloud
|
|
|
|
|
|
|
|
- name: Template modified /etc/passwd for nextcloud container
|
|
|
|
template:
|
|
|
|
src: nextcloud-passwd.j2
|
|
|
|
dest: "{{ nextcloud_basepath }}/nextcloud-passwd"
|
|
|
|
mode: "0640"
|
|
|
|
owner: "root"
|
|
|
|
group: "root"
|
|
|
|
notify:
|
|
|
|
- reload-nextcloud
|
|
|
|
|
|
|
|
- name: Template modified /etc/passwd for nextcloud container
|
|
|
|
template:
|
|
|
|
src: nextcloud-group.j2
|
|
|
|
dest: "{{ nextcloud_basepath }}/nextcloud-group"
|
|
|
|
mode: "0640"
|
|
|
|
owner: "root"
|
|
|
|
group: "root"
|
|
|
|
notify:
|
|
|
|
- reload-nextcloud
|
|
|
|
|
|
|
|
- name: Template systemd service for nextcloud's cron job
|
|
|
|
template:
|
|
|
|
src: systemd-nextcloud-cron.service.j2
|
|
|
|
dest: /etc/systemd/system/nextcloud-cron.service
|
|
|
|
mode: "0640"
|
|
|
|
owner: root
|
|
|
|
group: root
|
2021-10-17 19:02:11 +00:00
|
|
|
when: nextcloud_background_job_mode == 'cron'
|
2021-10-13 13:46:46 +00:00
|
|
|
notify:
|
|
|
|
- reload-systemd
|
|
|
|
|
|
|
|
- name: Template timer for nextcloud's cron job
|
|
|
|
template:
|
|
|
|
src: systemd-nextcloud-cron.timer.j2
|
|
|
|
dest: /etc/systemd/system/nextcloud-cron.timer
|
|
|
|
mode: "0640"
|
|
|
|
owner: root
|
|
|
|
group: root
|
2021-10-17 19:02:11 +00:00
|
|
|
when: nextcloud_background_job_mode == 'cron'
|
2021-10-13 13:46:46 +00:00
|
|
|
notify:
|
|
|
|
- reload-systemd
|
|
|
|
|
|
|
|
- meta: flush_handlers
|
|
|
|
|
|
|
|
- name: Ensure docker container for nextcloud is running
|
|
|
|
docker_container:
|
|
|
|
name: "{{ nextcloud_container_name }}"
|
|
|
|
image: "{{ nextcloud_container_image_ref }}"
|
|
|
|
volumes: "{{ nextcloud_container_volumes }}"
|
|
|
|
labels: "{{ nextcloud_container_labels }}"
|
|
|
|
env: "{{ nextcloud_container_env }}"
|
|
|
|
networks: "{{ nextcloud_container_networks | default(omit, true) }}"
|
|
|
|
purge_networks: "{{ nextcloud_container_purge_other_networks }}"
|
|
|
|
restart_policy: "{{ nextcloud_container_restart_policy }}"
|
|
|
|
state: started
|
2021-10-17 19:02:11 +00:00
|
|
|
|
|
|
|
- name: Enable systemd timer for nextcloud cron
|
|
|
|
systemd:
|
|
|
|
name: "nextcloud-cron.timer"
|
|
|
|
enabled: yes
|
|
|
|
when: nextcloud_background_job_mode == 'cron'
|
|
|
|
|
|
|
|
- name: Ensure systemd timer for nextcloud cron is started
|
|
|
|
systemd:
|
|
|
|
name: "nextcloud-cron.timer"
|
|
|
|
state: started
|
|
|
|
when: nextcloud_background_job_mode == 'cron'
|
|
|
|
|
|
|
|
- name: Check nextcloud background job mode
|
|
|
|
community.docker.docker_container_exec:
|
|
|
|
container: "{{ nextcloud_container_name }}"
|
|
|
|
command: "{{ nextcloud_occ_command }} config:app:get core backgroundjobs_mode"
|
|
|
|
user: "{{ nextcloud_user_info.uid }}"
|
|
|
|
tty: yes
|
|
|
|
register: nextcloud_current_backgroundjob_mode
|
|
|
|
# As nextcloud might still be starting, retry this task
|
|
|
|
retries: 5
|
|
|
|
delay: 5
|
|
|
|
changed_when: false
|
|
|
|
|
|
|
|
- name: Set nextcloud background job mode to {{ nextcloud_background_job_mode }}
|
|
|
|
community.docker.docker_container_exec:
|
|
|
|
container: "{{ nextcloud_container_name }}"
|
|
|
|
command: "{{ nextcloud_occ_command }} config:app:set core backgroundjobs_mode {{ nextcloud_background_job_mode }}"
|
|
|
|
user: "{{ nextcloud_user_info.uid }}"
|
|
|
|
tty: yes
|
|
|
|
when: nextcloud_current_backgroundjob_mode.stdout != nextcloud_background_job_mode
|