Reorganize Nextcloud docker mounts and variables

This commit is contained in:
Kris Lamoureux 2020-07-09 21:53:07 -04:00
parent a950b4057b
commit e66a4b96ff
Signed by: kris
GPG Key ID: 3EDA9C3441EDA925
3 changed files with 34 additions and 32 deletions

View File

@ -1,8 +1,9 @@
# nextcloud # container settings
mariadb_version: latest
nextcloud_name: nextcloud
nextcloud_dbpass: password
nextcloud_version: stable nextcloud_version: stable
nextcloud_admin: admin nextcloud_admin: admin
nextcloud_pass: password nextcloud_pass: password
nextcloud_domain: cloud.vm.krislamo.org nextcloud_domain: cloud.vm.krislamo.org
# database settings
nextcloud_dbversion: latest
nextcloud_dbpass: password

View File

@ -1,5 +1,11 @@
# nextcloud # container names
mariadb_name: mariadb nextcloud_container: nextcloud
nextcloud_dbname: nextcloud nextcloud_dbcontainer: "{{ nextcloud_container }}-db"
nextcloud_dbuser: nextcloud
nextcloud_root: "/opt/{{ nextcloud_name }}" # database settings
nextcloud_dbname: "{{ nextcloud_container }}"
nextcloud_dbuser: "{{ nextcloud_dbname }}"
# host mounts
nextcloud_root: "/opt/{{ nextcloud_container }}/public_html"
nextcloud_dbroot: "/opt/{{ nextcloud_container }}/database"

View File

@ -1,14 +1,15 @@
- name: Create Docker container bind mount directory - name: Create Docker container bind mount directories
file: file:
path: "{{ nextcloud_root }}/public_html" path: ["{{ nextcloud_root }}",
"{{ nextcloud_dbroot }}"]
state: directory state: directory
- name: Start MariaDB container - name: Start Nextcloud's database container
docker_container: docker_container:
name: "{{ mariadb_name }}" name: "{{ nextcloud_dbcontainer }}"
image: mariadb:{{ mariadb_version }} image: mariadb:{{ nextcloud_dbversion }}
restart_policy: always restart_policy: always
volumes: mariadb:/var/lib/mysql volumes: "{{ nextcloud_dbroot }}:/var/lib/mysql"
env: env:
MYSQL_RANDOM_ROOT_PASSWORD: "true" MYSQL_RANDOM_ROOT_PASSWORD: "true"
MYSQL_DATABASE: "{{ nextcloud_dbname }}" MYSQL_DATABASE: "{{ nextcloud_dbname }}"
@ -17,22 +18,16 @@
- name: Start Nextcloud container - name: Start Nextcloud container
docker_container: docker_container:
name: "{{ nextcloud_name }}" name: "{{ nextcloud_container }}"
image: nextcloud:{{ nextcloud_version }} image: nextcloud:{{ nextcloud_version }}
restart_policy: always restart_policy: always
volumes: "{{ nextcloud_root }}/public_html:/var/www/html" volumes: "{{ nextcloud_root }}:/var/www/html"
ports: 80:80 ports: 80:80
links: "{{ mariadb_name }}:mysql" links: "{{ nextcloud_dbcontainer }}:mysql"
env:
MYSQL_HOST: mysql
MYSQL_DATABASE: "{{ nextcloud_dbname }}"
MYSQL_USER: "{{ nextcloud_dbuser }}"
MYSQL_PASSWORD: "{{ nextcloud_dbpass }}"
register: nextcloud_container
- name: Grab Nextcloud container information - name: Grab Nextcloud container information
docker_container_info: docker_container_info:
name: "{{ nextcloud_name }}" name: "{{ nextcloud_container }}"
register: nextcloud_info register: nextcloud_info
- name: Wait for Nextcloud to become available - name: Wait for Nextcloud to become available
@ -41,17 +36,17 @@
port: 80 port: 80
- name: Check Nextcloud status - name: Check Nextcloud status
command: "docker exec --user www-data {{ nextcloud_name }} command: "docker exec --user www-data {{ nextcloud_container }}
php occ status" php occ status"
register: nextcloud_status register: nextcloud_status
args: args:
removes: "{{ nextcloud_root }}/public_html/config/CAN_INSTALL" removes: "{{ nextcloud_root }}/config/CAN_INSTALL"
- name: Install Nextcloud - name: Install Nextcloud
command: 'docker exec --user www-data {{ nextcloud_name }} command: 'docker exec --user www-data {{ nextcloud_container }}
php occ maintenance:install php occ maintenance:install
--database "mysql" --database "mysql"
--database-host "{{ mariadb_name }}" --database-host "{{ nextcloud_dbcontainer }}"
--database-name "{{ nextcloud_dbname }}" --database-name "{{ nextcloud_dbname }}"
--database-user "{{ nextcloud_dbuser }}" --database-user "{{ nextcloud_dbuser }}"
--database-pass "{{ nextcloud_dbpass }}" --database-pass "{{ nextcloud_dbpass }}"
@ -63,13 +58,13 @@
- nextcloud_domain is defined - nextcloud_domain is defined
- name: Set Nextcloud's Trusted Domain - name: Set Nextcloud's Trusted Domain
command: 'docker exec --user www-data {{ nextcloud_name }} command: 'docker exec --user www-data {{ nextcloud_container }}
php occ config:system:set trusted_domains 0 php occ config:system:set trusted_domains 0
--value="{{ nextcloud_domain }}"' --value="{{ nextcloud_domain }}"'
when: nextcloud_install.changed when: nextcloud_install.changed
- name: Preform Nextcloud database maintenance - name: Preform Nextcloud database maintenance
command: "docker exec --user www-data {{ nextcloud_name }} {{ item }}" command: "docker exec --user www-data {{ nextcloud_container }} {{ item }}"
loop: loop:
- "php occ maintenance:mode --on" - "php occ maintenance:mode --on"
- "php occ db:add-missing-indices" - "php occ db:add-missing-indices"
@ -79,5 +74,5 @@
- name: Remove Nextcloud's CAN_INSTALL file - name: Remove Nextcloud's CAN_INSTALL file
file: file:
path: "{{ nextcloud_root }}/public_html/config/CAN_INSTALL" path: "{{ nextcloud_root }}/config/CAN_INSTALL"
state: absent state: absent