Skip to content
Snippets Groups Projects
Commit 0c5905fd authored by Thomas Woerner's avatar Thomas Woerner
Browse files

library/ipadiscovery.py: Add ca_cert_file argument for discovery

parent 2253a415
Branches
Tags
No related merge requests found
...@@ -48,6 +48,9 @@ options: ...@@ -48,6 +48,9 @@ options:
hostname: hostname:
description: The authorized kerberos principal used to join the IPA realm. description: The authorized kerberos principal used to join the IPA realm.
required: false required: false
ca_cert_file:
description: A CA certificate to use.
required: false
check: check:
description: Check if IPA client is installed and matching. description: Check if IPA client is installed and matching.
required: false required: false
...@@ -147,6 +150,22 @@ from ipaclient.install import ipadiscovery ...@@ -147,6 +150,22 @@ from ipaclient.install import ipadiscovery
from ipalib.install.sysrestore import SYSRESTORE_STATEFILE from ipalib.install.sysrestore import SYSRESTORE_STATEFILE
from ipaplatform.paths import paths from ipaplatform.paths import paths
def get_cert_path(cert_path):
"""
If a CA certificate is passed in on the command line, use that.
Else if a CA file exists in paths.IPA_CA_CRT then use that.
Otherwise return None.
"""
if cert_path is not None:
return cert_path
if os.path.exists(paths.IPA_CA_CRT):
return paths.IPA_CA_CRT
return None
def is_client_configured(): def is_client_configured():
""" """
Check if ipa client is configured. Check if ipa client is configured.
...@@ -188,6 +207,7 @@ def main(): ...@@ -188,6 +207,7 @@ def main():
domain=dict(required=False), domain=dict(required=False),
realm=dict(required=False), realm=dict(required=False),
hostname=dict(required=False), hostname=dict(required=False),
ca_cert_file=dict(required=False),
check=dict(required=False, type='bool', default=False), check=dict(required=False, type='bool', default=False),
), ),
# required_one_of = ( [ '', '' ] ), # required_one_of = ( [ '', '' ] ),
...@@ -199,6 +219,7 @@ def main(): ...@@ -199,6 +219,7 @@ def main():
opt_servers = module.params.get('servers') opt_servers = module.params.get('servers')
opt_realm = module.params.get('realm') opt_realm = module.params.get('realm')
opt_hostname = module.params.get('hostname') opt_hostname = module.params.get('hostname')
opt_ca_cert_file = module.params.get('ca_cert_file')
opt_check = module.params.get('check') opt_check = module.params.get('check')
hostname = None hostname = None
...@@ -238,7 +259,7 @@ def main(): ...@@ -238,7 +259,7 @@ def main():
servers=opt_servers, servers=opt_servers,
realm=opt_realm, realm=opt_realm,
hostname=hostname, hostname=hostname,
ca_cert_path=None) ca_cert_path=get_cert_path(opt_ca_cert_file))
if opt_servers and ret != 0: if opt_servers and ret != 0:
# There is no point to continue with installation as server list was # There is no point to continue with installation as server list was
...@@ -276,7 +297,7 @@ def main(): ...@@ -276,7 +297,7 @@ def main():
domain=cli_domain, domain=cli_domain,
servers=opt_servers, servers=opt_servers,
hostname=hostname, hostname=hostname,
ca_cert_path=None) ca_cert_path=get_cert_path(opt_ca_cert_file))
if not cli_domain: if not cli_domain:
if ds.domain: if ds.domain:
...@@ -299,7 +320,7 @@ def main(): ...@@ -299,7 +320,7 @@ def main():
domain=cli_domain, domain=cli_domain,
servers=cli_server, servers=cli_server,
hostname=hostname, hostname=hostname,
ca_cert_path=None) ca_cert_path=get_cert_path(opt_ca_cert_file))
else: else:
# Only set dnsok to True if we were not passed in one or more servers # Only set dnsok to True if we were not passed in one or more servers
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
servers: "{{ groups.ipaservers | default(omit) }}" servers: "{{ groups.ipaservers | default(omit) }}"
realm: "{{ ipaclient_realm | default(omit) }}" realm: "{{ ipaclient_realm | default(omit) }}"
hostname: "{{ ansible_fqdn }}" hostname: "{{ ansible_fqdn }}"
#ca_cert_file: "{{ ipaclient_ca_cert_file | default(omit) }}"
check: yes check: yes
register: ipadiscovery register: ipadiscovery
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment