From 84867ff1e61a8091d255e31d0fe5cf08c6f7a075 Mon Sep 17 00:00:00 2001 From: Franziska Kunsmann Date: Sun, 27 Oct 2024 11:19:05 +0100 Subject: [PATCH] bundles/postfix: provide myhostname from reactor --- bundles/dovecot/files/dovecot.conf | 4 ++-- bundles/postfix/files/main.cf | 6 +++--- bundles/postfix/items.py | 2 +- bundles/postfix/metadata.py | 13 ++++++++++++- 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/bundles/dovecot/files/dovecot.conf b/bundles/dovecot/files/dovecot.conf index 804c6a9..73afeaf 100644 --- a/bundles/dovecot/files/dovecot.conf +++ b/bundles/dovecot/files/dovecot.conf @@ -29,8 +29,8 @@ mail_location = maildir:/var/mail/vmail/%d/%n protocols = imap lmtp sieve ssl = required -ssl_cert = % if node.has_bundle('postfixadmin'): -smtpd_tls_cert_file = /var/lib/dehydrated/certs/${node.metadata.get('postfix/myhostname', node.metadata['hostname'])}/fullchain.pem -smtpd_tls_key_file = /var/lib/dehydrated/certs/${node.metadata.get('postfix/myhostname', node.metadata['hostname'])}/privkey.pem +smtpd_tls_cert_file = /var/lib/dehydrated/certs/${node.metadata.get('postfix/myhostname')}/fullchain.pem +smtpd_tls_key_file = /var/lib/dehydrated/certs/${node.metadata.get('postfix/myhostname')}/privkey.pem <%text> smtpd_use_tls=yes smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache diff --git a/bundles/postfix/items.py b/bundles/postfix/items.py index d1bf0c2..5518c90 100644 --- a/bundles/postfix/items.py +++ b/bundles/postfix/items.py @@ -25,7 +25,7 @@ my_package = 'pkg_pacman:postfix' if node.os == 'arch' else 'pkg_apt:postfix' files = { '/etc/mailname': { - 'content': node.metadata.get('postfix/myhostname', node.metadata['hostname']), + 'content': node.metadata.get('postfix/myhostname'), 'before': { my_package, }, diff --git a/bundles/postfix/metadata.py b/bundles/postfix/metadata.py index 4788de6..3c3be24 100644 --- a/bundles/postfix/metadata.py +++ b/bundles/postfix/metadata.py @@ -87,7 +87,7 @@ def letsencrypt(metadata): } result['domains'] = { - metadata.get('postfix/myhostname', metadata.get('hostname')): set(), + metadata.get('postfix/myhostname'): set(), } return { @@ -148,3 +148,14 @@ def icinga2(metadata): }, }, } + + +@metadata_reactor.provides( + 'postfix/myhostname', +) +def myhostname(metadata): + return { + 'postfix': { + 'myhostname': metadata.get('hostname'), + }, + }