Install Nextcloud Docker container

This commit is contained in:
Kris Lamoureux 2020-07-02 01:35:01 -04:00
parent 93ec159bbb
commit 38041b22f6
Signed by: kris
GPG Key ID: 3EDA9C3441EDA925
4 changed files with 54 additions and 0 deletions

View File

@ -0,0 +1,5 @@
# nextcloud
mariadb_version: latest
nextcloud_name: nextcloud
nextcloud_dbpass: password
nextcloud_version: stable

10
dev/nextcloud.yml Normal file
View File

@ -0,0 +1,10 @@
- name: Install Nextcloud Server
hosts: all
become: true
vars_files:
- host_vars/nextcloud.yml
roles:
- ansible
- base
- docker
- nextcloud

View File

@ -0,0 +1,4 @@
# nextcloud
mariadb_name: mariadb
nextcloud_dbname: nextcloud
nextcloud_dbuser: nextcloud

View File

@ -0,0 +1,35 @@
- name: Start MariaDB container
docker_container:
name: "{{ mariadb_name }}"
image: mariadb:{{ mariadb_version }}
restart_policy: always
volumes: mariadb:/var/lib/mysql
env:
MYSQL_RANDOM_ROOT_PASSWORD: "true"
MYSQL_DATABASE: "{{ nextcloud_dbname }}"
MYSQL_USER: "{{ nextcloud_dbuser }}"
MYSQL_PASSWORD: "{{ nextcloud_dbpass }}"
- name: Start Nextcloud container
docker_container:
name: "{{ nextcloud_name }}"
image: nextcloud:{{ nextcloud_version }}
restart_policy: always
volumes: nextcloud:/var/www/html
ports: 80:80
links: "{{ mariadb_name }}:mysql"
env:
MYSQL_HOST: mysql
MYSQL_DATABASE: "{{ nextcloud_dbname }}"
MYSQL_USER: "{{ nextcloud_dbuser }}"
MYSQL_PASSWORD: "{{ nextcloud_dbpass }}"
register: nextcloud_container
- name: Do Nextcloud database maintenance
command: "docker exec --user www-data {{ nextcloud_name }} php {{ item }}"
loop:
- "occ maintenance:mode --on"
- "occ db:add-missing-indices"
- "occ db:convert-filecache-bigint"
- "occ maintenance:mode --off"
when: nextcloud_container.changed