diff --git a/tasks/main.yml b/tasks/main.yml index d2d1350..29d8634 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -75,16 +75,12 @@ - postfix-sasl-passwd - name: configure aliases - lineinfile: + template: + src: etc/aliases.j2 dest: "{{ postfix_aliases_file }}" - regexp: '^{{ item.user | regex_escape }}.*' - line: '{{ item.user }}: {{ item.alias }}' owner: root group: root mode: 0644 - create: true - state: present - with_items: "{{ postfix_aliases }}" notify: - new aliases - restart postfix diff --git a/templates/etc/aliases.j2 b/templates/etc/aliases.j2 new file mode 100644 index 0000000..8dedf5e --- /dev/null +++ b/templates/etc/aliases.j2 @@ -0,0 +1,7 @@ +{{ ansible_managed | comment }} +# See man 5 aliases for format + +postmaster: root +{% for alias in postfix_aliases %} +{{ alias.user }}: {{ alias.alias }} +{% endfor %}