aboutsummaryrefslogblamecommitdiffstats
path: root/roles/nextcloud/occ.yml
blob: 04c95390ea7068ba8200cf682403fbb4fe52edd7 (plain) (tree)















































































                                                                                                     
---

- 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'
remember that computers suck.