aboutsummaryrefslogtreecommitdiff
path: root/roles/services/containers/nextcloud/tasks
diff options
context:
space:
mode:
Diffstat (limited to 'roles/services/containers/nextcloud/tasks')
-rw-r--r--roles/services/containers/nextcloud/tasks/main.yml184
1 files changed, 184 insertions, 0 deletions
diff --git a/roles/services/containers/nextcloud/tasks/main.yml b/roles/services/containers/nextcloud/tasks/main.yml
new file mode 100644
index 0000000..fbd4a76
--- /dev/null
+++ b/roles/services/containers/nextcloud/tasks/main.yml
@@ -0,0 +1,184 @@
1- name: set image fact
2 set_fact:
3 image: nextcloud:27.0.0-apache
4
5- name: set other facts
6 set_fact:
7 repo_tag: "{{ image }}"
8 custom_registry: "{{ docker_registry_url + '/' + docker_registry_username }}"
9
10- name: create nextcloud directory
11 file:
12 path: "{{ docker_home }}/nextcloud"
13 state: directory
14 owner: "{{ docker_username }}"
15 group: "{{ docker_username }}"
16 mode: '0755'
17
18- name: create nextcloud app directory
19 file:
20 path: "{{ docker_home }}/nextcloud/app/"
21 state: directory
22 owner: "{{ docker_username }}"
23 group: "{{ docker_username }}"
24 mode: '0755'
25
26- name: create nextcloud data directory
27 file:
28 path: "{{ docker_home }}/nextcloud/data/"
29 state: directory
30 owner: "{{ docker_username }}"
31 group: "{{ docker_username }}"
32 mode: '0755'
33
34- name: login to docker registry
35 become: yes
36 become_user: "{{ docker_username }}"
37 environment:
38 XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}"
39 docker_login:
40 docker_host: "unix://run/user/{{ docker_uid }}/docker.sock"
41 registry_url: "{{ docker_registry_url }}"
42 username: "{{ docker_registry_username }}"
43 password: "{{ docker_registry_password }}"
44
45- name: pull and push nextcloud image
46 become: yes
47 become_user: "{{ docker_username }}"
48 environment:
49 XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}"
50 docker_image:
51 name: "{{ image }}"
52 repository: "{{ custom_registry }}/{{ repo_tag }}"
53 docker_host: "unix://run/user/{{ docker_uid }}/docker.sock"
54 source: pull
55 force_source: yes
56 push: yes
57
58- name: create nextcloud docker network
59 docker_network:
60 name: "{{ nextcloud_network_name }}"
61 docker_host: "unix://run/user/{{ docker_uid }}/docker.sock"
62 driver: bridge
63 ipam_config:
64 - subnet: "{{ nextcloud_subnet }}"
65 gateway: "{{ nextcloud_gateway }}"
66
67- name: create and deploy postgres container
68 become: yes
69 become_user: "{{ docker_username }}"
70 environment:
71 XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}"
72 docker_container:
73 name: "nextcloud-postgres"
74 hostname: "nextcloud-postgres"
75 image: "postgres:alpine"
76 pull: yes
77 docker_host: "unix://run/user/{{ docker_uid }}/docker.sock"
78 purge_networks: yes
79 networks:
80 - name: "{{ nextcloud_network_name }}"
81 ipv4_address: "{{ nextcloud_postgres_ipv4 }}"
82 state: 'started'
83 comparisons:
84 '*': strict
85 restart_policy: unless-stopped
86 env:
87 "POSTGRES_USER": "{{ nextcloud_postgres_user }}"
88 "POSTGRES_PASSWORD": "{{ nextcloud_postgres_password }}"
89 "POSTGRES_DB": "{{ nextcloud_postgres_db }}"
90 volumes:
91 - "{{ docker_home }}/nextcloud/data:/var/lib/postgresql/data"
92
93- name: create and deploy redis container
94 become: yes
95 become_user: "{{ docker_username }}"
96 environment:
97 XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}"
98 docker_container:
99 name: "nextcloud-redis"
100 hostname: "nextcloud-redis"
101 image: "redis:alpine"
102 pull: yes
103 docker_host: "unix://run/user/{{ docker_uid }}/docker.sock"
104 purge_networks: yes
105 networks:
106 - name: "{{ nextcloud_network_name }}"
107 ipv4_address: "{{ nextcloud_redis_ipv4 }}"
108 state: 'started'
109 comparisons:
110 '*': strict
111 restart_policy: unless-stopped
112
113- name: create and deploy nextcloud container
114 become: yes
115 become_user: "{{ docker_username }}"
116 environment:
117 XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}"
118 docker_container:
119 name: "nextcloud"
120 hostname: "nextcloud"
121 image: "{{ custom_registry }}/{{ repo_tag }}"
122 pull: yes
123 docker_host: "unix://run/user/{{ docker_uid }}/docker.sock"
124 purge_networks: yes
125 networks:
126 - name: "{{ nextcloud_network_name }}"
127 ipv4_address: "{{ nextcloud_ipv4 }}"
128 ports:
129 - "127.0.0.1:{{ nextcloud_external_port }}:80"
130 state: 'started'
131 comparisons:
132 '*': strict
133 restart_policy: unless-stopped
134 env:
135 "POSTGRES_USER": "{{ nextcloud_postgres_user }}"
136 "POSTGRES_PASSWORD": "{{ nextcloud_postgres_password }}"
137 "POSTGRES_DB": "{{ nextcloud_postgres_db }}"
138 "POSTGRES_HOST": "nextcloud-postgres"
139 "REDIS_HOST": "nextcloud-redis"
140 "NEXTCLOUD_ADMIN_USER": "{{ nextcloud_admin }}"
141 "NEXTCLOUD_ADMIN_PASSWORD": "{{ nextcloud_admin_password }}"
142 "NEXTCLOUD_TRUSTED_DOMAINS": "{{ nextcloud_trusted_domains }}"
143 volumes:
144 - "{{ docker_home }}/nextcloud/app:/var/www/html"
145
146- name: create and deploy nextcloud cron container
147 become: yes
148 become_user: "{{ docker_username }}"
149 environment:
150 XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}"
151 docker_container:
152 name: "nextcloud-cron"
153 hostname: "nextcloud-cron"
154 image: "{{ custom_registry }}/{{ repo_tag }}"
155 entrypoint: "/cron.sh"
156 pull: yes
157 docker_host: "unix://run/user/{{ docker_uid }}/docker.sock"
158 purge_networks: yes
159 networks:
160 - name: "{{ nextcloud_network_name }}"
161 ipv4_address: "{{ nextcloud_cron_ipv4 }}"
162 state: 'started'
163 recreate: yes
164 restart_policy: unless-stopped
165 volumes:
166 - "{{ docker_home }}/nextcloud/app:/var/www/html"
167
168- name: deploy nginx configuration
169 notify: restart nginx
170 register: nginx_config
171 copy:
172 src: "{{ nextcloud_nginx_config }}"
173 dest: /etc/nginx/sites-available/nextcloud.conf
174 owner: root
175 group: root
176 mode: '0644'
177
178- name: symlink site
179 file:
180 src: /etc/nginx/sites-available/nextcloud.conf
181 dest: /etc/nginx/sites-enabled/nextcloud.conf
182 owner: root
183 group: root
184 state: link