ansible-roles/evolinux-base/tasks/mail_aliases.yml
William Hirigoyen 1f8738fbda
All checks were successful
Ansible Lint |Total|New|Outstanding|Fixed|Trend |:-:|:-:|:-:|:-:|:-: |2696|33|2663|34|:+1: Reference build: <a href="https://jenkins.evolix.org/job/gitea/job/ansible-roles/job/unstable/467//ansiblelint">Evolix » ansible-roles » unstable #467</a>
gitea/ansible-roles/pipeline/head This commit looks good
postfix: move postfix installation from evolinux-base to postfix role, plus some refactoring
postfix:
* Move common packages installation in common.yml
* Replace ansible_fqdn by evolinux_fqdn, set postfix_slow_transport_include to false by default (only for packmails and packwebs)
* Remove dependency on evolinux_fqdn var
* Do not overwrite main.cf if it has been modified (except if postfix_force_main_cf)

evolinux-base:
* Move exim4 purge from evolinux-base to postfix role
* Call postfix role call after nagios role (dependency)
2024-02-01 18:00:48 +01:00

53 lines
1.2 KiB
YAML

---
- name: fetch users list
ansible.builtin.shell:
cmd: "set -o pipefail && getent passwd | cut -d':' -f 1 | grep -v root"
executable: /bin/bash
check_mode: no
register: non_root_users_list
changed_when: False
tags:
- postfix
- name: each user is aliased to root
ansible.builtin.lineinfile:
dest: /etc/aliases
regexp: "^{{ item }}:.*"
line: "{{ item }}: root"
loop: "{{ non_root_users_list.stdout_lines }}"
notify: newaliases
tags:
- postfix
when: evolinux_postfix_users_alias_root | bool
- name: additional users address aliased to root
ansible.builtin.lineinfile:
dest: /etc/aliases
regexp: "^{{ item }}:.*"
line: "{{ item }}: root"
loop:
- postmaster
- abuse
- mailer-daemon
- delay
- error
- bounce
notify: newaliases
tags:
- postfix
when: evolinux_postfix_mailer_alias_root | bool
- name: root alias is configured
ansible.builtin.lineinfile:
dest: /etc/aliases
regexp: "^root:"
line: "root: {{ postfix_alias_email or general_alert_email | mandatory }}"
notify: newaliases
tags:
- postfix
when: evolinux_postfix_root_alias | bool
- ansible.builtin.meta: flush_handlers