Nav apraksta
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

nextcloud.yml 4.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. ---
  2. # Installs the nextcloud personal cloud software.
  3. - name: Install NextCloud dependencies
  4. apt:
  5. name: "{{ packages }}"
  6. state: present
  7. vars:
  8. packages:
  9. - php
  10. - php-pgsql
  11. - php-fpm
  12. - php-apcu
  13. - php-imap
  14. - php-imagick
  15. - php-redis
  16. - php-mysql
  17. - php-xml
  18. - php-zip
  19. - php-mbstring
  20. - php-gd
  21. - php-json
  22. - php-curl
  23. - php-intl
  24. - curl
  25. - unzip
  26. tags:
  27. - dependencies
  28. - name: Install NextCloud dependencies
  29. apt:
  30. name: "{{ packages }}"
  31. state: present
  32. vars:
  33. packages:
  34. - php-mcrypt
  35. tags:
  36. - dependencies
  37. when: ansible_distribution_version == '9'
  38. - name: Create NextCloud temp directory
  39. file: path=/root/nextcloud state=directory
  40. - name: Download NextCloud {{ nextcloud_version }}
  41. get_url:
  42. url=https://download.nextcloud.com/server/releases/nextcloud-{{ nextcloud_version }}.zip
  43. dest=/root/nextcloud/nextcloud-{{ nextcloud_version }}.zip
  44. - name: Create NextCloud unpack directory
  45. file: path=/root/nextcloud/nextcloud-{{ nextcloud_version }} state=directory
  46. - name: Extract NextCloud archive
  47. unarchive:
  48. copy: no
  49. src: /root/nextcloud/nextcloud-{{ nextcloud_version }}.zip
  50. dest: /root/nextcloud/nextcloud-{{ nextcloud_version }}/
  51. creates: /root/nextcloud-{{ nextcloud_version }}/index.php
  52. - name: Back-Up old NextCloud config
  53. shell: cp -r /var/www/nextcloud/config/config.php /root/nextcloud/config.php.bak || true
  54. - name: Delete old NextCloud document root
  55. file: path=/var/www/nextcloud state=absent
  56. - name: Copy NextCloud source to document root
  57. shell: cp -r /root/nextcloud/nextcloud-{{ nextcloud_version }}/nextcloud /var/www/nextcloud
  58. - name: Delete empty NextCloud config
  59. file: path=/var/www/nextcloud/config/config.php state=absent
  60. - name: Restore old NextCloud config
  61. shell: cp -r /root/nextcloud/config.php.bak /var/www/nextcloud/config/config.php || true
  62. - name: Delete old NextCloud config
  63. file: path=/root/nextcloud/config.php.bak state=absent
  64. - name: Create database user for NextCloud
  65. postgresql_user:
  66. login_host=localhost
  67. login_user={{ db_admin_username }}
  68. login_password="{{ db_admin_password }}"
  69. name={{ nextcloud_db_username }}
  70. password="{{ nextcloud_db_password }}"
  71. role_attr_flags=CREATEDB
  72. state=present
  73. - name: Create NextCloud data directory
  74. file: path=/data/nextcloud-data state=directory owner=www-data group=www-data
  75. - name: Set NextCloud ownership
  76. action: file owner=www-data group=www-data path=/var/www/nextcloud recurse=yes state=directory
  77. - name: Run NextCloud installer
  78. become: true
  79. become_user: www-data
  80. command: php occ maintenance:install --no-interaction --data-dir "/data/nextcloud-data" --database "pgsql" --database-name "{{ nextcloud_db_database }}" --database-user "{{ nextcloud_db_username }}" --database-pass "{{ nextcloud_db_password }}" --admin-user "{{ nextcloud_admin_username }}" --admin-pass "{{ nextcloud_admin_password }}"
  81. args:
  82. chdir: /var/www/nextcloud
  83. creates: /var/www/nextcloud/config/config.php
  84. - name: Install NextCloud contacts app
  85. become: true
  86. become_user: www-data
  87. command: php occ app:install contacts
  88. args:
  89. chdir: /var/www/nextcloud
  90. creates: /var/www/nextcloud/apps/contacts/COPYING
  91. - name: Install NextCloud calendar app
  92. become: true
  93. become_user: www-data
  94. command: php occ app:install calendar
  95. args:
  96. chdir: /var/www/nextcloud
  97. creates: /var/www/nextcloud/apps/calendar/COPYING
  98. - name: Add our domains to the NextCloud trusted domains
  99. lineinfile:
  100. path: /var/www/nextcloud/config/config.php
  101. insertafter: 'instanceid'
  102. line: " 'trusted_domains' => array ('localhost', {{ virtual_domains | json_query('[*].name') | map('regex_replace', '^(.*)$', \"'\" + nextcloud_subdomain + \".\\1'\") | join(', ') }}),"
  103. - name: Create the Apache sites config files
  104. template:
  105. src=etc_apache2_sites-available_nextcloud.j2
  106. dest=/etc/apache2/sites-available/nextcloud_{{ item.name }}.conf
  107. owner=root
  108. group=root
  109. with_items: "{{ virtual_domains }}"
  110. - name: Enable Apache sites (creates new sites-enabled symlinks)
  111. command: a2ensite nextcloud_{{ item }}.conf creates=/etc/apache2/sites-enabled/nextcloud_{{ item }}.conf
  112. notify: restart apache
  113. with_items: "{{ virtual_domains | json_query('[*].name') }}"
  114. - name: Set nextcloud cron mail target
  115. cron:
  116. name: MAILTO
  117. env: yes
  118. value: "{{ admin_email }}"
  119. user: www-data
  120. - name: Install NextCloud cronjob
  121. cron:
  122. name="nextcloud"
  123. user="www-data"
  124. minute="*/5"
  125. job="php -f /var/www/nextcloud/cron.php > /dev/null"