Skip to content

Instantly share code, notes, and snippets.

Created May 13, 2020 03:37
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
import os
from dns import resolver
from ipalib import api
from ipapython import dnsutil
certbot_domain = os.environ['CERTBOT_DOMAIN']
certbot_validation = os.environ['CERTBOT_VALIDATION']
if 'CERTBOT_AUTH_OUTPUT' in os.environ:
command = 'dnsrecord_del'
command = 'dnsrecord_add'
validation_domain = f'_acme-challenge.{certbot_domain}'
fqdn = dnsutil.DNSName(validation_domain).make_absolute()
zone = dnsutil.DNSName(resolver.zone_for_name(fqdn))
name = fqdn.relativize(zone)
api.Command[command](zone, name, txtrecord=[certbot_validation], dnsttl=60)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment