nc_setup.yml 6.5 KB

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