2021-10-13 13:46:46 +00:00
|
|
|
---
|
|
|
|
|
|
|
|
- name: Create nextcloud user
|
2024-07-27 19:37:34 +00:00
|
|
|
ansible.builtin.user:
|
2021-10-13 13:46:46 +00:00
|
|
|
name: "{{ nextcloud_user }}"
|
|
|
|
state: present
|
|
|
|
system: yes
|
|
|
|
register: nextcloud_user_info
|
|
|
|
|
2021-10-24 10:38:43 +00:00
|
|
|
- name: Map nextcloud socket path if defined
|
2024-07-27 19:37:34 +00:00
|
|
|
ansible.builtin.set_fact:
|
2021-10-24 10:38:43 +00:00
|
|
|
nextcloud_paths: "{{ nextcloud_paths + [ socket_dir ] }}"
|
|
|
|
nextcloud_container_base_volumes: "{{ nextcloud_container_base_volumes + [ socket_map ] }}"
|
|
|
|
vars:
|
|
|
|
socket_dir:
|
|
|
|
path: "{{ nextcloud_socket_path }}"
|
|
|
|
mode: "0755"
|
|
|
|
owner: "{{ nextcloud_user_info.uid|default(nextcloud_user) }}"
|
|
|
|
group: "{{ nextcloud_user_info.uid|default(nextcloud_user) }}"
|
|
|
|
socket_map: "{{ nextcloud_socket_path }}:{{ nextcloud_container_php_socket_path }}:z"
|
|
|
|
when: nextcloud_socket_path is defined and nextcloud_socket_path is string
|
|
|
|
|
2021-10-13 13:46:46 +00:00
|
|
|
- name: Ensure nextcloud directories exist and have correct permissions
|
2024-07-27 19:37:34 +00:00
|
|
|
ansible.builtin.file:
|
2021-10-13 13:46:46 +00:00
|
|
|
path: "{{ item.path }}"
|
|
|
|
state: directory
|
|
|
|
mode: "{{ item.mode }}"
|
|
|
|
owner: "{{ item.owner }}"
|
|
|
|
group: "{{ item.group }}"
|
|
|
|
loop: "{{ nextcloud_paths }}"
|
|
|
|
|
2024-10-04 17:34:31 +00:00
|
|
|
- name: Ensure docker container image '{{ nextcloud_container_image_ref }}' for nextcloud is pulled
|
2024-07-27 19:37:34 +00:00
|
|
|
community.docker.docker_image:
|
2021-10-13 13:46:46 +00:00
|
|
|
name: "{{ nextcloud_container_image_ref }}"
|
|
|
|
state: present
|
|
|
|
source: pull
|
|
|
|
force_source: "{{ nextcloud_container_image_force_source }}"
|
|
|
|
|
|
|
|
- name: Template OpCache configuration
|
2024-07-27 19:37:34 +00:00
|
|
|
ansible.builtin.template:
|
2021-10-13 13:46:46 +00:00
|
|
|
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
|
2024-07-27 19:37:34 +00:00
|
|
|
ansible.builtin.template:
|
2021-10-13 13:46:46 +00:00
|
|
|
src: nextcloud-fpm.ini.j2
|
|
|
|
dest: "{{ nextcloud_fpm_config_path }}/fpm.ini"
|
|
|
|
mode: "0640"
|
|
|
|
owner: "root"
|
|
|
|
group: "root"
|
|
|
|
notify:
|
|
|
|
- reload-nextcloud
|
|
|
|
|
2021-10-24 10:38:43 +00:00
|
|
|
- name: Template PHP FPM docker-specific configuration
|
2024-07-27 19:37:34 +00:00
|
|
|
ansible.builtin.template:
|
2021-10-24 10:38:43 +00:00
|
|
|
src: nextcloud-fpm-docker.ini.j2
|
|
|
|
dest: "{{ nextcloud_fpm_config_path }}/fpm-docker.ini"
|
|
|
|
mode: "0640"
|
|
|
|
owner: "root"
|
|
|
|
group: "root"
|
|
|
|
notify:
|
|
|
|
- reload-nextcloud
|
|
|
|
|
2021-10-13 13:46:46 +00:00
|
|
|
- name: Template modified /etc/passwd for nextcloud container
|
2024-07-27 19:37:34 +00:00
|
|
|
ansible.builtin.template:
|
2021-10-13 13:46:46 +00:00
|
|
|
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
|
2024-07-27 19:37:34 +00:00
|
|
|
ansible.builtin.template:
|
2021-10-13 13:46:46 +00:00
|
|
|
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
|
2024-07-27 19:37:34 +00:00
|
|
|
ansible.builtin.template:
|
2021-10-13 13:46:46 +00:00
|
|
|
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
|
2024-07-27 19:37:34 +00:00
|
|
|
ansible.builtin.template:
|
2021-10-13 13:46:46 +00:00
|
|
|
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
|
|
|
|
|
2021-10-24 12:12:05 +00:00
|
|
|
- name: Flush handlers now to ensure systemd can know about the timer before it's enabled
|
2024-07-27 19:37:34 +00:00
|
|
|
ansible.builtin.meta: flush_handlers
|
2021-10-13 13:46:46 +00:00
|
|
|
|
|
|
|
- name: Ensure docker container for nextcloud is running
|
2024-07-27 19:37:34 +00:00
|
|
|
community.docker.docker_container:
|
2021-10-13 13:46:46 +00:00
|
|
|
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
|
2024-07-27 19:37:34 +00:00
|
|
|
ansible.builtin.systemd:
|
2021-10-17 19:02:11 +00:00
|
|
|
name: "nextcloud-cron.timer"
|
|
|
|
enabled: yes
|
|
|
|
when: nextcloud_background_job_mode == 'cron'
|
|
|
|
|
|
|
|
- name: Ensure systemd timer for nextcloud cron is started
|
2024-07-27 19:37:34 +00:00
|
|
|
ansible.builtin.systemd:
|
2021-10-17 19:02:11 +00:00
|
|
|
name: "nextcloud-cron.timer"
|
|
|
|
state: started
|
|
|
|
when: nextcloud_background_job_mode == 'cron'
|
|
|
|
|
2021-10-24 13:50:32 +00:00
|
|
|
- name: Configure nextcloud
|
2024-07-27 19:37:34 +00:00
|
|
|
ansible.builtin.include_tasks:
|
2021-10-24 13:50:32 +00:00
|
|
|
file: configure-single-setting.yml
|
|
|
|
vars:
|
|
|
|
key: "{{ item.key | replace('[', '.') | replace(']', '.') }}"
|
|
|
|
value: "{{ item.value }}"
|
|
|
|
loop: "{{ lookup('ansible.utils.to_paths', nextcloud_config ) | dict2items }}"
|