1
0
mirror of https://github.com/laurivosandi/certidude synced 2024-12-22 16:25:17 +00:00

cli: Add support for /etc/certidude/{client.conf.d,services.conf.d}

This commit is contained in:
Lauri Võsandi 2018-05-04 09:55:01 +03:00
parent 77c6fc0881
commit 4348458d30

View File

@ -87,6 +87,22 @@ def setup_client(prefix="client_", dh=False):
return wrapper return wrapper
class ConfigTreeParser(ConfigParser):
def __init__(self, path, *args, **kwargs):
ConfigParser.__init__(self, *args, **kwargs)
if os.path.exists(path):
with open(path) as fh:
click.echo("Parsing: %s" % fh.name)
self.readfp(fh)
if os.path.exists(path + ".d"):
for filename in os.listdir(path + ".d"):
if not filename.endswith(".conf"):
continue
with open(os.path.join(path + ".d", filename)) as fh:
click.echo("Parsing: %s" % fh.name)
self.readfp(fh)
@click.command("enroll", help="Run processes for requesting certificates and configuring services") @click.command("enroll", help="Run processes for requesting certificates and configuring services")
@click.option("-k", "--kerberos", default=False, is_flag=True, help="Offer system keytab for auth") @click.option("-k", "--kerberos", default=False, is_flag=True, help="Offer system keytab for auth")
@click.option("-r", "--renew", default=False, is_flag=True, help="Renew now") @click.option("-r", "--renew", default=False, is_flag=True, help="Renew now")
@ -123,12 +139,8 @@ def certidude_enroll(fork, renew, no_wait, kerberos, skip_self):
import requests import requests
clients = ConfigParser() clients = ConfigTreeParser(const.CLIENT_CONFIG_PATH)
clients.readfp(open(const.CLIENT_CONFIG_PATH)) service_config = ConfigTreeParser(const.SERVICES_CONFIG_PATH)
service_config = ConfigParser()
if os.path.exists(const.SERVICES_CONFIG_PATH):
service_config.readfp(open(const.SERVICES_CONFIG_PATH))
# Process directories # Process directories
if not os.path.exists(const.RUN_DIR): if not os.path.exists(const.RUN_DIR):