bundles/postfix: mynetworks now supports identifiers
This commit is contained in:
parent
b7222e2cd1
commit
61c6188454
2 changed files with 25 additions and 1 deletions
|
@ -6,7 +6,7 @@ compatibility_level = 2
|
||||||
myhostname = ${node.metadata.get('postfix/myhostname', node.metadata['hostname'])}
|
myhostname = ${node.metadata.get('postfix/myhostname', node.metadata['hostname'])}
|
||||||
myorigin = /etc/mailname
|
myorigin = /etc/mailname
|
||||||
mydestination = $myhostname, localhost
|
mydestination = $myhostname, localhost
|
||||||
mynetworks = 127.0.0.0/8 [::1]/128 [::ffff:127.0.0.0]/104 ${' '.join(sorted(node.metadata.get('postfix/mynetworks', set())))}
|
mynetworks = ${' '.join(sorted(mynetworks))}
|
||||||
mailbox_size_limit = 0
|
mailbox_size_limit = 0
|
||||||
recipient_delimiter = +
|
recipient_delimiter = +
|
||||||
inet_protocols = all
|
inet_protocols = all
|
||||||
|
|
|
@ -1,6 +1,27 @@
|
||||||
if node.has_bundle('postfixadmin'):
|
if node.has_bundle('postfixadmin'):
|
||||||
assert node.has_bundle('letsencrypt')
|
assert node.has_bundle('letsencrypt')
|
||||||
|
|
||||||
|
mynetworks = {
|
||||||
|
'127.0.0.0/8',
|
||||||
|
'[::1]/128',
|
||||||
|
'[::ffff:127.0.0.0]/104',
|
||||||
|
}
|
||||||
|
for identifier in node.metadata.get('postfix/mynetworks', set()):
|
||||||
|
print(identifier)
|
||||||
|
ips = repo.libs.tools.resolve_identifier(repo, identifier)
|
||||||
|
|
||||||
|
for ip in ips['ipv4']:
|
||||||
|
mynetworks.add(str(ip))
|
||||||
|
|
||||||
|
for ip in ips['ipv6']:
|
||||||
|
ip = str(ip)
|
||||||
|
if '/' in ip:
|
||||||
|
ip6, netmask = ip.split('/', 2)
|
||||||
|
else:
|
||||||
|
ip6 = ip
|
||||||
|
netmask = '128'
|
||||||
|
mynetworks.add(f'[{ip6}]/{netmask}')
|
||||||
|
|
||||||
files = {
|
files = {
|
||||||
'/etc/mailname': {
|
'/etc/mailname': {
|
||||||
'content': node.metadata.get('postfix/myhostname', node.metadata['hostname']),
|
'content': node.metadata.get('postfix/myhostname', node.metadata['hostname']),
|
||||||
|
@ -22,6 +43,9 @@ files = {
|
||||||
},
|
},
|
||||||
'/etc/postfix/main.cf': {
|
'/etc/postfix/main.cf': {
|
||||||
'content_type': 'mako',
|
'content_type': 'mako',
|
||||||
|
'context': {
|
||||||
|
'mynetworks': mynetworks,
|
||||||
|
},
|
||||||
'triggers': {
|
'triggers': {
|
||||||
'svc_systemd:postfix:restart',
|
'svc_systemd:postfix:restart',
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue