cainstance.update_ipa_conf: allow specifying ca_host

Enhance cainstance.update_ipa_conf() to allow specifying the
ca_host.  This will be used to update replica configurations when a
CA-less deployment gets promoted to CA-ful.

Part of: https://pagure.io/freeipa/issue/7188

Reviewed-By: Florence Blanc-Renaud <frenaud@redhat.com>
This commit is contained in:
Fraser Tweedale 2018-03-06 17:07:32 +11:00
parent 147b808ffb
commit 2fcc260cae

View File

@ -2205,17 +2205,20 @@ def add_lightweight_ca_tracking_requests(lwcas):
'already tracking certificate "%s"', nickname) 'already tracking certificate "%s"', nickname)
def update_ipa_conf(): def update_ipa_conf(ca_host=None):
""" """
Update IPA configuration file to ensure that RA plugins are enabled and Update IPA configuration file to ensure that RA plugins are enabled and
that CA host points to localhost that CA host points to specified server (or localhost if ca_host=None).
""" """
parser = RawConfigParser() parser = RawConfigParser()
parser.read(paths.IPA_DEFAULT_CONF) parser.read(paths.IPA_DEFAULT_CONF)
parser.set('global', 'enable_ra', 'True') parser.set('global', 'enable_ra', 'True')
parser.set('global', 'ra_plugin', 'dogtag') parser.set('global', 'ra_plugin', 'dogtag')
parser.set('global', 'dogtag_version', '10') parser.set('global', 'dogtag_version', '10')
parser.remove_option('global', 'ca_host') if ca_host is None:
parser.remove_option('global', 'ca_host')
else:
parser.set('global', 'ca_host', ca_host)
with open(paths.IPA_DEFAULT_CONF, 'w') as f: with open(paths.IPA_DEFAULT_CONF, 'w') as f:
parser.write(f) parser.write(f)