Nenhuma descrição
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

nextcloud.yml 4.3KB

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