No Description
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.

nextcloud.yml 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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. ignore_errors: True
  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. ignore_errors: True
  98. - name: Install NextCloud LDAP app
  99. become: true
  100. become_user: www-data
  101. command: php occ app:install user_ldap
  102. args:
  103. chdir: /var/www/nextcloud
  104. ignore_errors: True
  105. #- name: Update installed Nextcloud apps
  106. # become: true
  107. # become_user: www-data
  108. # command: php occ app:update
  109. # args:
  110. # chdir: /var/www/nextcloud
  111. - name: Add our domains to the NextCloud trusted domains
  112. lineinfile:
  113. path: /var/www/nextcloud/config/config.php
  114. insertafter: 'instanceid'
  115. line: " 'trusted_domains' => array ('localhost', {{ virtual_domains | json_query('[*].name') | map('regex_replace', '^(.*)$', \"'\" + nextcloud_subdomain + \".\\1'\") | join(', ') }}),"
  116. - name: Create the Apache sites config files
  117. template:
  118. src=etc_apache2_sites-available_nextcloud.j2
  119. dest=/etc/apache2/sites-available/nextcloud_{{ item.name }}.conf
  120. owner=root
  121. group=root
  122. with_items: "{{ virtual_domains }}"
  123. - name: Enable Apache sites (creates new sites-enabled symlinks)
  124. command: a2ensite nextcloud_{{ item }}.conf creates=/etc/apache2/sites-enabled/nextcloud_{{ item }}.conf
  125. notify: restart apache
  126. with_items: "{{ virtual_domains | json_query('[*].name') }}"
  127. - name: Set nextcloud cron mail target
  128. cron:
  129. name: MAILTO
  130. env: yes
  131. value: "{{ admin_email }}"
  132. user: www-data
  133. - name: Install NextCloud cronjob
  134. cron:
  135. name="nextcloud"
  136. user="www-data"
  137. minute="*/5"
  138. job="php -f /var/www/nextcloud/cron.php > /dev/null"