From 45790af73ba4aba2474a1b78c51a25328275f53d Mon Sep 17 00:00:00 2001 From: Mauro Torrez Date: Mon, 30 Sep 2019 13:09:10 -0300 Subject: [PATCH] restore lookup table logic --- tasks/lookup_tables.yml | 2 +- tasks/main.yml | 130 ++++++++++++++++++++++++++-------------- 2 files changed, 86 insertions(+), 46 deletions(-) diff --git a/tasks/lookup_tables.yml b/tasks/lookup_tables.yml index 8a57899..c1a2a30 100644 --- a/tasks/lookup_tables.yml +++ b/tasks/lookup_tables.yml @@ -48,7 +48,7 @@ {% for key in postfix_mail_domains[domain]['aliases']|default([]) -%} {{ key.alias }} {{ key.dest }} {% endfor %} - dest: "{{ postfix_mail_domains[domain].user_lookup.file | + dest: "{{ postfix_mail_domains[domain].alias_lookup.file | default('/etc/postfix/'+domain+'_aliases') | regex_replace('^/etc/postfix',postfix_mountpoint) }}" marker: "# {mark} ANSIBLE-MANAGED ALIASES" diff --git a/tasks/main.yml b/tasks/main.yml index 791ff63..7d06f76 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -105,57 +105,97 @@ register: container +- name: Exportar informacion de container + set_fact: + postfix_container: "{{ lookup('vars','postfix_container') }}" + +- when: postfix_volume[0] != '/' + block: + - name: Leer info de volumen {{ postfix_volume }} + docker_volume_info: + name: "{{ postfix_volume }}" + register: res_cfg + - name: Exportar informacion de volumen + set_fact: + postfix_volume: "{{ lookup('vars','postfix_volume') }}" + postfix_mountpoint: "{{ res_cfg.volume.Mountpoint }}" + +- when: postfix_volume[0] == '/' + block: + - name: Exportar informacion de volumen + set_fact: + postfix_volume: "{{ lookup('vars','postfix_volume') }}" + postfix_mountpoint: "{{ lookup('vars','postfix_volume') }}" + +- when: postfix_volume_ssl[0] != '/' + block: + - name: Leer info de volumen {{ postfix_volume_ssl }} + docker_volume_info: + name: "{{ postfix_volume_ssl }}" + register: res_ssl + - name: Exportar informacion de volumen + set_fact: + postfix_volume_ssl: "{{ lookup('vars','postfix_volume_ssl') }}" + postfix_mountpoint_ssl: "{{ res_ssl.volume.Mountpoint }}" + +- when: postfix_volume_ssl[0] == '/' + block: + - name: Exportar informacion de volumen + set_fact: + postfix_volume_ssl: "{{ lookup('vars','postfix_volume_ssl') }}" + postfix_mountpoint_ssl: "{{ lookup('vars','postfix_volume_ssl') }}" + # FIXME: resolver access lists y tables en Docker -# - name: Configurar lookup tables -# include_tasks: lookup_tables.yml -# loop: "{{ postfix_mail_domains.keys()|list }}" -# loop_control: -# loop_var: domain +- name: Configurar lookup tables + include_tasks: lookup_tables.yml + loop: "{{ postfix_mail_domains.keys()|list }}" + loop_control: + loop_var: domain -# - name: Template client access list -# blockinfile: -# path: "{{ postfix_mountpoint }}/{{ postfix_rules_dir }}/client_access_list" -# create: yes -# block: | -# # Edit host variable `postfix_client_access_list` to change these values -# {% for entry in postfix_client_access_list -%} -# {{ entry.regex }} {{ entry.action }} -# {% endfor %} -# notify: postmap access lists +- name: Template client access list + blockinfile: + path: "{{ postfix_mountpoint }}/{{ postfix_rules_dir }}/client_access_list" + create: yes + block: | + # Edit host variable `postfix_client_access_list` to change these values + {% for entry in postfix_client_access_list -%} + {{ entry.regex }} {{ entry.action }} + {% endfor %} + notify: postmap access lists -# - name: Template helo access list -# blockinfile: -# path: "{{ postfix_mountpoint }}/{{ postfix_rules_dir }}/helo_access_list" -# create: yes -# block: | -# # Edit host variable `postfix_helo_access_list` to change these values -# {% for entry in postfix_helo_access_list -%} -# {{ entry.host }} {{ entry.action }} -# {% endfor %} -# notify: postmap access lists +- name: Template helo access list + blockinfile: + path: "{{ postfix_mountpoint }}/{{ postfix_rules_dir }}/helo_access_list" + create: yes + block: | + # Edit host variable `postfix_helo_access_list` to change these values + {% for entry in postfix_helo_access_list -%} + {{ entry.host }} {{ entry.action }} + {% endfor %} + notify: postmap access lists -# - name: Template recipient access list -# blockinfile: -# path: "{{ postfix_mountpoint }}/{{ postfix_rules_dir }}/recipient_access_list" -# create: yes -# block: | -# # Edit host variable `postfix_recipient_access_list` to change these values -# {% for entry in postfix_recipient_access_list -%} -# {{ entry.rcpt }} {{ entry.action }} -# {% endfor %} -# notify: postmap access lists +- name: Template recipient access list + blockinfile: + path: "{{ postfix_mountpoint }}/{{ postfix_rules_dir }}/recipient_access_list" + create: yes + block: | + # Edit host variable `postfix_recipient_access_list` to change these values + {% for entry in postfix_recipient_access_list -%} + {{ entry.rcpt }} {{ entry.action }} + {% endfor %} + notify: postmap access lists -# - name: Template sender access list -# blockinfile: -# path: "{{ postfix_mountpoint }}/{{ postfix_rules_dir }}/sender_access_list" -# create: yes -# block: | -# # Edit host variable `postfix_sender_access_list` to change these values -# {% for entry in postfix_sender_access_list -%} -# {{ entry.sender }} {{ entry.action }} -# {% endfor %} -# notify: postmap access lists +- name: Template sender access list + blockinfile: + path: "{{ postfix_mountpoint }}/{{ postfix_rules_dir }}/sender_access_list" + create: yes + block: | + # Edit host variable `postfix_sender_access_list` to change these values + {% for entry in postfix_sender_access_list -%} + {{ entry.sender }} {{ entry.action }} + {% endfor %} + notify: postmap access lists # TODO: mensajes