This commit is contained in:
Kris Lamoureux 2022-11-22 04:27:55 -05:00
parent 511c26392c
commit 614c1645a4
4 changed files with 66 additions and 3 deletions

View File

@ -3,9 +3,10 @@
############### ###############
# These are sample public passwords not encrypted in Ansible Vault, unlike production # These are sample public passwords not encrypted in Ansible Vault, unlike production
secret: secret:
WORDPRESS_DB_PASSWORD: WPpa55w0rd!
NEXTCLOUD_MYSQL_PASSWORD: NCpa55w0rd!
TRAEFIK_DREAMHOST_APIKEY: DHap1pa55w0rd! TRAEFIK_DREAMHOST_APIKEY: DHap1pa55w0rd!
WORDPRESS_DB_PASSWORD: WPpa55w0rd!
NEXTCLOUD_MYSQL_PASSWORD: NCdbpa55w0rd!
NEXTCLOUD_ADMIN_PASSWORD: NCadm1npa55w0rd!
############## ##############
### Docker ### ### Docker ###
@ -49,9 +50,18 @@ webserver:
#WORDPRESS_DB_HOST: host.docker.internal #WORDPRESS_DB_HOST: host.docker.internal
#WORDPRESS_DB_NAME: wordpress #WORDPRESS_DB_NAME: wordpress
#WORDPRESS_DB_USER: wordpress #WORDPRESS_DB_USER: wordpress
#WORDPRESS_WEB_ENABLED: true
WORDPRESS_DB_PASSWORD: "{{ secret.WORDPRESS_DB_PASSWORD }}" WORDPRESS_DB_PASSWORD: "{{ secret.WORDPRESS_DB_PASSWORD }}"
################# #################
### Nextcloud ### ### Nextcloud ###
################# #################
#NEXTCLOUD_VERSION: stable
#NEXTCLOUD_DOMAIN: cloud.local.freeitathens.org
#NEXTCLOUD_MYSQL_HOST: host.docker.internal
#NEXTCLOUD_MYSQL_DATABASE: nextcloud
#NEXTCLOUD_MYSQL_USER: nextcloud
#NEXTCLOUD_WEB_ENABLED: true
#NEXTCLOUD_ADMIN: admin
NEXTCLOUD_ADMIN_PASSWORD: "{{ secret.NEXTCLOUD_ADMIN_PASSWORD }}"
NEXTCLOUD_MYSQL_PASSWORD: "{{ secret.NEXTCLOUD_MYSQL_PASSWORD }}" NEXTCLOUD_MYSQL_PASSWORD: "{{ secret.NEXTCLOUD_MYSQL_PASSWORD }}"

View File

@ -1,4 +1,5 @@
webserver_root: "{{ docker_compose_root }}/webserver" webserver_root: "{{ docker_compose_root }}/webserver"
nextcloud_install: true
mariadb_trust: mariadb_trust:
- "172.16.0.0/12" - "172.16.0.0/12"
- "192.168.0.0/16" - "192.168.0.0/16"

View File

@ -84,7 +84,7 @@ services:
image: nextcloud:${NEXTCLOUD_VERSION:-stable} image: nextcloud:${NEXTCLOUD_VERSION:-stable}
restart: always restart: always
environment: environment:
MYSQL_HOST: ${NEXTCLOUD_MYSQL_HOST:-host.docker.internal:3306} MYSQL_HOST: ${NEXTCLOUD_MYSQL_HOST:-host.docker.internal}
MYSQL_DATABASE: ${NEXTCLOUD_MYSQL_DATABASE-nextcloud} MYSQL_DATABASE: ${NEXTCLOUD_MYSQL_DATABASE-nextcloud}
MYSQL_USER: ${NEXTCLOUD_MYSQL_USER:-nextcloud} MYSQL_USER: ${NEXTCLOUD_MYSQL_USER:-nextcloud}
MYSQL_PASSWORD: ${NEXTCLOUD_MYSQL_PASSWORD} MYSQL_PASSWORD: ${NEXTCLOUD_MYSQL_PASSWORD}

View File

@ -3,6 +3,58 @@
args: args:
chdir: "{{ webserver_root }}" chdir: "{{ webserver_root }}"
listen: composeup_webserver listen: composeup_webserver
notify: install_nextcloud
- name: Grab Nextcloud container information
docker_container_info:
name: "{{ webserver_root | basename }}_nextcloud_1"
listen: install_nextcloud
register: nextcloud_info
- name: Check Nextcloud status
ansible.builtin.command: "docker exec --user www-data {{ webserver_root | basename }}_nextcloud_1
php occ status"
listen: install_nextcloud
register: nextcloud_status
- name: Install Nextcloud
ansible.builtin.command: 'docker exec --user www-data {{ webserver_root | basename }}_nextcloud_1
php occ maintenance:install
--database "mysql"
--database-host "{{ webserver.NEXTCLOUD_MYSQL_HOST | default("host.docker.internal") }}"
--database-name "{{ webserver.NEXTCLOUD_MYSQL_DATABASE | default("nextcloud") }}"
--database-user "{{ webserver.NEXTCLOUD_MYSQL_USER | default("nextcloud") }}"
--database-pass "{{ webserver.NEXTCLOUD_MYSQL_PASSWORD }}"
--admin-user "{{ webserver.NEXTCLOUD_ADMIN | default("admin") }}"
--admin-pass "{{ webserver.NEXTCLOUD_ADMIN_PASSWORD }}"'
register: nextcloud_install
listen: install_nextcloud
when:
- nextcloud_status.stdout[:26] == "Nextcloud is not installed"
- nextcloud_install is defined and nextcloud_install
- name: Set Nextcloud's Trusted Proxy
command: 'docker exec --user www-data {{ webserver_root | basename }}_nextcloud_1
php occ config:system:set trusted_proxies 0 --value="traefik"'
listen: install_nextcloud
when: nextcloud_install.changed
- name: Set Nextcloud's Trusted Domain
command: 'docker exec --user www-data {{ webserver_root | basename }}_nextcloud_1
php occ config:system:set trusted_domains 0
--value="{{ webserver.NEXTCLOUD_DOMAIN }}"'
listen: install_nextcloud
when: nextcloud_install.changed
- name: Preform Nextcloud database maintenance
command: "docker exec --user www-data {{ webserver_root | basename }}_nextcloud_1 {{ item }}"
loop:
- "php occ maintenance:mode --on"
- "php occ db:add-missing-indices"
- "php occ db:convert-filecache-bigint"
- "php occ maintenance:mode --off"
listen: install_nextcloud
when: nextcloud_install.changed
- name: Restart MariaDB - name: Restart MariaDB
ansible.builtin.service: ansible.builtin.service: