# HG changeset patch # User IBBoard # Date 1581968746 0 # Node ID 01d1b0f6dbaffce6073047015893ebf64b297de5 # Parent 1bfc290270cc2cde35f24d49e6f4c7ab7dc63b18 Fix more IPv4 vs IPv6 settings Postfix wouldn't look up "localhost" but accepts IPs Checking for the existance of "ipaddress" covers us for now as a work-around, because IPv6-only doesn't have "ipaddress" but "IPv4 with IPv6 link-local" does have "ipaddress6" diff -r 1bfc290270cc -r 01d1b0f6dbaf manifests/templates.pp --- a/manifests/templates.pp Mon Feb 17 18:45:06 2020 +0000 +++ b/manifests/templates.pp Mon Feb 17 19:45:46 2020 +0000 @@ -42,10 +42,14 @@ } #VPS is a self-mastered Puppet machine, so bodge a Hosts file + if $primary_ip =~ Stdlib::IP::Address::V6 { + $lo_ip = '::1' + } else { + $lo_ip = '127.0.0.1' + } file { '/etc/hosts': ensure => present, - content => "127.0.0.1 localhost -$primary_ip ${fqdn}", + content => "${lo_ip} localhost\n${primary_ip} ${fqdn}", } require repos @@ -706,7 +710,7 @@ ){ class { 'postfix': mailserver => $mailserver, - protocols => 'ipv4', + protocols => has_key($facts, 'ipaddress') ? { true => 'ipv4', default => 'ipv6' }, } class { 'dovecot': imapserver => $imapserver, diff -r 1bfc290270cc -r 01d1b0f6dbaf modules/postfix/manifests/init.pp --- a/modules/postfix/manifests/init.pp Mon Feb 17 18:45:06 2020 +0000 +++ b/modules/postfix/manifests/init.pp Mon Feb 17 19:45:46 2020 +0000 @@ -2,6 +2,15 @@ $mailserver, $protocols='all' ){ + + if has_key($facts, 'ipaddress') { + $lo_ip = '127.0.0.1' + $lo_networks = '127.0.0.0/8' + } else { + $lo_ip = '[::1]' + $lo_networks = '[::1]' + } + package { 'sendmail': ensure => 'absent', } @@ -31,10 +40,7 @@ content => template('postfix/main.cf.erb'), } file { '/etc/postfix/master.cf': - source => [ - "puppet:///modules/postfix/master.${operatingsystem}${operatingsystemmajrelease}.cf", - 'puppet:///modules/postfix/master.cf' - ] + content => template('postfix/master.cf.erb'), } #Hosted domains file { '/etc/postfix/vdomains': diff -r 1bfc290270cc -r 01d1b0f6dbaf modules/postfix/templates/main.cf.erb --- a/modules/postfix/templates/main.cf.erb Mon Feb 17 18:45:06 2020 +0000 +++ b/modules/postfix/templates/main.cf.erb Mon Feb 17 19:45:46 2020 +0000 @@ -8,8 +8,9 @@ inet_interfaces = all inet_protocols = <%= @protocols %> mydestination = $myhostname, localhost.$mydomain, localhost +smtp_host_lookup = dns, native unknown_local_recipient_reject_code = 550 -mynetworks = 127.0.0.0/8 +mynetworks = <%= @lo_networks %> relay_domains = alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases @@ -86,4 +87,4 @@ postscreen_access_list = permit_mynetworks, cidr:/etc/postfix/postscreen_access_private.cidr, cidr:/etc/postfix/postscreen_spf_whitelist.cidr postscreen_blacklist_action = enforce -content_filter = smtp-amavis:[127.0.0.1]:10024 +content_filter = smtp-amavis:<%= @lo_ip %>:10024