nc_setup.yml 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. ---
  2. - name: Setup... Set APCU config for Nextcloud
  3. copy:
  4. dest: "{{ http_webroot }}/nextcloud/config/apcu.config.php"
  5. src: files/apcu.config.php
  6. owner: "{{ nextcloud_websrv_user }}"
  7. group: "{{ nextcloud_websrv_group }}"
  8. mode: 0640
  9. - name: Setup... Set custom_apps config for Nextcloud
  10. copy:
  11. dest: "{{ http_webroot }}/nextcloud/config/apps.config.php"
  12. src: files/apps.config.php
  13. owner: "{{ nextcloud_websrv_user }}"
  14. group: "{{ nextcloud_websrv_group }}"
  15. mode: 0640
  16. - name: Setup... Check disabled apps list
  17. shell: "{{ php_bin }} occ app:list --no-warnings | grep -A30 'Disabled' | grep -v 'Disabled' | cut -d'-' -f2 | cut -d':' -f1 | grep -v 'encryption'"
  18. args:
  19. chdir: "{{ http_webroot }}/nextcloud"
  20. become_user: "{{ nextcloud_websrv_user }}"
  21. become: true
  22. register: nc_apps_list
  23. failed_when: nc_apps_list.rc >= 2
  24. - name: Setup... Enable all disabled apps
  25. become_user: "{{ nextcloud_websrv_user }}"
  26. become: true
  27. shell: "{{ php_bin }} occ app:enable {{ item }}"
  28. args:
  29. chdir: "{{ http_webroot }}/nextcloud"
  30. with_items: "{{ nc_apps_list.stdout_lines }}"
  31. when: nc_apps_list.rc == 0
  32. - name: Setup... Applying default settings
  33. become_user: "{{ nextcloud_websrv_user }}"
  34. become: true
  35. shell: "{{ php_bin }} occ {{ item }}"
  36. args:
  37. chdir: "{{ http_webroot }}/nextcloud"
  38. loop:
  39. - "config:system:set loglevel --value='{{ nc_loglevel }}'"
  40. - "config:system:set log_type --value=file"
  41. - "config:system:set logfile --value='{{ nc_data_dir }}/nextcloud.log'"
  42. - "config:system:set log_rotate_size --value='{{ nc_log_rotate_size }}'"
  43. - "config:app:set admin_audit logfile --value='{{ nc_data_dir }}/audit.log'"
  44. - "config:system:set log.condition apps 0 --value='admin_audit'"
  45. loop_control:
  46. pause: 2
  47. - name: Setup... Applying preview settings
  48. become_user: "{{ nextcloud_websrv_user }}"
  49. become: true
  50. shell: "{{ php_bin }} occ {{ item }}"
  51. args:
  52. chdir: "{{ http_webroot }}/nextcloud"
  53. loop:
  54. - "config:system:set preview_max_x --value='2048'"
  55. - "config:system:set preview_max_y --value='2048'"
  56. - "config:app:set preview jpeg_quality --value='60'"
  57. - "config:system:set jpeg_quality --value='60'"
  58. - "config:system:delete enabledPreviewProviders"
  59. - "config:system:set enabledPreviewProviders 1 --value='OC\\Preview\\Image'"
  60. - "config:system:set enabledPreviewProviders 2 --value='OC\\Preview\\MarkDown'"
  61. - "config:system:set enabledPreviewProviders 3 --value='OC\\Preview\\MP3'"
  62. - "config:system:set enabledPreviewProviders 4 --value='OC\\Preview\\TXT'"
  63. - "config:system:set enabledPreviewProviders 5 --value='OC\\Preview\\OpenDocument'"
  64. - "config:system:set enabledPreviewProviders 6 --value='OC\\Preview\\Movie'"
  65. - "config:system:set enable_previews --value=true --type=boolean"
  66. loop_control:
  67. pause: 2
  68. - name: Setup... Applying other settings
  69. become_user: "{{ nextcloud_websrv_user }}"
  70. become: true
  71. shell: "{{ php_bin }} occ {{ item }}"
  72. args:
  73. chdir: "{{ http_webroot }}/nextcloud"
  74. loop:
  75. - "config:system:set upgrade.disable-web --type=bool --value=true"
  76. - "config:system:set trashbin_retention_obligation --value='auto, 30'"
  77. - "config:system:set versions_retention_obligation --value='auto, 30'"
  78. - "config:system:set activity_expire_days --value='30'"
  79. - "config:system:set simpleSignUpLink.shown --type=bool --value=false"
  80. #- "config:system:set share_folder --value='/Shared'"
  81. loop_control:
  82. pause: 2
  83. - name: Setup... Set Nextcloud system settings in config.php
  84. become_user: "{{ nextcloud_websrv_user }}"
  85. become: true
  86. shell: "{{ php_bin }} occ config:system:set {{ item.name }} --value={{ item.value }}"
  87. args:
  88. chdir: "{{ http_webroot }}/nextcloud"
  89. with_items:
  90. - "{{ nextcloud_config_settings }}"
  91. - name: Setup... Set Redis setup
  92. template:
  93. dest: "{{ http_webroot }}/nextcloud/config/redis.config.php"
  94. src: redis.config.php.j2
  95. owner: "{{ nextcloud_websrv_user }}"
  96. group: "{{ nextcloud_websrv_group }}"
  97. mode: 0640
  98. - name: Setup... Install Nextcloud Apps
  99. become_user: "{{ nextcloud_websrv_user }}"
  100. become: true
  101. shell: "{{ php_bin }} occ app:install {{ item }}"
  102. args:
  103. chdir: "{{ http_webroot }}/nextcloud"
  104. with_items: "{{ nextcloud_apps }}"
  105. register: nc_apps_installed
  106. failed_when: nc_apps_installed.rc >= 2
  107. - name: Setup... Set Cron method to Crontab
  108. become_user: "{{ nextcloud_websrv_user }}"
  109. become: true
  110. shell: "{{ php_bin }} occ background:cron"
  111. args:
  112. chdir: "{{ http_webroot }}/nextcloud"
  113. when: (nc_background_cron | bool)
  114. ###- name: Setup... "[NC] Set Custom Mimetype"
  115. ### ansible.builtin.copy:
  116. ### dest: "{{ nextcloud_webroot }}/config/mimetypemapping.json"
  117. ### src: files/nextcloud_custom_mimetypemapping.json
  118. ### mode: 0640
  119. ###
  120. - name: Setup... Collabora settings ownership
  121. file:
  122. path: "{{ item }}"
  123. recurse: true
  124. owner: cool
  125. group: cool
  126. with_items:
  127. - /opt/cool/systemplate/etc/hosts
  128. - /opt/cool/systemplate/etc/resolv.conf
  129. - /etc/coolwsd
  130. when: nc_collabora
  131. #- name: Main... Setting stronger directories ownership
  132. # file:
  133. # path: "{{ item }}"
  134. # state: directory
  135. # owner: "{{ nextcloud_websrv_user }}"
  136. # group: "{{ nextcloud_websrv_group }}"
  137. # recurse: yes
  138. # mode: 0750
  139. # with_items:
  140. # - "{{ nc_data_dir }}"
  141. # - "{{ http_webroot }}"
  142. #- name: Setup... Ensure Nextcloud directories are 0750
  143. # shell: find {{ http_webroot }}/nextcloud -type d -exec chmod -c 0750 {} \;
  144. # register: nc_installation_chmod_result
  145. # changed_when: "nc_installation_chmod_result.stdout != \"\""
  146. #
  147. #- name: Setup... Ensure Nextcloud files are 0640
  148. # shell: find {{ http_webroot }}/nextcloud -type f -exec chmod -c 0640 {} \;
  149. # register: nc_installation_chmod_result
  150. # changed_when: "nc_installation_chmod_result.stdout != \"\""
  151. ###- name: Setup... "[NC] Setting stronger directory ownership"
  152. ### ansible.builtin.file:
  153. ### path: "{{ nextcloud_webroot }}/{{ item }}/"
  154. ### recurse: true
  155. ### owner: "{{ nextcloud_websrv_user }}"
  156. ### group: "{{ nextcloud_websrv_group }}"
  157. ### state: directory
  158. ### with_items:
  159. ### - apps
  160. ### - custom_apps
  161. ### - config
  162. ### - themes
  163. ### - updater