Execution
Date 20 Mar 2026 09:02:32 +0000
Duration 00:00:22.16
Controller ssh-gw-4.layershift.com
User root
Versions
Ansible 2.16.13
ara 1.7.4 / 1.7.4
Python 3.10.10
Summary
25 Hosts
2 Tasks
50 Results
1 Plays
1 Files
0 Records

File: /home/ssh-gateway/ansible/kuly/RM10331-deploy_postmark_postfix.yaml

---
- name: Playbook to install postmark and postfix
  hosts: all
  gather_facts: false
  tasks:
    - name: Remove postfix and sendmail
      tags: redeploy
      ansible.builtin.shell: |
        set -o pipefail
        dnf -y remove postfix sendmail
        rm -rf /etc/postfix/
        dnf -y install postfix cyrus-sasl-plain s-nail
        echo -e "\n#Sending all emails through postmark" >> /etc/postfix/main.cf
        echo "relayhost = [smtp.postmarkapp.com]:587" >> /etc/postfix/main.cf
        echo "smtp_sasl_auth_enable = yes" >> /etc/postfix/main.cf
        echo "smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd" >> /etc/postfix/main.cf
        echo "smtp_sasl_security_options = noanonymous" >> /etc/postfix/main.cf
        echo "smtp_tls_security_level = may" >> /etc/postfix/main.cf
        echo "smtp_tls_loglevel = 1" >> /etc/postfix/main.cf
        echo "smtp_always_send_ehlo = yes" >> /etc/postfix/main.cf
        echo "[smtp.postmarkapp.com]:587 PM-T-mdmonitor-VLXylaXkYUznVO0nZVOX1:0ZnmCrZdSdpJGPGqoyQ2jukwGTrcyUb8Q5KI" > /etc/postfix/sasl_passwd
        echo "#end postmark" >> /etc/postfix/main.cf
        chmod 600 /etc/postfix/sasl_passwd
        postmap /etc/postfix/sasl_passwd
        systemctl enable --now postfix.service
        systemctl --no-pager status postfix.service
      args:
        executable: /bin/bash
      changed_when: false
    - name: Set email alias for user root
      tags: newaliases
      ansible.builtin.shell: |
        set -o pipefail
        sed -i '/root:/d' /etc/aliases
        echo "root:           opsmonitor@layershift.com" >> /etc/aliases
        newaliases
        systemctl restart postfix.service
        systemctl --no-pager status postfix.service
      args:
        executable: /bin/bash
      changed_when: false