automation/deployer/roles/build/tasks/nextcloud.yml
2020-09-23 12:45:03 +02:00

106 lines
No EOL
3 KiB
YAML

---
- block: # Used for tagging all tasks with "nextcloud"
- name: "Set site_data_path to {{ www_path }}/{{ site.slug }}"
set_fact: site_data_path="{{ www_path }}/{{ site.slug }}"
tags: always
###############################
# Create wp-content if needed #
###############################
- name: Is it a new install?
stat:
path: "{{ site_data_path }}/index.php"
register: content
tags: bootstrap
- name: Populate data folder
block:
# - name: "Clear folder {{ site_data_path }}"
# file:
# path: "{{ site_data_path }}"
# state: absent
- name: "Download NextCloud {{ nextcloud.version }} archive"
get_url:
url: "https://download.nextcloud.com/server/releases/nextcloud-{{ nextcloud.version }}.tar.bz2"
dest: "/tmp/nextcloud.tbz2"
checksum: "{{ nextcloud.checksum }}"
- name: "Extract NextCloud {{ nextcloud.version }} archive"
unarchive:
src: "/tmp/nextcloud.tbz2"
dest: /tmp
remote_src: yes
- name: "Copy NextCloud folder to destination"
copy:
src: /tmp/nextcloud
dest: "{{ site_data_path }}"
remote_src: yes
# group: www-data
# mode: '0660'
# directory_mode: '0770'
- name: "Set proper access rights to {{ site_data_path }}"
file:
path: "{{ site_data_path }}"
state: directory
recurse: yes
group: www-data
mode: "u=rwX,g=rwX,o="
- name: "Remove downloaded content"
file:
path: "{{ toremove }}"
state: absent
loop:
- /tmp/nextcloud.tgz
loop_control:
loop_var: toremove
when: content.stat.exists is not defined or content.stat.exists == False
tags: bootstrap
####################
# Render templates #
####################
- name: "Render templates"
import_tasks: render.yml
tags: render
#######################
# MySQL configuration #
#######################
- name: "Setup MySQL"
import_tasks: mysql.yml
tags: mysql
#################
# Setup backups #
#################
# Backups would need to exclude the '/data' folder.
# Otherwise they can heavily grow in size depending on usage.
# So forget about it for now.
# - name: "Setup backups"
# import_tasks: backup.yml
# tags: backup
###################
# SSL certificate #
###################
# - name: Create Let's Encrypt certificate
# This seems hard, see:
# https://docs.ansible.com/ansible/latest/modules/acme_certificate_module.html#acme-certificate-module
# https://www.digitalocean.com/community/tutorials/how-to-acquire-a-let-s-encrypt-certificate-using-ansible-on-ubuntu-18-04
# Maybe using shell directly? e.g.
# certbot certonly --webroot -w /var/www/letsencrypt -d <url>
tags: nextcloud # / block