commit inicial docker

This commit is contained in:
Mauro Torrez
2019-09-08 13:47:21 -03:00
parent 431114680c
commit f02b759ff3
16 changed files with 181 additions and 292 deletions

View File

@@ -1,85 +1,97 @@
---
- name: Instalar paquetes
apt:
state: present
name: >-
[ "dovecot-lmtpd",
"ssl-cert",
{% if dovecot_proto_imap_enable or dovecot_proto_imaps_enable -%}
"dovecot-imapd",
{% endif %}
{% if dovecot_proto_pop3_enable or dovecot_proto_pop3s_enable -%}
"dovecot-pop3d",
{% endif %}
{% if dovecot_ldap_enable -%}
"dovecot-ldap",
{% endif %}
{% if dovecot_sieve_enable -%}
"dovecot-sieve",
{% endif %}
{% if dovecot_proto_managesieve_enable -%}
"dovecot-managesieved",
{% endif %}
{% if dovecot_antispam_enable -%}
"dovecot-antispam",
{% endif %}
]
- name: Crear grupo para el mail
group:
name: "{{ dovecot_mail_group }}"
gid: "{{ dovecot_mail_gid }}"
- name: Crear usuario para el mail
user:
name: "{{ dovecot_mail_user }}"
uid: "{{ dovecot_mail_uid }}"
group: "{{ dovecot_mail_group }}"
home: "{{ dovecot_mail_home }}"
shell: /bin/false
- name: Directorios de configuración de Dovecot
- name: Directorio de build dovecot
file:
path: "{{ item }}"
path: /root/.dovecot-docker-image
state: directory
tags: skip_me
- name: Copiar archivos de build
copy:
src: "{{ item }}"
dest: /root/.dovecot-docker-image
loop:
- /etc/dovecot/conf.d
- "{{ dovecot_sieve_before }}"
- "{{ dovecot_sieve_after }}"
- Dockerfile
- 10-mail.conf
- 10-master.conf
- 10-ssl.conf
- 11-quota.conf
- 15-mailboxes.conf
- 20-imap.conf
- 90-antispam.conf
- 90-sieve.conf
- auth-ldap.conf.ext
- auth-master.conf.ext
- junk-filter.sieve
tags: skip_me
- name: Crear imagen {{ dovecot_image }}
docker_image:
state: present
name: "{{ dovecot_image }}"
path: /root/.dovecot-docker-image
tags: skip_me
- name: Activar container dovecot
docker_container:
name: "{{ dovecot_container }}"
state: started
restart_policy: unless-stopped
image: "{{ dovecot_image }}"
volumes:
- "{{ dovecot_volume_config }}:/etc/dovecot/"
- "{{ dovecot_volume_mail }}:/vmail/"
- "{{ dovecot_volume_ssl }}:/ssl/"
networks:
- name: "{{ docker_network_name }}"
ports:
- 143:143
- 2000:2000
env:
register: container
- name: Leer info de volumen {{ dovecot_volume_config }}
docker_volume_info:
name: "{{ dovecot_volume_config }}"
register: res_cfg
- name: Leer info de volumen {{ dovecot_volume_mail }}
docker_volume_info:
name: "{{ dovecot_volume_mail }}"
register: res_mail
- name: Leer info de volumen {{ dovecot_volume_ssl }}
docker_volume_info:
name: "{{ dovecot_volume_ssl }}"
register: res_ssl
- name: Exportar informacion de volumen
set_fact:
dovecot_container: "{{ lookup('vars','dovecot_container') }}"
dovecot_volume_config: "{{ lookup('vars','dovecot_volume_config') }}"
dovecot_mountpoint_config: "{{ res_cfg.volume.Mountpoint }}"
dovecot_volume_mail: "{{ lookup('vars','dovecot_volume_mail') }}"
dovecot_mountpoint_mail: "{{ res_mail.volume.Mountpoint }}"
dovecot_volume_ssl: "{{ lookup('vars','dovecot_volume_ssl') }}"
dovecot_mountpoint_ssl: "{{ res_ssl.volume.Mountpoint }}"
- name: Configuración de Dovecot (1)
template:
dest: "/etc/dovecot/conf.d/{{ item }}"
dest: "{{ dovecot_mountpoint_config }}/conf.d/{{ item }}"
src: "{{item}}.j2"
loop:
- 10-mail.conf
- 10-auth.conf
- 10-ssl.conf
- 20-lmtp.conf
- 20-imap.conf
- 10-master.conf
- auth-ldap.conf.ext
- 15-mailboxes.conf
- 90-sieve.conf
- 90-quota.conf
- 90-antispam.conf
notify: restart dovecot
- name: Configuración de Dovecot (2-LDAP)
template:
dest: "/etc/dovecot/dovecot-ldap.conf.ext"
dest: "{{ dovecot_mountpoint_config }}/dovecot-ldap.conf.ext"
src: "dovecot-ldap.conf.ext.j2"
notify: restart dovecot
- name: Configuración de Dovecot (3-LDAP)
file:
src: dovecot-ldap.conf.ext
dest: /etc/dovecot/dovecot-ldap2.conf.ext
state: link
notify: restart dovecot
- name: Filtro de spam global
template:
src: junk-filter.sieve.j2
dest: "{{ dovecot_sieve_before }}/junk-filter.sieve"
notify: recompile sieve scripts
dest: "{{ dovecot_mountpoint_config }}/dovecot-ldap2.conf.ext"
src: "dovecot-ldap.conf.ext.j2"
notify: restart dovecot