Align Postfix identity with system hostname on PMG nodes.

Add an idempotent baseline step that enforces myhostname/mydomain from hostname -f and reloads postfix only when drift is detected.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Ruslan Petrovich
2026-06-24 21:31:53 +03:00
co-authored by Cursor
parent 664a544aa9
commit 1ec315d96c
+15
View File
@@ -17,6 +17,21 @@ pmg-cluster-status:
cmd.run: cmd.run:
- name: pmgcm status - name: pmgcm status
pmg-postfix-identity-from-system-hostname:
cmd.run:
- name: >-
HN="$(hostname -f)" &&
DM="${HN#*.}" &&
postconf -e "myhostname=${HN}" "mydomain=${DM}" &&
systemctl reload postfix
- unless: >-
HN="$(hostname -f)" &&
DM="${HN#*.}" &&
[ "$(postconf -h myhostname)" = "${HN}" ] &&
[ "$(postconf -h mydomain)" = "${DM}" ]
- require:
- service: pmg-service-postfix
{% if manage_hosts_file %} {% if manage_hosts_file %}
pmg-managed-hosts: pmg-managed-hosts:
file.blockreplace: file.blockreplace: