diff options
Diffstat (limited to 'roles/nextcloud/occ.yml')
-rw-r--r-- | roles/nextcloud/occ.yml | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/roles/nextcloud/occ.yml b/roles/nextcloud/occ.yml new file mode 100644 index 0000000..04c9539 --- /dev/null +++ b/roles/nextcloud/occ.yml @@ -0,0 +1,80 @@ +--- + +- name: maintenance:install nextcloud + ansible.builtin.command: + argv: + - php + - occ + - maintenance:install + - --database=pgsql + - "--database-name={{ nextcloud__db_name }}" + - "--database-port={{ postgresql__port }}" + - "--database-user={{ nextcloud__db_user }}" + - "--database-pass={{ nextcloud__db_password }}" + - "--database-host={{ nextcloud__db_host }}" + - "--admin-email={{ nextcloud__admin_email }}" + - "--admin-user={{ nextcloud__admin_name }}" + - "--admin-pass={{ nextcloud__admin_password }}" + chdir: "{{ httpd_pre__chroot_dir }}/nextcloud" + creates: "{{ nextcloud__data_dir }}/appdata_*" + register: nextcloud__result_maintenance_install + failed_when: + - nextcloud__result_maintenance_install.rc != 0 + - '"is not defined" is not in nextcloud__result_maintenance_install.stderr' + changed_when: + - '"is not defined" is not in nextcloud__result_maintenance_install.stderr' + +- name: set system settings + ansible.builtin.command: + cmd: "php occ config:system:set {{ item.option }} {{ item.value }}" + chdir: "{{ httpd_pre__chroot_dir }}/nextcloud" + loop: "{{ nextcloud__occ_system_settings }}" + +- name: disable applications + ansible.builtin.command: + cmd: "php occ app:enable {{ item }}" + chdir: "{{ httpd_pre__chroot_dir }}/nextcloud" + loop: "{{ nextcloud__disabled_apps }}" + register: nextcloud__result_disable_applications + changed_when: + - "'already disabled' not in nextcloud__result_disable_applications.stdout" + +- name: enable applications + ansible.builtin.command: + cmd: "php occ app:enable {{ item }}" + chdir: "{{ httpd_pre__chroot_dir }}/nextcloud" + loop: "{{ nextcloud__enabled_apps }}" + register: nextcloud__result_enable_applications + changed_when: + - "'already enabled' not in nextcloud__result_enable_applications.stdout" + +- name: enable encryption + ansible.builtin.command: + cmd: php occ encryption:enable + chdir: "{{ httpd_pre__chroot_dir }}/nextcloud" + register: nextcloud__result_enable_encryption + changed_when: + - "'already enabled' not in nextcloud__result_enable_encryption.stdout" + +- name: create application users + ansible.builtin.command: + argv: + - php + - occ + - user:add + - --password-from-env + - "--display-name={{ item.fullname }}" + - "{{ item.username }}" + chdir: "{{ httpd_pre__chroot_dir }}/nextcloud" + environment: + OC_PASS: "{{ lookup( + 'ansible.builtin.password', + 'secrets/files/passwords/' + inventory_hostname + '_nextcloud__user_' + item.username + '.txt', + )}}" + loop: "{{ nextcloud__users }}" + register: nextcloud__result_create_application_users + failed_when: + - nextcloud__result_create_application_users.rc == 1 + - '"already exists" not in nextcloud__result_create_application_users.stdout' + changed_when: + - '"already exists" not in nextcloud__result_create_application_users.stdout' |