From 7ad695f01d9800521273398fca2e65b555f1332f Mon Sep 17 00:00:00 2001 From: Adrien Waksberg Date: Fri, 20 Aug 2021 18:30:38 +0200 Subject: [PATCH] feat: add transport map --- CHANGELOG.md | 1 + README.md | 6 ++++++ defaults/main.yml | 1 + handlers/main.yml | 3 +++ tasks/main.yml | 10 ++++++++++ templates/transport.j2 | 5 +++++ 6 files changed, 26 insertions(+) create mode 100644 templates/transport.j2 diff --git a/CHANGELOG.md b/CHANGELOG.md index 4811816..296612a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ Which is based on [Keep A Changelog](http://keepachangelog.com/) ### Added - feat: add bsd-mailx package +- feat: add transport map ### Changed diff --git a/README.md b/README.md index 46c69bd..06ec6ad 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,12 @@ Install and configure an simple mta with postfix inet_protocols: all ``` +* `postfix_transports` - hash with the transport configuration + +``` + google.com: smtp:127.0.0.1 +``` + ## How to use ``` diff --git a/defaults/main.yml b/defaults/main.yml index 823fe30..a90b837 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -18,3 +18,4 @@ postfix_default_config: inet_interfaces: localhost inet_protocols: all postfix_full_config: '{{ postfix_default_config|combine(postfix_config) }}' +postfix_transports: {} diff --git a/handlers/main.yml b/handlers/main.yml index ce984dc..5f6be52 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -3,3 +3,6 @@ ansible.builtin.service: name: postfix state: reloaded + +- name: map transport + ansible.builtin.command: postmap /etc/postfix/transport diff --git a/tasks/main.yml b/tasks/main.yml index 27f45bc..81844c4 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -16,6 +16,16 @@ notify: reload postfix tags: postfix +- name: copy transport configuration + template: + src: transport.j2 + dest: /etc/postfix/transport + owner: root + group: root + mode: 0644 + notify: map transport + tags: postfix + - name: enable and start service ansible.builtin.service: name: postfix diff --git a/templates/transport.j2 b/templates/transport.j2 new file mode 100644 index 0000000..f425a08 --- /dev/null +++ b/templates/transport.j2 @@ -0,0 +1,5 @@ +# {{ ansible_managed }} + +{% for domain, transport in postfix_transports.items() %} +{{ domain }} {{ transport }} +{% endfor %}