2019-10-11 23:00:03 -03:00

115 lines
4.1 KiB
YAML

---
# TODO: postgres support
# - name: create nextcloud database (pg)
# postgresql_db:
# state: present
# name: "{{ nextcloud_db_name }}"
# login_host: "{{ postgresql_host }}"
# login_port: "{{ postgresql_port }}"
# login_user: "{{ postgresql_root_password }}"
# login_password: "{{ postgresql_root_password }}"
# - name: create nextcloud db user (pg)
# postgresql_user:
# state: present
# name: "{{ nextcloud_db_user }}"
# password: "{{ nextcloud_db_password }}"
# priv: "{{ nextcloud_db_name }}.*:ALL"
# login_host: "{{ postgresql_host }}"
# login_port: "{{ postgresql_port }}"
# login_user: root
# login_password: "{{ postgresql_root_password }}"
- name: create nextcloud database
mysql_db:
state: present
name: "{{ nextcloud_db_name }}"
login_host: "{{ mariadb_host }}"
login_port: "{{ mariadb_port }}"
login_user: root
login_password: "{{ mariadb_root_password }}"
when: nextcloud_db_engine in ('mariadb','mysql')
- name: create nextcloud db user
mysql_user:
state: present
name: "{{ nextcloud_db_user }}"
host: "%"
password: "{{ nextcloud_db_password }}"
priv: "{{ nextcloud_db_name }}.*:ALL"
login_host: "{{ mariadb_host }}"
login_port: "{{ mariadb_port }}"
login_user: root
login_password: "{{ mariadb_root_password }}"
when: nextcloud_db_engine in ('mariadb','mysql')
- name: start nextcloud container
docker_container:
image: "{{ nextcloud_image }}"
name: "{{ nextcloud_container }}"
volumes:
- "{{ nextcloud_volume }}:/var/www/html"
env:
SQLITE_DATABASE:
"{{ nextcloud_db_name if nextcloud_db_engine == 'sqlite' else '' }}"
MYSQL_DATABASE:
"{{ nextcloud_db_name if nextcloud_db_engine in ('mysql','mariadb') else '' }}"
MYSQL_USER:
"{{ nextcloud_db_user if nextcloud_db_engine in ('mysql','mariadb') else '' }}"
MYSQL_PASSWORD:
"{{ nextcloud_db_password if nextcloud_db_engine in ('mysql','mariadb') else '' }}"
MYSQL_HOST:
"{{ nextcloud_db_host if nextcloud_db_engine in ('mysql','mariadb') else '' }}"
POSTGRES_DB:
"{{ nextcloud_db_name if 'postgres' in nextcloud_db_engine else '' }}"
POSTGRES_USER:
"{{ nextcloud_db_user if 'postgres' in nextcloud_db_engine else '' }}"
POSTGRES_PASSWORD:
"{{ nextcloud_db_password if 'postgres' in nextcloud_db_engine else '' }}"
POSTGRES_HOST:
"{{ nextcloud_db_host if 'postgres' in nextcloud_db_engine else '' }}"
NEXTCLOUD_TABLE_PREFIX: "{{ nextcloud_table_prefix }}"
NEXTCLOUD_ADMIN_USER: "{{ nextcloud_admin_user }}"
NEXTCLOUD_ADMIN_PASSWORD: "{{ nextcloud_admin_password }}"
NEXTCLOUD_TRUSTED_DOMAINS: "{{ nextcloud_trusted_domains | join(' ')}}"
NEXTCLOUD_UPDATE: "{{ nextcloud_update }}"
REDIS_HOST: "{{ nextcloud_redis_host }}"
REDIS_HOST_PORT: "{{ nextcloud_redis_port }}"
SMTP_HOST: "{{ nextcloud_smtp_host }}"
SMTP_SECURE: "{{ nextcloud_smtp_secure }}"
SMTP_PORT: "{{ nextcloud_smtp_port }}"
SMTP_AUTHTYPE: "{{ nextcloud_smtp_authtype }}"
SMTP_NAME: "{{ nextcloud_smtp_user }}"
SMTP_PASSWORD: "{{ nextcloud_smtp_password }}"
MAIL_FROM_ADDRESS: "{{ nextcloud_mail_from_address }}"
MAIL_DOMAIN: "{{ nextcloud_mail_domain }}"
networks:
- name: "{{ docker_network }}"
ports:
- name: export nginx config
set_fact:
nginx_config: >-
{{ nginx_config | default({}) | combine({
nextcloud_domain: {
"locations": {
'~ ^\/(?:index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|oc[ms]-provider\/.+)\.php(?:$|\/)': {
"proxy_pass": "http://{}:9001/".format(nextcloud_container)
},
'/': {
"proxy_pass": "http://{}:9002/".format(nextcloud_container)
}
}
}
}, recursive=True) }}
- name: inspect nextcloud volume
docker_volume_info:
name: "{{ nextcloud_volume }}"
register: volinfo
- name: export variables
set_fact:
nextcloud_volume: "{{ lookup('vars','nextcloud_volume') }}"
nextcloud_volume_mountpoint: "{{ volinfo.volume.Mountpoint }}"