@@ -295,6 +295,15 @@ def get_ca_signed_cert(cacert_path, ca_name, CN):
295295 return "\n " .join ([cert , key ])
296296
297297
298+ def _read_cert_file (path : str ) -> str :
299+ """Helper to read certificate files, which might be symlinks"""
300+ try :
301+ with open (path , 'r' ) as f :
302+ return f .read ()
303+ except (IOError , OSError ):
304+ return None
305+
306+
298307def ext_pillar (minion_id , pillar , base = "/etc/ssl" , name = "PSFCA" , cert_opts = None ):
299308 if cert_opts is None :
300309 cert_opts = {}
@@ -315,7 +324,6 @@ def ext_pillar(minion_id, pillar, base="/etc/ssl", name="PSFCA", cert_opts=None)
315324 }
316325
317326 minion_roles = []
318- # match roles based on pillar.roles:pattern
319327 minion_roles .extend (
320328 role_name
321329 for role_name , role_config in pillar .get ("roles" , {}).items ()
@@ -345,6 +353,11 @@ def ext_pillar(minion_id, pillar, base="/etc/ssl", name="PSFCA", cert_opts=None)
345353 for domain , domain_config in acme_certs .items ():
346354 cert_roles = domain_config .get ("roles" , [])
347355 if any (role in minion_roles for role in cert_roles ):
348- data ["tls" ]["acme_certs" ][domain ] = domain_config
356+ cert_name = domain_config .get ('name' , domain )
357+ full_cert_chain = _read_cert_file (f"/etc/letsencrypt/live/{ cert_name } /fullchain.pem" )
358+ privkey = _read_cert_file (f"/etc/letsencrypt/live/{ cert_name } /privkey.pem" )
359+
360+ if full_cert_chain and privkey :
361+ data ["tls" ]["acme_certs" ][domain ] = full_cert_chain + "\n " + privkey
349362
350- return data
363+ return data
0 commit comments