forked from mauro/ansible-role-mariadb-docker
Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
aef469fa91 | ||
|
|
35cd435135 | ||
|
|
769c69f166 | ||
|
|
9f8f664ed7 | ||
| 33eda44c16 | |||
|
|
23aba0b59e | ||
|
|
188f7f87ac | ||
|
|
1378d4d677 | ||
|
|
9fbe0c3a20 | ||
|
|
18fb1c7445 | ||
|
|
d66cd019d6 | ||
|
|
e5507857df | ||
|
|
d8ce72e9d1 | ||
|
|
5d36d9edc5 | ||
|
|
a9ff4f484b | ||
|
|
4c6f2f31da | ||
|
|
b049fb68a9 | ||
|
|
2610cd4ef1 | ||
|
|
ed73b0bc2e | ||
|
|
f04a93096a | ||
|
|
a47d2c8380 |
@@ -1,25 +1,39 @@
|
|||||||
---
|
---
|
||||||
# domain, webroot
|
# domain, webroot
|
||||||
wordpress_domain: example.com
|
roundcube_domain: default
|
||||||
wordpress_web_root: /
|
roundcube_web_root: /roundcube
|
||||||
|
roundcube_version: 1.3.10
|
||||||
# database
|
|
||||||
wordpress_db_host: localhost
|
|
||||||
wordpress_db_user: wordpress
|
|
||||||
wordpress_db_password: password
|
|
||||||
wordpress_db_name: wordpress
|
|
||||||
wordpress_table_prefix: wp
|
|
||||||
|
|
||||||
# debug: cualquier valor distinto de "" es si
|
|
||||||
wordpress_debug: ""
|
|
||||||
|
|
||||||
# configuracion extra - va literal al config.php
|
|
||||||
wordpress_config_extra: ""
|
|
||||||
|
|
||||||
# container
|
# container
|
||||||
wordpress_image: wordpress
|
roundcube_image: eumau/roundcubemail:{{ roundcube_version }}
|
||||||
wordpress_container: wordpress
|
roundcube_container: roundcube
|
||||||
wordpress_volume: wordpress
|
roundcube_volume: roundcube
|
||||||
|
|
||||||
|
# mysql, mariadb, postgresql
|
||||||
|
roundcube_db_type: sqlite
|
||||||
|
roundcube_db_host: localhost
|
||||||
|
roundcube_db_port: "{{ '5432' if 'post' in roundcube_db_type else '3306' }}"
|
||||||
|
roundcube_db_user: roundcube
|
||||||
|
roundcube_db_password: password
|
||||||
|
roundcube_db_name:
|
||||||
|
roundcube{{ '.sqlite' if roundcube_db_type == 'sqlite' else '' }}
|
||||||
|
|
||||||
|
# data dir (inside container)
|
||||||
|
roundcube_data_dir: /var/www/html
|
||||||
|
|
||||||
|
# imap
|
||||||
|
roundcube_imap_host: "tls://{{ dovecot_container | default('localhost') }}"
|
||||||
|
roundcube_imap_port: "143"
|
||||||
|
|
||||||
|
# smtp
|
||||||
|
roundcube_smtp_host: "tls://{{ postfix_container | default('localhost') }}"
|
||||||
|
roundcube_smtp_port: "587"
|
||||||
|
|
||||||
|
# plugins
|
||||||
|
roundcube_plugins: []
|
||||||
|
|
||||||
|
# upload max filesize
|
||||||
|
roundcube_upload_max_filesize: 40M
|
||||||
|
|
||||||
# definido por rol docker
|
# definido por rol docker
|
||||||
docker_network_name: dockernet
|
docker_network_name: dockernet
|
||||||
|
|||||||
145
tasks/main.yml
145
tasks/main.yml
@@ -1,95 +1,108 @@
|
|||||||
---
|
---
|
||||||
- name: create wordpress database
|
# TODO: postgres support
|
||||||
|
# - name: create roundcube database (pg)
|
||||||
|
# postgresql_db:
|
||||||
|
# state: present
|
||||||
|
# name: "{{ roundcube_db_name }}"
|
||||||
|
# login_host: "{{ postgresql_host }}"
|
||||||
|
# login_port: "{{ postgresql_port }}"
|
||||||
|
# login_user: "{{ postgresql_root_password }}"
|
||||||
|
# login_password: "{{ postgresql_root_password }}"
|
||||||
|
|
||||||
|
# - name: create roundcube db user (pg)
|
||||||
|
# postgresql_user:
|
||||||
|
# state: present
|
||||||
|
# name: "{{ roundcube_db_user }}"
|
||||||
|
# password: "{{ roundcube_db_password }}"
|
||||||
|
# priv: "{{ roundcube_db_name }}.*:ALL"
|
||||||
|
# login_host: "{{ postgresql_host }}"
|
||||||
|
# login_port: "{{ postgresql_port }}"
|
||||||
|
# login_user: root
|
||||||
|
# login_password: "{{ postgresql_root_password }}"
|
||||||
|
|
||||||
|
- name: create roundcube database
|
||||||
mysql_db:
|
mysql_db:
|
||||||
state: present
|
state: present
|
||||||
name: "{{ wordpress_db_name }}"
|
name: "{{ roundcube_db_name }}"
|
||||||
login_host: "{{ mariadb_host }}"
|
login_host: "{{ mariadb_host }}"
|
||||||
login_port: "{{ mariadb_port }}"
|
login_port: "{{ mariadb_port }}"
|
||||||
login_user: root
|
login_user: root
|
||||||
login_password: "{{ mariadb_root_password }}"
|
login_password: "{{ mariadb_root_password }}"
|
||||||
|
when: roundcube_db_type in ('mariadb','mysql')
|
||||||
|
|
||||||
- name: create wordpress db user
|
- name: create roundcube db user
|
||||||
mysql_user:
|
mysql_user:
|
||||||
state: present
|
state: present
|
||||||
name: "{{ wordpress_db_user }}"
|
name: "{{ roundcube_db_user }}"
|
||||||
host: "%"
|
host: "%"
|
||||||
password: "{{ wordpress_db_password }}"
|
password: "{{ roundcube_db_password }}"
|
||||||
priv: "{{ wordpress_db_name }}.*:ALL"
|
priv: "{{ roundcube_db_name }}.*:ALL"
|
||||||
login_host: "{{ mariadb_host }}"
|
login_host: "{{ mariadb_host }}"
|
||||||
login_port: "{{ mariadb_port }}"
|
login_port: "{{ mariadb_port }}"
|
||||||
login_user: root
|
login_user: root
|
||||||
login_password: "{{ mariadb_root_password }}"
|
login_password: "{{ mariadb_root_password }}"
|
||||||
|
when: roundcube_db_type in ('mariadb','mysql')
|
||||||
|
|
||||||
- name: start wordpress container
|
- name: start roundcube container
|
||||||
docker_container:
|
docker_container:
|
||||||
image: "{{ wordpress_image }}"
|
image: "{{ roundcube_image }}"
|
||||||
name: "{{ wordpress_container }}"
|
name: "{{ roundcube_container }}"
|
||||||
volumes:
|
volumes:
|
||||||
- "{{ wordpress_volume }}:/var/www/html"
|
- "{{ roundcube_volume }}:/var/www/html"
|
||||||
env:
|
env:
|
||||||
WORDPRESS_DB_HOST: "{{ mariadb_container }}"
|
ROUNDCUBEMAIL_DEFAULT_HOST: "{{ roundcube_imap_host }}"
|
||||||
WORDPRESS_DB_USER: "{{ wordpress_db_user }}"
|
ROUNDCUBEMAIL_DEFAULT_PORT: "{{ roundcube_imap_port }}"
|
||||||
WORDPRESS_DB_PASSWORD: "{{ wordpress_db_password }}"
|
ROUNDCUBEMAIL_SMTP_SERVER: "{{ roundcube_smtp_host }}"
|
||||||
WORDPRESS_DB_NAME: "{{ wordpress_db_name }}"
|
ROUNDCUBEMAIL_SMTP_PORT: "{{ roundcube_smtp_port }}"
|
||||||
WORDPRESS_TABLE_PREFIX: "{{ wordpress_table_prefix }}"
|
ROUNDCUBEMAIL_PLUGINS: "{{ roundcube_plugins | join (',') }}"
|
||||||
# (default to unique random SHA1s, but only if other environment
|
ROUNDCUBEMAIL_UPLOAD_MAX_FILESIZE: "{{ roundcube_upload_max_filesize }}"
|
||||||
# variable configuration is provided)
|
ROUNDCUBEMAIL_DB_TYPE: "{{ roundcube_db_type }}"
|
||||||
# WORDPRESS_AUTH_KEY:
|
ROUNDCUBEMAIL_DB_HOST: "{{ roundcube_db_host }}"
|
||||||
# WORDPRESS_SECURE_AUTH_KEY:
|
ROUNDCUBEMAIL_DB_PORT: "{{ roundcube_db_port }}"
|
||||||
# WORDPRESS_LOGGED_IN_KEY:
|
ROUNDCUBEMAIL_DB_USER: "{{ roundcube_db_user }}"
|
||||||
# WORDPRESS_NONCE_KEY:
|
ROUNDCUBEMAIL_DB_PASSWORD: "{{ roundcube_db_password }}"
|
||||||
# WORDPRESS_AUTH_SALT:
|
ROUNDCUBEMAIL_DB_NAME: "{{ roundcube_db_name }}"
|
||||||
# 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 }}"
|
|
||||||
networks:
|
networks:
|
||||||
- name: "{{ docker_network_name }}"
|
- name: "{{ docker_network_name }}"
|
||||||
ports:
|
ports:
|
||||||
|
|
||||||
- name: template nginx config
|
- name: export nginx config
|
||||||
copy:
|
set_fact:
|
||||||
content: |
|
nginx_config: >-
|
||||||
server {
|
{{ nginx_config | default({}) | combine({
|
||||||
listen 80; # para debug
|
roundcube_domain: {
|
||||||
listen 443 ssl;
|
"locations": {
|
||||||
server_name {{ wordpress_domain }};
|
roundcube_web_root.rstrip('/')+'/': {
|
||||||
|
"proxy_pass": "http://{}:9080/".format(roundcube_container)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, recursive=True) }}
|
||||||
|
|
||||||
# root /var/www/html;
|
- name: inspect roundcube volume
|
||||||
# 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 }};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dest: "{{ nginx_config_mountpoint }}/wordpress.conf"
|
|
||||||
register: ngconf
|
|
||||||
|
|
||||||
- name: restart frontend
|
|
||||||
docker_container:
|
|
||||||
name: "{{ nginx_container_name }}"
|
|
||||||
restart: yes
|
|
||||||
when: ngconf is changed
|
|
||||||
|
|
||||||
- name: inspect wordpress volume
|
|
||||||
docker_volume_info:
|
docker_volume_info:
|
||||||
name: "{{ wordpress_volume }}"
|
name: "{{ roundcube_volume }}"
|
||||||
register: volinfo
|
register: volinfo
|
||||||
|
|
||||||
- name: export variables
|
- name: export variables
|
||||||
set_fact:
|
set_fact:
|
||||||
wordpress_volume: "{{ lookup('vars','wordpress_volume') }}"
|
roundcube_volume: "{{ lookup('vars','roundcube_volume') }}"
|
||||||
wordpress_volume_mountpoint: "{{ volinfo.volume.Mountpoint }}"
|
roundcube_volume_mountpoint: "{{ volinfo.volume.Mountpoint }}"
|
||||||
|
|
||||||
|
- name: allow self-signed mail server certs
|
||||||
|
blockinfile:
|
||||||
|
state: present
|
||||||
|
path: "{{ roundcube_volume_mountpoint }}/config/config.inc.php"
|
||||||
|
block: |
|
||||||
|
$config['imap_conn_options'] = array(
|
||||||
|
'ssl' => array(
|
||||||
|
'verify_peer' => false,
|
||||||
|
'verify_peer_name' => false,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
$config['smtp_conn_options'] = array(
|
||||||
|
'ssl' => array(
|
||||||
|
'verify_peer' => false,
|
||||||
|
'verify_peer_name' => false,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user