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