2020-11-07 21:31:18 +00:00
|
|
|
if node.has_bundle('postfixadmin'):
|
2021-04-02 16:57:13 +00:00
|
|
|
repo.libs.tools.require_bundle(node, 'letsencrypt')
|
2020-11-07 21:31:18 +00:00
|
|
|
|
2021-04-01 14:59:49 +00:00
|
|
|
mynetworks = {
|
|
|
|
'127.0.0.0/8',
|
|
|
|
'[::1]/128',
|
|
|
|
'[::ffff:127.0.0.0]/104',
|
|
|
|
}
|
|
|
|
for identifier in node.metadata.get('postfix/mynetworks', set()):
|
|
|
|
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}')
|
|
|
|
|
2021-07-10 14:16:56 +00:00
|
|
|
my_package = 'pkg_pacman:postfix' if node.os == 'arch' else 'pkg_apt:postfix'
|
2021-05-23 10:24:00 +00:00
|
|
|
|
2020-11-07 21:31:18 +00:00
|
|
|
files = {
|
|
|
|
'/etc/mailname': {
|
2021-02-18 17:12:25 +00:00
|
|
|
'content': node.metadata.get('postfix/myhostname', node.metadata['hostname']),
|
2023-09-20 15:38:17 +00:00
|
|
|
'before': {
|
|
|
|
my_package,
|
|
|
|
},
|
2020-11-07 21:31:18 +00:00
|
|
|
'triggers': {
|
|
|
|
'svc_systemd:postfix:restart',
|
|
|
|
},
|
|
|
|
},
|
2020-11-09 09:52:24 +00:00
|
|
|
'/etc/aliases': {
|
|
|
|
'content_type': 'mako',
|
|
|
|
'triggers': {
|
|
|
|
'action:postfix_newaliases',
|
|
|
|
},
|
|
|
|
},
|
2020-11-07 21:31:18 +00:00
|
|
|
'/etc/postfix/master.cf': {
|
|
|
|
'content_type': 'mako',
|
|
|
|
'triggers': {
|
|
|
|
'svc_systemd:postfix:restart',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
'/etc/postfix/main.cf': {
|
|
|
|
'content_type': 'mako',
|
2021-04-01 14:59:49 +00:00
|
|
|
'context': {
|
|
|
|
'mynetworks': mynetworks,
|
|
|
|
},
|
2020-11-07 21:31:18 +00:00
|
|
|
'triggers': {
|
|
|
|
'svc_systemd:postfix:restart',
|
|
|
|
},
|
|
|
|
},
|
2020-11-10 19:34:27 +00:00
|
|
|
'/etc/postfix/submission_header_cleanup': {
|
|
|
|
'triggers': {
|
|
|
|
'svc_systemd:postfix:restart',
|
|
|
|
},
|
|
|
|
},
|
2021-04-24 08:17:05 +00:00
|
|
|
'/usr/local/bin/postfix-telegraf-queue': {
|
|
|
|
'mode': '0755',
|
|
|
|
},
|
2020-11-10 09:21:37 +00:00
|
|
|
'/usr/local/share/icinga/plugins/check_postfix_queue': {
|
|
|
|
'mode': '0755',
|
|
|
|
},
|
2020-11-07 21:31:18 +00:00
|
|
|
}
|
|
|
|
|
2020-11-09 09:52:24 +00:00
|
|
|
actions = {
|
|
|
|
'postfix_newaliases': {
|
|
|
|
'command': 'newaliases',
|
|
|
|
'triggered': True,
|
2020-11-09 15:36:26 +00:00
|
|
|
'needs': {
|
2021-05-23 10:24:00 +00:00
|
|
|
my_package,
|
2020-11-09 15:36:26 +00:00
|
|
|
},
|
2020-11-09 09:52:24 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2020-11-07 21:31:18 +00:00
|
|
|
svc_systemd = {
|
|
|
|
'postfix': {
|
|
|
|
'needs': {
|
|
|
|
'file:/etc/postfix/master.cf',
|
|
|
|
'file:/etc/postfix/main.cf',
|
2021-05-23 10:24:00 +00:00
|
|
|
my_package,
|
2020-11-07 21:31:18 +00:00
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
2021-07-10 14:16:56 +00:00
|
|
|
|
|
|
|
if node.os == 'arch':
|
|
|
|
files['/etc/systemd/system/postfix.service.d/bundlewrap.conf'] = {
|
|
|
|
'source': 'arch-override.conf',
|
|
|
|
'content_type': 'mako',
|
|
|
|
'triggers': {
|
|
|
|
'action:systemd-reload',
|
|
|
|
'svc_systemd:postfix:restart',
|
|
|
|
},
|
|
|
|
}
|