Skip to content

Commit

Permalink
IQSS#103 use main.cf template for rhel/centos8 for idempotence's sake
Browse files Browse the repository at this point in the history
  • Loading branch information
don.sizemore committed Dec 7, 2020
1 parent 903d0db commit c41dfc0
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 18 deletions.
29 changes: 11 additions & 18 deletions tasks/postfix.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,20 @@
---

- name: install postfix
yum:
package:
name: postfix
state: latest

- name: set public hostname
lineinfile:
path: /etc/postfix/main.cf
line: 'myhostname = {{ public_hostname }}'
insertbefore: '^#myhostname'

- name: set mydomain
lineinfile:
path: /etc/postfix/main.cf
line: 'mydomain = {{ public_hostname }}'
insertbefore: '^#mydomain'

- name: set origin hostname
lineinfile:
path: /etc/postfix/main.cf
line: 'myorigin = {{ public_hostname }}'
insertbefore: '^#myorigin'
- name: place main.cf template
template:
src: main.cf.j2
dest: /etc/postfix/main.cf
owner: root
group: root
mode: '0644'
when:
- ansible_os_family == "RedHat"
- ansible_distribution_major_version == "8"

- name: enable and start postfix
systemd:
Expand Down
34 changes: 34 additions & 0 deletions templates/main.cf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
compatibility_level = 2
queue_directory = /var/spool/postfix
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
mail_owner = postfix
myhostname = {{ ansible_fqdn }}
myorigin = $myhostname
inet_interfaces = localhost
inet_protocols = all
mydestination = $myhostname, localhost.$mydomain, localhost
unknown_local_recipient_reject_code = 550
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
debug_peer_level = 2
debugger_command =
PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin
ddd $daemon_directory/$process_name $process_id & sleep 5
sendmail_path = /usr/sbin/sendmail.postfix
newaliases_path = /usr/bin/newaliases.postfix
mailq_path = /usr/bin/mailq.postfix
setgid_group = postdrop
html_directory = no
manpage_directory = /usr/share/man
sample_directory = /usr/share/doc/postfix/samples
readme_directory = /usr/share/doc/postfix/README_FILES
smtpd_tls_cert_file = /etc/pki/tls/certs/postfix.pem
smtpd_tls_key_file = /etc/pki/tls/private/postfix.key
smtpd_tls_security_level = may
smtp_tls_CApath = /etc/pki/tls/certs
smtp_tls_CAfile = /etc/pki/tls/certs/ca-bundle.crt
smtp_tls_security_level = may
meta_directory = /etc/postfix
shlib_directory = /usr/lib64/postfix

0 comments on commit c41dfc0

Please sign in to comment.