Initial admin credentials for Nextcloud container

This commit is contained in:
Kris Lamoureux 2020-07-07 17:21:04 -04:00
parent 38041b22f6
commit 954ea7f2a6
Signed by: kris
GPG Key ID: 3EDA9C3441EDA925
4 changed files with 50 additions and 9 deletions

View File

@ -3,3 +3,6 @@ mariadb_version: latest
nextcloud_name: nextcloud nextcloud_name: nextcloud
nextcloud_dbpass: password nextcloud_dbpass: password
nextcloud_version: stable nextcloud_version: stable
nextcloud_admin: admin
nextcloud_pass: password
nextcloud_domain: cloud.vm.krislamo.org

View File

@ -1 +0,0 @@
docker_user: vagrant

View File

@ -2,3 +2,4 @@
mariadb_name: mariadb mariadb_name: mariadb
nextcloud_dbname: nextcloud nextcloud_dbname: nextcloud
nextcloud_dbuser: nextcloud nextcloud_dbuser: nextcloud
nextcloud_root: "/opt/{{ nextcloud_name }}"

View File

@ -1,3 +1,8 @@
- name: Create Docker container bind mount directory
file:
path: "{{ nextcloud_root }}/public_html"
state: directory
- name: Start MariaDB container - name: Start MariaDB container
docker_container: docker_container:
name: "{{ mariadb_name }}" name: "{{ mariadb_name }}"
@ -15,7 +20,7 @@
name: "{{ nextcloud_name }}" name: "{{ nextcloud_name }}"
image: nextcloud:{{ nextcloud_version }} image: nextcloud:{{ nextcloud_version }}
restart_policy: always restart_policy: always
volumes: nextcloud:/var/www/html volumes: "{{ nextcloud_root }}/public_html:/var/www/html"
ports: 80:80 ports: 80:80
links: "{{ mariadb_name }}:mysql" links: "{{ mariadb_name }}:mysql"
env: env:
@ -25,11 +30,44 @@
MYSQL_PASSWORD: "{{ nextcloud_dbpass }}" MYSQL_PASSWORD: "{{ nextcloud_dbpass }}"
register: nextcloud_container register: nextcloud_container
- name: Do Nextcloud database maintenance - name: Grab Nextcloud container information
command: "docker exec --user www-data {{ nextcloud_name }} php {{ item }}" docker_container_info:
name: "{{ nextcloud_name }}"
register: nextcloud_info
- name: Wait for Nextcloud to become available
wait_for:
host: "{{ nextcloud_info.container.NetworkSettings.IPAddress }}"
port: 80
- name: Check Nextcloud status
command: "docker exec --user www-data {{ nextcloud_name }}
php occ status"
register: nextcloud_status
args:
removes: "{{ nextcloud_root }}/public_html/config/CAN_INSTALL"
- name: Install Nextcloud
command: 'docker exec --user www-data {{ nextcloud_name }}
php occ maintenance:install
--admin-user "{{ nextcloud_admin }}"
--admin-pass "{{ nextcloud_pass }}"'
register: nextcloud_install
when:
- nextcloud_status.stdout[:26] == "Nextcloud is not installed"
- nextcloud_domain is defined
- name: Set Nextcloud's Trusted Domain
command: 'docker exec --user www-data {{ nextcloud_name }}
php occ config:system:set trusted_domains 0
--value="{{ nextcloud_domain }}"'
when: nextcloud_install.changed
- name: Preform Nextcloud database maintenance
command: "docker exec --user www-data {{ nextcloud_name }} {{ item }}"
loop: loop:
- "occ maintenance:mode --on" - "php occ maintenance:mode --on"
- "occ db:add-missing-indices" - "php occ db:add-missing-indices"
- "occ db:convert-filecache-bigint" - "php occ db:convert-filecache-bigint"
- "occ maintenance:mode --off" - "php occ maintenance:mode --off"
when: nextcloud_container.changed when: nextcloud_install.changed