Playbooks to a new Lilik
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

196 lines
5.6 KiB

  1. ---
  2. - name: 'install requirements'
  3. apt:
  4. pkg:
  5. - 'postgresql'
  6. - 'postgresql-contrib'
  7. - 'python3-psycopg2'
  8. - 'ca-certificates'
  9. - 'redis-server'
  10. - 'rabbitmq-server'
  11. state: 'present'
  12. update_cache: true
  13. cache_valid_time: 3600
  14. - name: 'USERS | create onlyoffice'
  15. user:
  16. name: 'onlyoffice'
  17. system: true
  18. home: '/opt/onlyoffice'
  19. - name: 'USERS | add www-data to onlyoffice'
  20. user:
  21. name: 'www-data'
  22. groups: 'onlyoffice'
  23. append: true
  24. - block:
  25. - name: 'PGSQL | create onlyoffice DB'
  26. postgresql_db:
  27. name: 'onlyoffice'
  28. - name: 'PGSQL | create onlyoffice DB user'
  29. postgresql_user:
  30. name: 'onlyoffice'
  31. db: 'onlyoffice'
  32. # password: '{{ onlyoffice_pgsql_passwd.passwd }}'
  33. priv: 'ALL'
  34. become: true
  35. become_method: 'su'
  36. become_user: 'postgres'
  37. #- name: 'install onlyoffice'
  38. # apt:
  39. # pkg: 'onlyoffice-documentserver'
  40. # state: 'present'
  41. # update_cache: true
  42. # cache_valid_time: 3600
  43. - name: 'create onlyoffice folders'
  44. file:
  45. path: '{{ item }}'
  46. state: 'directory'
  47. owner: 'onlyoffice'
  48. group: 'onlyoffice'
  49. loop:
  50. - '/opt/onlyoffice'
  51. - '/etc/onlyoffice'
  52. - '/etc/onlyoffice/documentserver/'
  53. - '/etc/onlyoffice/documentserver/log4js'
  54. - '/var/lib/onlyoffice'
  55. - '/var/lib/onlyoffice/documentserver/'
  56. - name: 'extract onlyoffice documentserver'
  57. unarchive:
  58. remote_src: true
  59. src: '/opt/documentserver.tar.gz'
  60. dest: '/opt/onlyoffice'
  61. owner: 'onlyoffice'
  62. group: 'onlyoffice'
  63. mode: '0750'
  64. # creates: '/opt/onlyoffice/documentserver/'
  65. - name: 'PGSQL | init DB'
  66. shell:
  67. cmd: 'psql -d onlyoffice < /opt/onlyoffice/documentserver/server/schema/postgresql/createdb.sql'
  68. register: onlyoffice_pgsql_init
  69. changed_when: onlyoffice_pgsql_init.stdout != 'CREATE TABLE\nCREATE TABLE\nCREATE FUNCTION'
  70. become: true
  71. become_method: 'su'
  72. become_user: 'onlyoffice'
  73. - name: 'ONLYOFFICE | copy configs'
  74. copy:
  75. src: '{{ item.src }}'
  76. dest: '/etc/onlyoffice/documentserver/{{ item.dest }}'
  77. notify: 'restart onlyoffice'
  78. loop:
  79. - { src: 'production-linux.json', dest: 'production-linux.json' }
  80. - { src: 'production.json', dest: 'log4js/production.json' }
  81. - { src: 'default.json', dest: 'default.json' }
  82. - name: 'ONLYOFFICE | generate integration secret'
  83. gen_passwd: 'length=32'
  84. register: 'onlyoffice_integration_secret'
  85. no_log: true
  86. - name: 'ONLYOFFICE | template configs'
  87. template:
  88. src: 'local.json.j2'
  89. dest: '/etc/onlyoffice/documentserver/local.json'
  90. notify: 'restart onlyoffice'
  91. no_log: true
  92. - block:
  93. - name: 'ONLYOFFICE | generate fonts'
  94. shell:
  95. cmd: |
  96. ${PWD}/server/tools/allfontsgen \
  97. --input="${PWD}/core-fonts" \
  98. --allfonts-web="${PWD}/sdkjs/common/AllFonts.js" \
  99. --allfonts="${PWD}/server/FileConverter/bin/AllFonts.js" \
  100. --images="${PWD}/sdkjs/common/Images" \
  101. --selection="${PWD}/server/FileConverter/bin/font_selection.bin" \
  102. --output-web='fonts' \
  103. --use-system="true"
  104. chdir: '/opt/onlyoffice/documentserver'
  105. notify: 'restart onlyoffice'
  106. - name: 'ONLYOFFICE | generate themes'
  107. shell:
  108. cmd: |
  109. ${PWD}/server/tools/allthemesgen \
  110. --converter-dir="${PWD}/server/FileConverter/bin" \
  111. --src="${PWD}/sdkjs/slide/themes" \
  112. --output="${PWD}/sdkjs/common/Images"
  113. chdir: '/opt/onlyoffice/documentserver'
  114. notify: 'restart onlyoffice'
  115. environment:
  116. LD_LIBRARY_PATH: '/opt/onlyoffice/documentserver/server/FileConverter/bin'
  117. become: true
  118. become_method: 'su'
  119. become_user: 'onlyoffice'
  120. - name: 'SYSTEMD | create services'
  121. copy:
  122. src: '{{ item }}'
  123. dest: '/etc/systemd/system/{{ item }}'
  124. loop:
  125. - 'onlyoffice-ds-docservice.service'
  126. - 'onlyoffice-ds-converter.service'
  127. - 'onlyoffice-ds-spellchecker.service'
  128. - 'onlyoffice-ds.target'
  129. notify: 'restart onlyoffice'
  130. - name: 'NGINX | create onlyoffice upstreams'
  131. copy:
  132. src: 'onlyoffice-ds-http.conf'
  133. dest: '/etc/nginx/conf.d/onlyoffice-ds-http.conf'
  134. notify: 'reload nginx'
  135. - name: 'NGINX | create onlyoffice locations'
  136. copy:
  137. src: '{{ item }}'
  138. dest: '/etc/nginx/locations/{{ onlyoffice_nginx_fqdn }}/{{ item }}'
  139. loop:
  140. - 'onlyoffice-ds-common.conf'
  141. - 'onlyoffice-ds-docservice.conf'
  142. - 'onlyoffice-ds-spellchecker.conf'
  143. notify: 'reload nginx'
  144. - block:
  145. - name: 'NEXTCLOUD | get installed apps'
  146. import_tasks: 'roles/nextcloud/tasks/occ.yaml'
  147. vars:
  148. occ_args: 'app:list --output json'
  149. - name: 'NEXTCLOUD | install onlyoffice integration'
  150. import_tasks: 'roles/nextcloud/tasks/occ.yaml'
  151. vars:
  152. occ_args: 'app:install onlyoffice --no-interaction'
  153. nojson: true
  154. when:
  155. - not 'onlyoffice' in occ_out.enabled
  156. - not 'onlyoffice' in occ_out.disabled
  157. - name: 'NEXTCLOUD | enable onlyoffice integration'
  158. import_tasks: 'roles/nextcloud/tasks/occ.yaml'
  159. vars:
  160. occ_args: 'app:enable onlyoffice'
  161. nojson: true
  162. when:
  163. - true and 'onlyoffice' in occ_out.disabled
  164. - name: 'NEXTCLOUD | configure onlyoffice integration'
  165. occ:
  166. command: 'config:app:set'
  167. key: 'onlyoffice {{ item.key }}'
  168. value: '{{ item.value }}'
  169. loop: '{{ onlyoffice_nextcloud_settings|dict2items }}'
  170. vars:
  171. onlyoffice_nextcloud_settings:
  172. DocumentServerUrl: 'https://{{ onlyoffice_nginx_fqdn }}/'
  173. jwt_secret: '{{ onlyoffice_integration_secret.passwd }}'
  174. no_log: true
  175. delegate_to: '{{ nextcloud_host }}'
  176. tags:
  177. - integration
  178. ...