2020-07-11 07:38:45 +00:00
|
|
|
- name: Create Nextcloud network
|
2023-05-04 03:42:55 +00:00
|
|
|
community.general.docker_network:
|
2020-07-11 07:38:45 +00:00
|
|
|
name: "{{ nextcloud_container }}"
|
|
|
|
|
2020-07-10 01:53:07 +00:00
|
|
|
- name: Start Nextcloud's database container
|
2023-05-04 03:42:55 +00:00
|
|
|
community.general.docker_container:
|
2020-07-10 01:53:07 +00:00
|
|
|
name: "{{ nextcloud_dbcontainer }}"
|
|
|
|
image: mariadb:{{ nextcloud_dbversion }}
|
2020-07-29 04:43:31 +00:00
|
|
|
state: started
|
2020-07-02 05:35:01 +00:00
|
|
|
restart_policy: always
|
2020-07-10 01:53:07 +00:00
|
|
|
volumes: "{{ nextcloud_dbroot }}:/var/lib/mysql"
|
2020-07-11 07:38:45 +00:00
|
|
|
networks_cli_compatible: true
|
|
|
|
networks:
|
|
|
|
- name: "{{ nextcloud_container }}"
|
2020-07-02 05:35:01 +00:00
|
|
|
env:
|
|
|
|
MYSQL_RANDOM_ROOT_PASSWORD: "true"
|
|
|
|
MYSQL_DATABASE: "{{ nextcloud_dbname }}"
|
|
|
|
MYSQL_USER: "{{ nextcloud_dbuser }}"
|
|
|
|
MYSQL_PASSWORD: "{{ nextcloud_dbpass }}"
|
|
|
|
|
|
|
|
- name: Start Nextcloud container
|
2023-05-04 03:42:55 +00:00
|
|
|
community.general.docker_container:
|
2020-07-10 01:53:07 +00:00
|
|
|
name: "{{ nextcloud_container }}"
|
2020-07-02 05:35:01 +00:00
|
|
|
image: nextcloud:{{ nextcloud_version }}
|
2020-07-29 04:43:31 +00:00
|
|
|
state: started
|
2020-07-02 05:35:01 +00:00
|
|
|
restart_policy: always
|
2020-07-10 01:53:07 +00:00
|
|
|
volumes: "{{ nextcloud_root }}:/var/www/html"
|
2020-07-11 07:38:45 +00:00
|
|
|
networks_cli_compatible: true
|
|
|
|
networks:
|
|
|
|
- name: "{{ nextcloud_container }}"
|
|
|
|
- name: traefik
|
2023-06-19 03:52:10 +00:00
|
|
|
env:
|
|
|
|
PHP_MEMORY_LIMIT: 1024M
|
2020-07-11 07:38:45 +00:00
|
|
|
labels:
|
|
|
|
traefik.http.routers.nextcloud.rule: "Host(`{{ nextcloud_domain }}`)"
|
2020-07-17 05:28:02 +00:00
|
|
|
traefik.http.routers.nextcloud.entrypoints: websecure
|
2020-09-04 06:14:12 +00:00
|
|
|
traefik.http.routers.nextcloud.tls.certresolver: letsencrypt
|
2020-09-16 03:06:33 +00:00
|
|
|
traefik.http.routers.nextcloud.middlewares: "securehttps@file,nextcloud-webdav"
|
2020-07-28 05:04:23 +00:00
|
|
|
traefik.http.middlewares.nextcloud-webdav.redirectregex.regex: "https://(.*)/.well-known/(card|cal)dav"
|
|
|
|
traefik.http.middlewares.nextcloud-webdav.redirectregex.replacement: "https://${1}/remote.php/dav/"
|
|
|
|
traefik.http.middlewares.nextcloud-webdav.redirectregex.permanent: "true"
|
2020-07-11 07:38:45 +00:00
|
|
|
traefik.docker.network: traefik
|
|
|
|
traefik.enable: "true"
|
2020-07-02 05:35:01 +00:00
|
|
|
|
2020-08-01 02:30:20 +00:00
|
|
|
- name: Grab Nextcloud database container information
|
2023-05-04 03:42:55 +00:00
|
|
|
community.general.docker_container_info:
|
2020-08-01 02:30:20 +00:00
|
|
|
name: "{{ nextcloud_dbcontainer }}"
|
|
|
|
register: nextcloud_dbinfo
|
|
|
|
|
2020-07-07 21:21:04 +00:00
|
|
|
- name: Grab Nextcloud container information
|
2023-05-04 03:42:55 +00:00
|
|
|
community.general.docker_container_info:
|
2020-07-10 01:53:07 +00:00
|
|
|
name: "{{ nextcloud_container }}"
|
2020-07-07 21:21:04 +00:00
|
|
|
register: nextcloud_info
|
|
|
|
|
|
|
|
- name: Wait for Nextcloud to become available
|
2023-05-04 03:42:55 +00:00
|
|
|
ansible.builtin.wait_for:
|
2020-07-11 07:38:45 +00:00
|
|
|
host: "{{ nextcloud_info.container.NetworkSettings.Networks.traefik.IPAddress }}"
|
2020-07-07 21:21:04 +00:00
|
|
|
port: 80
|
|
|
|
|
|
|
|
- name: Check Nextcloud status
|
2023-05-04 03:42:55 +00:00
|
|
|
ansible.builtin.command: "docker exec --user www-data {{ nextcloud_container }}
|
2020-07-07 21:21:04 +00:00
|
|
|
php occ status"
|
|
|
|
register: nextcloud_status
|
|
|
|
args:
|
2020-07-10 01:53:07 +00:00
|
|
|
removes: "{{ nextcloud_root }}/config/CAN_INSTALL"
|
2020-07-07 21:21:04 +00:00
|
|
|
|
2020-08-01 02:30:20 +00:00
|
|
|
- name: Wait for Nextcloud database to become available
|
2023-05-04 03:42:55 +00:00
|
|
|
ansible.builtin.wait_for:
|
2020-08-01 02:30:20 +00:00
|
|
|
host: "{{ nextcloud_dbinfo.container.NetworkSettings.Networks.nextcloud.IPAddress }}"
|
|
|
|
port: 3306
|
|
|
|
|
2020-07-07 21:21:04 +00:00
|
|
|
- name: Install Nextcloud
|
2023-05-04 03:42:55 +00:00
|
|
|
ansible.builtin.command: 'docker exec --user www-data {{ nextcloud_container }}
|
2020-07-07 21:21:04 +00:00
|
|
|
php occ maintenance:install
|
2020-07-09 04:09:48 +00:00
|
|
|
--database "mysql"
|
2020-07-10 01:53:07 +00:00
|
|
|
--database-host "{{ nextcloud_dbcontainer }}"
|
2020-07-09 04:09:48 +00:00
|
|
|
--database-name "{{ nextcloud_dbname }}"
|
|
|
|
--database-user "{{ nextcloud_dbuser }}"
|
|
|
|
--database-pass "{{ nextcloud_dbpass }}"
|
2020-07-07 21:21:04 +00:00
|
|
|
--admin-user "{{ nextcloud_admin }}"
|
|
|
|
--admin-pass "{{ nextcloud_pass }}"'
|
|
|
|
register: nextcloud_install
|
|
|
|
when:
|
|
|
|
- nextcloud_status.stdout[:26] == "Nextcloud is not installed"
|
|
|
|
- nextcloud_domain is defined
|
|
|
|
|
2020-07-12 06:11:02 +00:00
|
|
|
- name: Set Nextcloud's Trusted Proxy
|
2023-05-04 03:42:55 +00:00
|
|
|
ansible.builtin.command: 'docker exec --user www-data {{ nextcloud_container }}
|
2020-07-12 06:11:02 +00:00
|
|
|
php occ config:system:set trusted_proxies 0
|
|
|
|
--value="{{ traefik_name }}"'
|
|
|
|
when: nextcloud_install.changed
|
|
|
|
|
2020-07-07 21:21:04 +00:00
|
|
|
- name: Set Nextcloud's Trusted Domain
|
2023-05-04 03:42:55 +00:00
|
|
|
ansible.builtin.command: 'docker exec --user www-data {{ nextcloud_container }}
|
2020-07-07 21:21:04 +00:00
|
|
|
php occ config:system:set trusted_domains 0
|
|
|
|
--value="{{ nextcloud_domain }}"'
|
|
|
|
when: nextcloud_install.changed
|
|
|
|
|
|
|
|
- name: Preform Nextcloud database maintenance
|
2023-05-04 03:42:55 +00:00
|
|
|
ansible.builtin.command: "docker exec --user www-data {{ nextcloud_container }} {{ item }}"
|
2020-07-02 05:35:01 +00:00
|
|
|
loop:
|
2020-07-07 21:21:04 +00:00
|
|
|
- "php occ maintenance:mode --on"
|
|
|
|
- "php occ db:add-missing-indices"
|
|
|
|
- "php occ db:convert-filecache-bigint"
|
|
|
|
- "php occ maintenance:mode --off"
|
|
|
|
when: nextcloud_install.changed
|
2020-07-07 21:44:25 +00:00
|
|
|
|
2023-06-19 03:52:10 +00:00
|
|
|
- name: Install Nextcloud background jobs cron
|
|
|
|
ansible.builtin.cron:
|
|
|
|
name: Nextcloud background job
|
|
|
|
minute: "*/5"
|
|
|
|
job: "/usr/bin/docker exec -u www-data nextcloud /usr/local/bin/php -f /var/www/html/cron.php"
|
|
|
|
user: root
|
|
|
|
|
2020-07-07 21:44:25 +00:00
|
|
|
- name: Remove Nextcloud's CAN_INSTALL file
|
2023-05-04 03:42:55 +00:00
|
|
|
ansible.builtin.file:
|
2020-07-10 01:53:07 +00:00
|
|
|
path: "{{ nextcloud_root }}/config/CAN_INSTALL"
|
2020-07-07 21:44:25 +00:00
|
|
|
state: absent
|