설명 없음
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 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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-mcrypt
  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: Create NextCloud temp directory
  29. file: path=/root/nextcloud state=directory
  30. - name: Download NextCloud {{ nextcloud_version }}
  31. get_url:
  32. url=https://download.nextcloud.com/server/releases/nextcloud-{{ nextcloud_version }}.zip
  33. dest=/root/nextcloud/nextcloud-{{ nextcloud_version }}.zip
  34. - name: Create NextCloud unpack directory
  35. file: path=/root/nextcloud/nextcloud-{{ nextcloud_version }} state=directory
  36. - name: Extract NextCloud archive
  37. unarchive:
  38. copy: no
  39. src: /root/nextcloud/nextcloud-{{ nextcloud_version }}.zip
  40. dest: /root/nextcloud/nextcloud-{{ nextcloud_version }}/
  41. creates: /root/nextcloud-{{ nextcloud_version }}/index.php
  42. - name: Back-Up old NextCloud config
  43. shell: cp -r /var/www/nextcloud/config/config.php /root/nextcloud/config.php.bak || true
  44. - name: Delete old NextCloud document root
  45. file: path=/var/www/nextcloud state=absent
  46. - name: Copy NextCloud source to document root
  47. shell: cp -r /root/nextcloud/nextcloud-{{ nextcloud_version }}/nextcloud /var/www/nextcloud
  48. - name: Delete empty NextCloud config
  49. file: path=/var/www/nextcloud/config/config.php state=absent
  50. - name: Restore old NextCloud config
  51. shell: cp -r /root/nextcloud/config.php.bak /var/www/nextcloud/config/config.php || true
  52. - name: Delete old NextCloud source
  53. file: path=/root/nextcloud state=absent
  54. - name: Create database user for NextCloud
  55. postgresql_user:
  56. login_host=localhost
  57. login_user={{ db_admin_username }}
  58. login_password="{{ db_admin_password }}"
  59. name={{ nextcloud_db_username }}
  60. password="{{ nextcloud_db_password }}"
  61. role_attr_flags=CREATEDB
  62. state=present
  63. - name: Create NextCloud data directory
  64. file: path=/data/nextcloud-data state=directory owner=www-data group=www-data
  65. - name: Set NextCloud ownership
  66. action: file owner=www-data group=www-data path=/var/www/nextcloud recurse=yes state=directory
  67. - name: Run NextCloud installer
  68. become: true
  69. become_user: www-data
  70. 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 }}"
  71. args:
  72. chdir: /var/www/nextcloud
  73. creates: /var/www/nextcloud/config/config.php
  74. - name: Add our domains to the NextCloud trusted domains
  75. lineinfile:
  76. path: /var/www/nextcloud/config/config.php
  77. insertafter: 'instanceid'
  78. line: " 'trusted_domains' => array ('localhost', {{ virtual_domains | json_query('[*].name') | map('regex_replace', '(.*)', \"'cloud.\\1'\") | join(', ') }}),"
  79. - name: Create the Apache sites config files
  80. template:
  81. src=etc_apache2_sites-available_nextcloud.j2
  82. dest=/etc/apache2/sites-available/nextcloud_{{ item.name }}.conf
  83. owner=root
  84. group=root
  85. with_items: "{{ virtual_domains }}"
  86. - name: Remove old sites-enabled symlinks (new ones will be created by a2ensite)
  87. file: path=/etc/apache2/sites-enabled/nextcloud_{{ item }}.conf state=absent
  88. with_items: "{{ virtual_domains | json_query('[*].name') }}"
  89. - name: Enable Apache sites (creates new sites-enabled symlinks)
  90. command: a2ensite nextcloud_{{ item }}.conf creates=/etc/apache2/sites-enabled/nextcloud_{{ item }}.conf
  91. notify: restart apache
  92. with_items: "{{ virtual_domains | json_query('[*].name') }}"
  93. - name: Install NextCloud cronjob
  94. cron:
  95. name="nextcloud"
  96. user="www-data"
  97. minute="*/5"
  98. job="php -f /var/www/nextcloud/cron.php > /dev/null"