暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

nextcloud.yml 4.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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 config
  53. file: path=/root/nextcloud/config.php.bak 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: Install NextCloud contacts app
  75. become: true
  76. become_user: www-data
  77. command: php occ app:install contacts
  78. args:
  79. chdir: /var/www/nextcloud
  80. creates: /var/www/nextcloud/apps/contacts/COPYING
  81. - name: Install NextCloud calendar app
  82. become: true
  83. become_user: www-data
  84. command: php occ app:install calendar
  85. args:
  86. chdir: /var/www/nextcloud
  87. creates: /var/www/nextcloud/apps/calendar/COPYING
  88. - name: Add our domains to the NextCloud trusted domains
  89. lineinfile:
  90. path: /var/www/nextcloud/config/config.php
  91. insertafter: 'instanceid'
  92. line: " 'trusted_domains' => array ('localhost', {{ virtual_domains | json_query('[*].name') | map('regex_replace', '(.*)', \"'cloud.\\1'\") | join(', ') }}),"
  93. - name: Create the Apache sites config files
  94. template:
  95. src=etc_apache2_sites-available_nextcloud.j2
  96. dest=/etc/apache2/sites-available/nextcloud_{{ item.name }}.conf
  97. owner=root
  98. group=root
  99. with_items: "{{ virtual_domains }}"
  100. - name: Enable Apache sites (creates new sites-enabled symlinks)
  101. command: a2ensite nextcloud_{{ item }}.conf creates=/etc/apache2/sites-enabled/nextcloud_{{ item }}.conf
  102. notify: restart apache
  103. with_items: "{{ virtual_domains | json_query('[*].name') }}"
  104. - name: Install NextCloud cronjob
  105. cron:
  106. name="nextcloud"
  107. user="www-data"
  108. minute="*/5"
  109. job="php -f /var/www/nextcloud/cron.php > /dev/null"