From a47d2c838047c4c72055ac10adc518f390f396c5 Mon Sep 17 00:00:00 2001 From: Mauro Torrez Date: Wed, 28 Aug 2019 18:13:39 -0300 Subject: [PATCH] commit inicial --- defaults/main.yml | 60 +++++++++++++++++----- tasks/main.yml | 128 +++++++++++++++++++++++++++------------------- 2 files changed, 120 insertions(+), 68 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index 3340501..464c6a1 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,25 +1,57 @@ --- # domain, webroot -wordpress_domain: example.com -wordpress_web_root: / +nextcloud_domain: example.com +nextcloud_web_root: / # database -wordpress_db_host: localhost -wordpress_db_user: wordpress -wordpress_db_password: password -wordpress_db_name: wordpress -wordpress_table_prefix: wp +nextcloud_db_engine: sqlite -# debug: cualquier valor distinto de "" es si -wordpress_debug: "" +# db name or path (sqlite) +nextcloud_db_name: nextcloud -# configuracion extra - va literal al config.php -wordpress_config_extra: "" +# mysql, mariadb, postgresql +nextcloud_db_host: localhost +nextcloud_db_user: nextcloud +nextcloud_db_password: password +nextcloud_table_prefix: "" + +# data dir (inside container) +nextcloud_data_dir: /var/www/html/data + +# admin user +nextcloud_admin_user: admin +nextcloud_admin_password: password + +# space separated trusted domains +nextcloud_trusted_domains: "" + +# The install and update script is only triggered when a default command +# is used (apache-foreground or php-fpm). If you use a custom command +# you have to enable the install / update with +nextcloud_update: "" + +# The use of Redis is recommended to prevent file locking problems. See +# the examples for further instructions. +# If you want to use Redis you have to create a separate Redis container +# in your setup / in your docker-compose file. To inform Nextcloud about +# the Redis container add: +nextcloud_redis_host: "" +nextcloud_redis_port: "6379" + +# smtp +nextcloud_smtp_host: "" +nextcloud_smtp_secure: "" +nextcloud_smtp_port: "" +nextcloud_smtp_authtype: LOGIN +nextcloud_smtp_user: "" +nextcloud_smtp_password: "" +nextcloud_mail_from_address: "" +nextcloud_mail_domain: "" # container -wordpress_image: wordpress -wordpress_container: wordpress -wordpress_volume: wordpress +nextcloud_image: nextcloud +nextcloud_container: nextcloud +nextcloud_volume: nextcloud # definido por rol docker docker_network_name: dockernet diff --git a/tasks/main.yml b/tasks/main.yml index 007bc8e..184521d 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,56 +1,86 @@ --- -- name: create wordpress database +# 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: "{{ wordpress_db_name }}" + name: "{{ nextcloud_db_name }}" login_host: "{{ mariadb_host }}" login_port: "{{ mariadb_port }}" login_user: root login_password: "{{ mariadb_root_password }}" -- name: create wordpress db user +- name: create nextcloud db user mysql_user: state: present - name: "{{ wordpress_db_user }}" + name: "{{ nextcloud_db_user }}" host: "%" - password: "{{ wordpress_db_password }}" - priv: "{{ wordpress_db_name }}.*:ALL" + 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 }}" -- name: start wordpress container +- name: start nextcloud container docker_container: - image: "{{ wordpress_image }}" - name: "{{ wordpress_container }}" + image: "{{ nextcloud_image }}" + name: "{{ nextcloud_container }}" volumes: - - "{{ wordpress_volume }}:/var/www/html" + - "{{ nextcloud_volume }}:/var/www/html" env: - WORDPRESS_DB_HOST: "{{ mariadb_container }}" - WORDPRESS_DB_USER: "{{ wordpress_db_user }}" - WORDPRESS_DB_PASSWORD: "{{ wordpress_db_password }}" - WORDPRESS_DB_NAME: "{{ wordpress_db_name }}" - WORDPRESS_TABLE_PREFIX: "{{ wordpress_table_prefix }}" - # (default to unique random SHA1s, but only if other environment - # variable configuration is provided) - # WORDPRESS_AUTH_KEY: - # WORDPRESS_SECURE_AUTH_KEY: - # WORDPRESS_LOGGED_IN_KEY: - # WORDPRESS_NONCE_KEY: - # WORDPRESS_AUTH_SALT: - # WORDPRESS_SECURE_AUTH_SALT: - # WORDPRESS_LOGGED_IN_SALT: - # WORDPRESS_NONCE_SALT: - # (defaults to disabled, non-empty value will enable WP_DEBUG in - # wp-config.php) - WORDPRESS_DEBUG: "{{ wordpress_debug }}" - # (defaults to nothing, non-empty value will be embedded verbatim - # inside wp-config.php -- especially useful for applying extra - # configuration values this image does not provide by default such - # as WP_ALLOW_MULTISITE; see docker-library/wordpress#142 for more - # details) - WORDPRESS_CONFIG_EXTRA: "{{ wordpress_config_extra }}" + 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 }}" + 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_name }}" ports: @@ -58,24 +88,14 @@ - name: template nginx config copy: content: | - server { - listen 80; # para debug - listen 443 ssl; - server_name {{ wordpress_domain }}; - # root /var/www/html; - # index index.php index.html; - # access_log /dev/stdout; - # error_log /dev/stdout info; - - location {{ wordpress_web_root }} { - proxy_set_header Host $host; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header X-Forwarded-Proto $scheme; - proxy_pass http://{{ wordpress_container }}; - } + location {{ nextcloud_web_root }} { + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_pass http://{{ nextcloud_container }}; } - dest: "{{ nginx_config_mountpoint }}/wordpress.conf" + dest: "{{ nginx_location }}/nextcloud.conf" register: ngconf - name: restart frontend @@ -84,12 +104,12 @@ restart: yes when: ngconf is changed -- name: inspect wordpress volume +- name: inspect nextcloud volume docker_volume_info: - name: "{{ wordpress_volume }}" + name: "{{ nextcloud_volume }}" register: volinfo - name: export variables set_fact: - wordpress_volume: "{{ lookup('vars','wordpress_volume') }}" - wordpress_volume_mountpoint: "{{ volinfo.volume.Mountpoint }}" + nextcloud_volume: "{{ lookup('vars','nextcloud_volume') }}" + nextcloud_volume_mountpoint: "{{ volinfo.volume.Mountpoint }}"