diff --git a/roles/nextcloud/tasks/main.yml b/roles/nextcloud/tasks/main.yml index 7273e4e..fa00782 100644 --- a/roles/nextcloud/tasks/main.yml +++ b/roles/nextcloud/tasks/main.yml @@ -20,29 +20,10 @@ owner: "33" group: "33" register: cfg -- name: Run nextcloud container - become: true - community.docker.docker_container: - name: nextcloud-{{ item }} - image: nextcloud:30.0.2-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 +- include_tasks: start_server.yml loop: [1, 2] + loop_control: + loop_var: server_idx - name: Schedule background jobs become: true ansible.builtin.cron: diff --git a/roles/nextcloud/tasks/start_server.yml b/roles/nextcloud/tasks/start_server.yml new file mode 100644 index 0000000..639e346 --- /dev/null +++ b/roles/nextcloud/tasks/start_server.yml @@ -0,0 +1,41 @@ +--- +- name: Disable server in haproxy + become: true + community.general.haproxy: + socket: /run/haproxy/admin.sock + state: disabled + drain: true + wait: true + backend: nextcloud + host: s{{ server_idx }} + fail_on_not_found: true +- name: Run nextcloud container + become: true + community.docker.docker_container: + name: nextcloud-{{ server_idx }} + image: nextcloud:30.0.2-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 +- name: Enable server in haproxy + become: true + community.general.haproxy: + socket: /run/haproxy/admin.sock + state: enabled + backend: nextcloud + host: s{{ server_idx }} + fail_on_not_found: true