aboutsummaryrefslogtreecommitdiffstats
path: root/roles/nextcloud/occ.yml
blob: e6f41f11aa3af0ebbec4138a3e3369d74795f93e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
---

- name: maintenance:install nextcloud
  ansible.builtin.command:
    argv:
      - "{{ nextcloud__php_bin }}"
      - 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: "{{ nextcloud__php_bin }} 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: "{{ nextcloud__php_bin }} 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: "{{ nextcloud__php_bin }} 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: "{{ nextcloud__php_bin }} 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:
      - "{{ nextcloud__php_bin }}"
      - occ
      - user:add
      - --password-from-env
      - "--display-name={{ item.display_name }}"
      - "{{ 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'

- name: update application users
  ansible.builtin.command:
    argv:
      - "{{ nextcloud__php_bin }}"
      - occ
      - user:setting
      - "{{ item.0.username }}"
      - settings
      - "{{ item.1 }}"
      - "{{ item.0[item.1] }}"
    chdir: "{{ httpd_pre__chroot_dir }}/nextcloud"
  with_nested:
    - "{{ nextcloud__users }}"
    - ["email"]
remember that computers suck.