--- - name: create zfs datasets when: nextcloud_zfs is defined block: - name: create zfs base dataset zfs: name: "{{ nextcloud_zfs.pool }}/{{ nextcloud_zfs.name }}" state: present extra_zfs_properties: "{{ nextcloud_zfs.properties | default(omit) }}" - name: create zfs volumes for instances loop: "{{ nextcloud_instances | dict2items }}" loop_control: label: "{{ item.key }} ({{ (item.value.zfs_properties | default({})).items() | map('join', '=') | join(', ') }})" zfs: name: "{{ nextcloud_zfs.pool }}/{{ nextcloud_zfs.name }}/{{ item.key }}" state: present extra_zfs_properties: "{{ item.value.zfs_properties | default(omit) }}" - name: configure nextcloud base bath set_fact: nextcloud_base_path: "{{ zfs_zpools[nextcloud_zfs.pool].mountpoint }}/{{ nextcloud_zfs.name }}" - name: create instance subdirectories when: nextcloud_zfs is not defined loop: "{{ nextcloud_instances | list }}" file: path: "{{ nextcloud_base_path }}/{{ item }}" state: directory - name: add group for nextcloud app group: name: nc-app gid: "{{ nextcloud_app_gid }}" - name: add user for nextcloud app user: name: nc-app uid: "{{ nextcloud_app_uid }}" group: nc-app password: "!" - name: create nextcloud app subdirectory loop: "{{ nextcloud_instances | list }}" file: path: "{{ nextcloud_base_path }}/{{ item }}/nextcloud" owner: "{{ nextcloud_app_uid }}" group: "{{ nextcloud_app_gid }}" state: directory - name: add group for nextcloud db group: name: nc-db gid: "{{ nextcloud_db_gid }}" - name: add user for nextcloud db user: name: nc-db uid: "{{ nextcloud_db_uid }}" group: nc-db password: "!" - name: create nextcloud database subdirectory loop: "{{ nextcloud_instances | dict2items}}" loop_control: label: "{{ item.key }} ({{ item.value.database.type }})" file: path: "{{ nextcloud_base_path }}/{{ item.key }}/{{ item.value.database.type }}" owner: "{{ nextcloud_db_uid }}" group: "{{ nextcloud_db_gid }}" state: directory - name: create auxiliary config directory loop: "{{ nextcloud_instances | list }}" file: path: "{{ nextcloud_base_path }}/{{ item }}/config" state: directory - name: create apache vhost config loop: "{{ nextcloud_instances | list }}" template: src: apache-site.conf.j2 dest: "{{ nextcloud_base_path }}/{{ item }}/config/apache-site.conf" - name: configure apache to run on port 8080 only loop: "{{ nextcloud_instances | list }}" copy: content: | Listen 8080 dest: "{{ nextcloud_base_path }}/{{ item }}/config/ports.conf" - name: build custom image loop: "{{ nextcloud_instances | dict2items }}" loop_control: label: "{{ item.key }}" when: "'custom_image' in item.value" include_tasks: custom-image.yml - name: generate pod manifests loop: "{{ nextcloud_instances | dict2items }}" loop_control: label: "{{ item.key }}" template: src: "pod-with-{{ item.value.database.type }}.yml.j2" dest: "/etc/kubernetes/manifests/nextcloud-{{ item.key }}.yml" mode: 0600 - name: install cron trigger script loop: "{{ nextcloud_instances | list }}" template: src: run-cron.sh.j2 dest: "{{ nextcloud_base_path }}/{{ item }}/config/run-cron.sh" mode: 0755 - name: install template systemd unit for cron trigger template: src: cron@.service.j2 dest: /etc/systemd/system/nextcloud-cron@.service - name: install systemd timer unit loop: "{{ nextcloud_instances | list }}" template: src: cron-.timer.j2 dest: "/etc/systemd/system/nextcloud-cron-{{ item }}.timer" - name: start/enable cron trigger systemd timer loop: "{{ nextcloud_instances | list }}" systemd: daemon_reload: yes name: "nextcloud-cron-{{ item }}.timer" state: started enabled: yes - name: configure nginx vhost loop: "{{ nextcloud_instances | dict2items }}" include_role: name: nginx/vhost vars: nginx_vhost: name: "nextcloud-{{ item.key }}" template: generic-proxy-no-buffering-with-acme acme: true hostnames: "{{ item.value.hostnames }}" client_max_body_size: "512M" proxy_pass: "http://127.0.0.1:{{ item.value.port }}" proxy_redirect: - redirect: "http://$host/" replacement: "https://$host/" - redirect: "http://$host:8080/" replacement: "https://$host/" - name: install management scripts loop: - nextcloud-upgrade - nextcloud-occ template: src: "{{ item }}.j2" dest: "/usr/local/bin/{{ item }}" mode: 0755 ## TODO: # do this automatically! - name: print info for new instance loop: "{{ nextcloud_instances | dict2items }}" loop_control: label: "{{ item.key }}" when: "'new' in item.value and item.value.new" pause: seconds: 5 prompt: | ************* {{ item.key }} is a new instance ** ** Go to https://{{ item.value.hostnames[0] }} and finalize the ** installation. After that run the following commands: ** ** $ nextcloud-occ {{ item.key }} db:add-missing-indices ** $ nextcloud-occ {{ item.key }} db:convert-filecache-bigint ** ** Also please add the following option to the file ** "{{ nextcloud_base_path }}/{{ item.key }}/nextcloud/config/config.php" ** ** 'overwriteprotocol' => 'https', ** ****************************************