mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-07-29 02:44:43 +00:00
ipa[server,replica,client]: flake8 and pylint fixes
These are white space and line length changes to calm down pylint and flake8.
This commit is contained in:
@@ -56,13 +56,12 @@ def kinit_password(principal, password, ccache_name, config):
|
||||
Perform kinit using principal/password, with the specified config file
|
||||
and store the TGT in ccache_name.
|
||||
"""
|
||||
args = [ "/usr/bin/kinit", principal, '-c', ccache_name]
|
||||
args = ["/usr/bin/kinit", principal, '-c', ccache_name]
|
||||
old_config = os.environ.get('KRB5_CONFIG')
|
||||
os.environ['KRB5_CONFIG'] = config
|
||||
|
||||
try:
|
||||
result = run_cmd(args, stdin=password.encode())
|
||||
return result
|
||||
return run_cmd(args, stdin=password.encode())
|
||||
finally:
|
||||
if old_config is not None:
|
||||
os.environ['KRB5_CONFIG'] = old_config
|
||||
@@ -122,6 +121,7 @@ KRB5CONF_TEMPLATE = """
|
||||
{{ ipa_domain }} = {{ ipa_realm }}
|
||||
"""
|
||||
|
||||
|
||||
class ActionModule(ActionBase):
|
||||
|
||||
def run(self, tmp=None, task_vars=None):
|
||||
@@ -162,8 +162,8 @@ class ActionModule(ActionBase):
|
||||
result['msg'] = "principal is required"
|
||||
return result
|
||||
|
||||
data = self._execute_module(module_name='ipaclient_get_facts', module_args=dict(),
|
||||
task_vars=None)
|
||||
data = self._execute_module(module_name='ipaclient_get_facts',
|
||||
module_args=dict(), task_vars=None)
|
||||
try:
|
||||
domain = data['ansible_facts']['ipa']['domain']
|
||||
realm = data['ansible_facts']['ipa']['realm']
|
||||
@@ -217,7 +217,8 @@ class ActionModule(ActionBase):
|
||||
kinit_keytab(principal, keytab, ccache_name, krb5conf_name)
|
||||
except Exception as e:
|
||||
result['failed'] = True
|
||||
result['msg'] = 'kinit %s with keytab %s failed' % (principal, keytab)
|
||||
result['msg'] = 'kinit %s with keytab %s failed: %s' % \
|
||||
(principal, keytab, str(e))
|
||||
return result
|
||||
|
||||
try:
|
||||
|
||||
@@ -80,15 +80,16 @@ from ansible.module_utils.ansible_ipa_client import (
|
||||
CLIENT_INSTALL_ERROR, logger
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(
|
||||
argument_spec = dict(
|
||||
argument_spec=dict(
|
||||
servers=dict(required=True, type='list'),
|
||||
realm=dict(required=True),
|
||||
hostname=dict(required=True),
|
||||
debug=dict(required=False, type='bool', default="false")
|
||||
debug=dict(required=False, type='bool', default="false"),
|
||||
),
|
||||
supports_check_mode = True,
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
||||
module._ansible_debug = True
|
||||
@@ -102,10 +103,10 @@ def main():
|
||||
|
||||
ca_certs = x509.load_certificate_list_from_file(paths.IPA_CA_CRT)
|
||||
if 40500 <= NUM_VERSION < 40590:
|
||||
ca_certs = [ cert.public_bytes(serialization.Encoding.DER)
|
||||
for cert in ca_certs ]
|
||||
ca_certs = [cert.public_bytes(serialization.Encoding.DER)
|
||||
for cert in ca_certs]
|
||||
elif NUM_VERSION < 40500:
|
||||
ca_certs = [ cert.der_data for cert in ca_certs ]
|
||||
ca_certs = [cert.der_data for cert in ca_certs]
|
||||
|
||||
with certdb.NSSDatabase() as tmp_db:
|
||||
api.bootstrap(context='cli_installer',
|
||||
@@ -139,7 +140,7 @@ def main():
|
||||
else:
|
||||
tmp_db.add_cert(cert, 'CA certificate %d' % (i + 1),
|
||||
'C,,')
|
||||
except CalledProcessError as e:
|
||||
except CalledProcessError:
|
||||
module.fail_json(msg="Failed to add CA to temporary NSS database.")
|
||||
|
||||
api.finalize()
|
||||
@@ -175,10 +176,12 @@ def main():
|
||||
"may not be available")
|
||||
except errors.PublicError as e2:
|
||||
module.fail_json(
|
||||
msg="Cannot connect to the IPA server RPC interface: %s" % e2)
|
||||
msg="Cannot connect to the IPA server RPC interface: "
|
||||
"%s" % e2)
|
||||
except errors.PublicError as e:
|
||||
module.fail_json(
|
||||
msg="Cannot connect to the server due to generic error: %s" % e)
|
||||
msg="Cannot connect to the server due to generic error: "
|
||||
"%s" % e)
|
||||
# Use the RPC directly so older servers are supported
|
||||
try:
|
||||
result = api.Backend.rpcclient.forward(
|
||||
@@ -200,7 +203,7 @@ def main():
|
||||
try:
|
||||
config = api.Command['config_show']()['result']
|
||||
subject_base = str(DN(config['ipacertificatesubjectbase'][0]))
|
||||
except errors.PublicError as e:
|
||||
except errors.PublicError:
|
||||
try:
|
||||
config = api.Backend.rpcclient.forward(
|
||||
'config_show',
|
||||
@@ -219,5 +222,6 @@ def main():
|
||||
ca_enabled=ca_enabled,
|
||||
subject_base=subject_base)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -72,9 +72,10 @@ from ansible.module_utils.ansible_ipa_client import (
|
||||
get_ca_certs, errors
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(
|
||||
argument_spec = dict(
|
||||
argument_spec=dict(
|
||||
servers=dict(required=True, type='list'),
|
||||
realm=dict(required=True),
|
||||
basedn=dict(required=True),
|
||||
@@ -101,7 +102,7 @@ def main():
|
||||
if not os.path.exists(paths.IPA_CA_CRT):
|
||||
if not allow_repair:
|
||||
module.fail_json(
|
||||
msg="%s missing, enable allow_repair to fix it." % \
|
||||
msg="%s missing, enable allow_repair to fix it." %
|
||||
paths.IPA_CA_CRT)
|
||||
|
||||
# Repair missing ca.crt file
|
||||
@@ -121,5 +122,6 @@ def main():
|
||||
|
||||
module.exit_json(changed=changed)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -56,9 +56,10 @@ from ansible.module_utils.ansible_ipa_client import (
|
||||
paths, sysrestore
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(
|
||||
argument_spec = dict(
|
||||
argument_spec=dict(
|
||||
backup=dict(required=True),
|
||||
),
|
||||
)
|
||||
@@ -73,5 +74,6 @@ def main():
|
||||
|
||||
module.exit_json(changed=False)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -49,6 +49,7 @@ def is_ntpd_configured():
|
||||
except IOError:
|
||||
return False
|
||||
|
||||
|
||||
def is_dns_configured():
|
||||
# dns is configured when /etc/named.conf contains the line
|
||||
# dyndb "ipa" "/usr/lib64/bind/ldap.so" {
|
||||
@@ -63,20 +64,24 @@ def is_dns_configured():
|
||||
except IOError:
|
||||
return False
|
||||
|
||||
|
||||
def is_dogtag_configured(subsystem):
|
||||
# ca / kra is configured when the directory /var/lib/pki/pki-tomcat/[ca|kra]
|
||||
# exists
|
||||
available_subsystems = { 'ca', 'kra' }
|
||||
# ca / kra is configured when the directory
|
||||
# /var/lib/pki/pki-tomcat/[ca|kra] # exists
|
||||
available_subsystems = {'ca', 'kra'}
|
||||
assert subsystem in available_subsystems
|
||||
|
||||
return os.path.isdir(os.path.join(VAR_LIB_PKI_TOMCAT, subsystem))
|
||||
|
||||
|
||||
def is_ca_configured():
|
||||
return is_dogtag_configured('ca')
|
||||
|
||||
|
||||
def is_kra_configured():
|
||||
return is_dogtag_configured('kra')
|
||||
|
||||
|
||||
def is_client_configured():
|
||||
# IPA Client is configured when /etc/ipa/default.conf exists
|
||||
# and /var/lib/ipa-client/sysrestore/sysrestore.state exists
|
||||
@@ -84,12 +89,14 @@ def is_client_configured():
|
||||
fstore = sysrestore.FileStore(paths.IPA_CLIENT_SYSRESTORE)
|
||||
return (os.path.isfile(paths.IPA_DEFAULT_CONF) and fstore.has_files())
|
||||
|
||||
|
||||
def is_server_configured():
|
||||
# IPA server is configured when /etc/ipa/default.conf exists
|
||||
# and /var/lib/ipa/sysrestore/sysrestore.state exists
|
||||
return (os.path.isfile(paths.IPA_DEFAULT_CONF) and
|
||||
os.path.isfile(SERVER_SYSRESTORE_STATE))
|
||||
|
||||
|
||||
def get_ipa_conf():
|
||||
# Extract basedn, realm and domain from /etc/ipa/default.conf
|
||||
parser = RawConfigParser()
|
||||
@@ -103,6 +110,7 @@ def get_ipa_conf():
|
||||
domain=domain
|
||||
)
|
||||
|
||||
|
||||
def get_ipa_version():
|
||||
try:
|
||||
from ipapython import version
|
||||
@@ -115,7 +123,8 @@ def get_ipa_version():
|
||||
# 4.4.90.201610191151GITd852c00
|
||||
# 4.4.90.dev201701071308+git2e43db1
|
||||
# 4.6.90.pre2
|
||||
if part.startswith('dev') or part.startswith('pre') or 'GIT' in part:
|
||||
if part.startswith('dev') or part.startswith('pre') or \
|
||||
'GIT' in part:
|
||||
version_info.append(part)
|
||||
else:
|
||||
version_info.append(int(part))
|
||||
@@ -128,9 +137,10 @@ def get_ipa_version():
|
||||
version_info=version_info
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(
|
||||
argument_spec = dict(),
|
||||
argument_spec=dict(),
|
||||
supports_check_mode=True
|
||||
)
|
||||
|
||||
@@ -138,7 +148,7 @@ def main():
|
||||
# check mode is supported
|
||||
|
||||
facts = dict(
|
||||
packages= dict(
|
||||
packages=dict(
|
||||
ipalib=HAS_IPALIB,
|
||||
ipaserver=HAS_IPASERVER,
|
||||
),
|
||||
@@ -157,7 +167,7 @@ def main():
|
||||
facts['configured']['client'] = True
|
||||
|
||||
facts['version'] = get_ipa_version()
|
||||
for key,value in six.iteritems(get_ipa_conf()):
|
||||
for key, value in six.iteritems(get_ipa_conf()):
|
||||
facts[key] = value
|
||||
|
||||
if HAS_IPASERVER:
|
||||
@@ -173,5 +183,6 @@ def main():
|
||||
ansible_facts=dict(ipa=facts)
|
||||
)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -146,6 +146,7 @@ from ipapython.ipautil import run
|
||||
if six.PY3:
|
||||
unicode = str
|
||||
|
||||
|
||||
def get_host_diff(ipa_host, module_host):
|
||||
"""
|
||||
Compares two dictionaries containing host attributes and builds a dict
|
||||
@@ -171,7 +172,7 @@ def get_host_diff(ipa_host, module_host):
|
||||
ipa_value = sorted(ipa_value)
|
||||
module_value = sorted(module_value)
|
||||
if ipa_value != module_value:
|
||||
data[key]=unicode(module_value)
|
||||
data[key] = unicode(module_value)
|
||||
return data
|
||||
|
||||
|
||||
@@ -226,7 +227,7 @@ def ensure_host_present(module, api, ipahost):
|
||||
# If we want to create a random password, and the host
|
||||
# already has Keytab: true, then we need first to run
|
||||
# ipa host-disable in order to remove OTP and keytab
|
||||
if module.params.get('random') and ipahost['has_keytab'] == True:
|
||||
if module.params.get('random') and ipahost['has_keytab'] is True:
|
||||
api.Command.host_disable(fqdn)
|
||||
|
||||
result = api.Command.host_mod(fqdn, **diffs)
|
||||
@@ -289,14 +290,14 @@ def main():
|
||||
"""
|
||||
module = AnsibleModule(
|
||||
argument_spec=dict(
|
||||
principal = dict(default='admin'),
|
||||
ccache = dict(required=False, type='path'),
|
||||
fqdn = dict(required=True),
|
||||
certificates = dict(required=False, type='list'),
|
||||
sshpubkey= dict(required=False),
|
||||
ipaddress = dict(required=False),
|
||||
random = dict(default=False, type='bool'),
|
||||
state = dict(default='present', choices=[ 'present', 'absent' ]),
|
||||
principal=dict(default='admin'),
|
||||
ccache=dict(required=False, type='path'),
|
||||
fqdn=dict(required=True),
|
||||
certificates=dict(required=False, type='list'),
|
||||
sshpubkey=dict(required=False),
|
||||
ipaddress=dict(required=False),
|
||||
random=dict(default=False, type='bool'),
|
||||
state=dict(default='present', choices=['present', 'absent']),
|
||||
),
|
||||
supports_check_mode=True,
|
||||
)
|
||||
@@ -307,7 +308,7 @@ def main():
|
||||
state = module.params.get('state')
|
||||
|
||||
try:
|
||||
os.environ['KRB5CCNAME']=ccache
|
||||
os.environ['KRB5CCNAME'] = ccache
|
||||
|
||||
cfg = dict(
|
||||
context='ansible_module',
|
||||
@@ -320,24 +321,24 @@ def main():
|
||||
api.finalize()
|
||||
api.Backend.rpcclient.connect()
|
||||
|
||||
changed = False
|
||||
try:
|
||||
result = api.Command.host_show(fqdn, all=True)
|
||||
host = result['result']
|
||||
except errors.NotFound:
|
||||
host = None
|
||||
|
||||
if state in ['present','disabled']:
|
||||
changed = ensure_host_present(module, api, host)
|
||||
if state in ['present', 'disabled']:
|
||||
ensure_host_present(module, api, host)
|
||||
elif state == 'absent':
|
||||
changed = ensure_host_absent(module, api, host)
|
||||
ensure_host_absent(module, api, host)
|
||||
|
||||
except Exception as e:
|
||||
module.fail_json(msg="ipaclient_get_otp module failed : %s" % str(e))
|
||||
finally:
|
||||
run([paths.KDESTROY], raiseonerr=False, env=os.environ)
|
||||
|
||||
module.exit_json(changed=changed, host=host)
|
||||
module.exit_json(changed=False, host=host)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -76,16 +76,17 @@ from ansible.module_utils.ansible_ipa_client import (
|
||||
paths, sysrestore, configure_ipa_conf
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(
|
||||
argument_spec = dict(
|
||||
argument_spec=dict(
|
||||
domain=dict(required=True, default=None),
|
||||
servers=dict(required=True, type='list', default=None),
|
||||
realm=dict(required=True, default=None),
|
||||
hostname=dict(required=True, default=None),
|
||||
basedn=dict(required=True),
|
||||
),
|
||||
supports_check_mode = True,
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
||||
module._ansible_debug = True
|
||||
@@ -101,5 +102,6 @@ def main():
|
||||
|
||||
module.exit_json(changed=True)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -133,9 +133,10 @@ from ansible.module_utils.ansible_ipa_client import (
|
||||
get_ca_cert, get_ca_certs, errors, run
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(
|
||||
argument_spec = dict(
|
||||
argument_spec=dict(
|
||||
servers=dict(required=True, type='list'),
|
||||
domain=dict(required=True),
|
||||
realm=dict(required=True),
|
||||
@@ -151,7 +152,7 @@ def main():
|
||||
kinit_attempts=dict(required=False, type='int', default=5),
|
||||
debug=dict(required=False, type='bool'),
|
||||
),
|
||||
supports_check_mode = True,
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
||||
module._ansible_debug = True
|
||||
@@ -224,7 +225,7 @@ def main():
|
||||
join_args.append("-f")
|
||||
if not os.path.exists(admin_keytab):
|
||||
module.fail_json(
|
||||
msg="Keytab file could not be found: %s" % \
|
||||
msg="Keytab file could not be found: %s" %
|
||||
admin_keytab)
|
||||
try:
|
||||
kinit_keytab(principal,
|
||||
@@ -298,7 +299,8 @@ def main():
|
||||
|
||||
# Fail for missing krb5.keytab on already joined host
|
||||
if already_joined and not os.path.exists(paths.KRB5_KEYTAB):
|
||||
module.fail_json(msg="krb5.keytab missing! Retry with ipaclient_force_join=yes to generate a new one.")
|
||||
module.fail_json(msg="krb5.keytab missing! Retry with "
|
||||
"ipaclient_force_join=yes to generate a new one.")
|
||||
|
||||
if principal:
|
||||
run([paths.KDESTROY], raiseonerr=False, env=env)
|
||||
@@ -337,5 +339,6 @@ def main():
|
||||
module.exit_json(changed=changed,
|
||||
already_joined=already_joined)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -60,10 +60,10 @@ from ansible.module_utils.ansible_ipa_client import (
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(
|
||||
argument_spec = dict(
|
||||
argument_spec=dict(
|
||||
hostname=dict(required=True),
|
||||
),
|
||||
supports_check_mode = True,
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
||||
module._ansible_debug = True
|
||||
|
||||
@@ -61,17 +61,18 @@ from ansible.module_utils.ansible_ipa_client import (
|
||||
options, configure_automount
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(
|
||||
argument_spec = dict(
|
||||
argument_spec=dict(
|
||||
servers=dict(required=True, type='list'),
|
||||
sssd=dict(required=False, type='bool', default='yes'),
|
||||
automount_location=dict(required=False, default=None),
|
||||
),
|
||||
supports_check_mode = True,
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
||||
#os.environ['KRB5CCNAME'] = paths.IPA_DNS_CCACHE
|
||||
# os.environ['KRB5CCNAME'] = paths.IPA_DNS_CCACHE
|
||||
|
||||
module._ansible_debug = True
|
||||
options.servers = module.params.get('servers')
|
||||
@@ -85,5 +86,6 @@ def main():
|
||||
|
||||
module.exit_json(changed=True)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -61,13 +61,14 @@ from ansible.module_utils.ansible_ipa_client import (
|
||||
sysrestore, paths, options, configure_firefox
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(
|
||||
argument_spec = dict(
|
||||
argument_spec=dict(
|
||||
domain=dict(required=True),
|
||||
firefox_dir=dict(required=False),
|
||||
),
|
||||
supports_check_mode = True,
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
||||
module._ansible_debug = True
|
||||
@@ -80,5 +81,6 @@ def main():
|
||||
|
||||
module.exit_json(changed=True)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -63,9 +63,10 @@ from ansible.module_utils.ansible_ipa_client import (
|
||||
sysrestore, paths, configure_krb5_conf, logger
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(
|
||||
argument_spec = dict(
|
||||
argument_spec=dict(
|
||||
domain=dict(required=False, default=None),
|
||||
servers=dict(required=False, type='list', default=None),
|
||||
realm=dict(required=False, default=None),
|
||||
@@ -75,9 +76,9 @@ def main():
|
||||
client_domain=dict(required=False, default=None),
|
||||
sssd=dict(required=False, type='bool', default=False),
|
||||
force=dict(required=False, type='bool', default=False),
|
||||
#on_master=dict(required=False, type='bool', default=False),
|
||||
# on_master=dict(required=False, type='bool', default=False),
|
||||
),
|
||||
supports_check_mode = True,
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
||||
module._ansible_debug = True
|
||||
@@ -90,21 +91,21 @@ def main():
|
||||
client_domain = module.params.get('client_domain')
|
||||
sssd = module.params.get('sssd')
|
||||
force = module.params.get('force')
|
||||
#on_master = module.params.get('on_master')
|
||||
# on_master = module.params.get('on_master')
|
||||
|
||||
fstore = sysrestore.FileStore(paths.IPA_CLIENT_SYSRESTORE)
|
||||
|
||||
#if options.on_master:
|
||||
# # If on master assume kerberos is already configured properly.
|
||||
# # Get the host TGT.
|
||||
# try:
|
||||
# kinit_keytab(host_principal, paths.KRB5_KEYTAB, CCACHE_FILE,
|
||||
# attempts=options.kinit_attempts)
|
||||
# os.environ['KRB5CCNAME'] = CCACHE_FILE
|
||||
# except gssapi.exceptions.GSSError as e:
|
||||
# logger.error("Failed to obtain host TGT: %s", e)
|
||||
# raise ScriptError(rval=CLIENT_INSTALL_ERROR)
|
||||
#else:
|
||||
# if options.on_master:
|
||||
# # If on master assume kerberos is already configured properly.
|
||||
# # Get the host TGT.
|
||||
# try:
|
||||
# kinit_keytab(host_principal, paths.KRB5_KEYTAB, CCACHE_FILE,
|
||||
# attempts=options.kinit_attempts)
|
||||
# os.environ['KRB5CCNAME'] = CCACHE_FILE
|
||||
# except gssapi.exceptions.GSSError as e:
|
||||
# logger.error("Failed to obtain host TGT: %s", e)
|
||||
# raise ScriptError(rval=CLIENT_INSTALL_ERROR)
|
||||
# else:
|
||||
|
||||
# Configure krb5.conf
|
||||
fstore.backup_file(paths.KRB5_CONF)
|
||||
@@ -125,5 +126,6 @@ def main():
|
||||
|
||||
module.exit_json(changed=True)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -61,13 +61,14 @@ from ansible.module_utils.ansible_ipa_client import (
|
||||
options, sysrestore, paths, configure_nisdomain
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(
|
||||
argument_spec = dict(
|
||||
argument_spec=dict(
|
||||
domain=dict(required=True),
|
||||
nisdomain=dict(required=False),
|
||||
),
|
||||
supports_check_mode = True,
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
||||
module._ansible_debug = True
|
||||
@@ -77,7 +78,7 @@ def main():
|
||||
statestore = sysrestore.StateFile(paths.IPA_CLIENT_SYSRESTORE)
|
||||
|
||||
argspec = inspect.getargspec(configure_nisdomain)
|
||||
if not "statestore" in argspec.args:
|
||||
if "statestore" not in argspec.args:
|
||||
# NUM_VERSION < 40500:
|
||||
configure_nisdomain(options=options, domain=domain)
|
||||
else:
|
||||
@@ -86,5 +87,6 @@ def main():
|
||||
|
||||
module.exit_json(changed=True)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -167,9 +167,10 @@ from ansible.module_utils.ansible_ipa_client import (
|
||||
nosssd_files, configure_openldap_conf, hardcode_ldap_server
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(
|
||||
argument_spec = dict(
|
||||
argument_spec=dict(
|
||||
servers=dict(required=True, type='list'),
|
||||
domain=dict(required=True),
|
||||
realm=dict(required=True),
|
||||
@@ -195,7 +196,7 @@ def main():
|
||||
no_krb5_offline_passwords=dict(required=False, type='bool'),
|
||||
no_dns_sshfp=dict(required=False, type='bool', default=False),
|
||||
),
|
||||
supports_check_mode = True,
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
||||
module._ansible_debug = True
|
||||
@@ -251,7 +252,7 @@ def main():
|
||||
api.Backend.rpcclient.connect()
|
||||
try:
|
||||
api.Backend.rpcclient.forward('ping')
|
||||
except errors.KerberosError as e:
|
||||
except errors.KerberosError:
|
||||
# Cannot connect to the server due to Kerberos error, trying with
|
||||
# delegate=True
|
||||
api.Backend.rpcclient.disconnect()
|
||||
@@ -272,8 +273,8 @@ def main():
|
||||
|
||||
# Get CA certificates from the certificate store
|
||||
try:
|
||||
ca_certs = get_certs_from_ldap(cli_server[0], cli_basedn, cli_realm,
|
||||
ca_enabled)
|
||||
ca_certs = get_certs_from_ldap(cli_server[0], cli_basedn,
|
||||
cli_realm, ca_enabled)
|
||||
except errors.NoCertificateError:
|
||||
if ca_enabled:
|
||||
ca_subject = DN(('CN', 'Certificate Authority'), subject_base)
|
||||
@@ -281,7 +282,8 @@ def main():
|
||||
ca_subject = None
|
||||
ca_certs = certstore.make_compat_ca_certs(ca_certs, cli_realm,
|
||||
ca_subject)
|
||||
ca_certs_trust = [(c, n, certstore.key_policy_to_trust_flags(t, True, u))
|
||||
ca_certs_trust = [(c, n,
|
||||
certstore.key_policy_to_trust_flags(t, True, u))
|
||||
for (c, n, t, u) in ca_certs]
|
||||
|
||||
if hasattr(paths, "KDC_CA_BUNDLE_PEM"):
|
||||
@@ -303,12 +305,13 @@ def main():
|
||||
for cert, nickname, trust_flags in ca_certs_trust:
|
||||
try:
|
||||
ipa_db.add_cert(cert, nickname, trust_flags)
|
||||
except CalledProcessError as e:
|
||||
except CalledProcessError:
|
||||
raise ScriptError(
|
||||
"Failed to add %s to the IPA NSS database." % nickname,
|
||||
rval=CLIENT_INSTALL_ERROR)
|
||||
|
||||
# Add the CA certificates to the platform-dependant systemwide CA store
|
||||
# Add the CA certificates to the platform-dependant systemwide CA
|
||||
# store
|
||||
tasks.insert_ca_certs_into_systemwide_ca_store(ca_certs)
|
||||
|
||||
if not options.on_master:
|
||||
@@ -361,7 +364,8 @@ def main():
|
||||
except Exception:
|
||||
if not options.sssd:
|
||||
logger.warning(
|
||||
"Failed to configure automatic startup of the %s daemon",
|
||||
"Failed to configure automatic startup of the %s "
|
||||
"daemon",
|
||||
nscd.service_name)
|
||||
logger.info(
|
||||
"Caching of users/groups will not be "
|
||||
@@ -434,15 +438,15 @@ def main():
|
||||
sssd.enable()
|
||||
except CalledProcessError as e:
|
||||
logger.warning(
|
||||
"Failed to enable automatic startup of the SSSD daemon: "
|
||||
"%s", e)
|
||||
"Failed to enable automatic startup of the SSSD "
|
||||
"daemon: %s", e)
|
||||
|
||||
if not options.sssd:
|
||||
tasks.modify_pam_to_use_krb5(statestore)
|
||||
logger.info("Kerberos 5 enabled")
|
||||
|
||||
# Update non-SSSD LDAP configuration after authconfig calls as it would
|
||||
# change its configuration otherways
|
||||
# Update non-SSSD LDAP configuration after authconfig calls as it
|
||||
# would change its configuration otherways
|
||||
if not options.sssd:
|
||||
for configurer in [configure_ldap_conf, configure_nslcd_conf]:
|
||||
(retcode, conf, filenames) = configurer(
|
||||
@@ -479,9 +483,9 @@ def main():
|
||||
# Particulary, SSSD might take longer than 6-8 seconds.
|
||||
while n < 10 and not found:
|
||||
try:
|
||||
ipautil.run([paths.GETENT, "passwd", user])
|
||||
ipautil.run([getent_cmd, "passwd", user])
|
||||
found = True
|
||||
except Exception as e:
|
||||
except Exception:
|
||||
time.sleep(1)
|
||||
n = n + 1
|
||||
|
||||
@@ -510,5 +514,6 @@ def main():
|
||||
module.exit_json(changed=True,
|
||||
ca_enabled_ra=ca_enabled)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -91,23 +91,24 @@ from ansible.module_utils.ansible_ipa_client import (
|
||||
timeconf
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(
|
||||
argument_spec = dict(
|
||||
### basic ###
|
||||
argument_spec=dict(
|
||||
# basic
|
||||
ntp_servers=dict(required=False, type='list', default=None),
|
||||
ntp_pool=dict(required=False, default=None),
|
||||
no_ntp=dict(required=False, type='bool', default=False),
|
||||
# force_ntpd=dict(required=False, type='bool', default=False),
|
||||
on_master=dict(required=False, type='bool', default=False),
|
||||
### additional ###
|
||||
# additional
|
||||
servers=dict(required=False, type='list', default=None),
|
||||
domain=dict(required=False, default=None),
|
||||
),
|
||||
supports_check_mode = True,
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
||||
#module._ansible_debug = True
|
||||
# module._ansible_debug = True
|
||||
options.ntp_servers = module.params.get('ntp_servers')
|
||||
options.ntp_pool = module.params.get('ntp_pool')
|
||||
options.no_ntp = module.params.get('no_ntp')
|
||||
@@ -133,10 +134,11 @@ def main():
|
||||
else:
|
||||
synced_ntp = sync_time(options, fstore, statestore)
|
||||
elif options.on_master:
|
||||
# If we're on master skipping the time sync here because it was done
|
||||
# in ipa-server-install
|
||||
logger.info("Skipping attempt to configure and synchronize time with"
|
||||
" chrony server as it has been already done on master.")
|
||||
# If we're on master skipping the time sync here because it was
|
||||
# done in ipa-server-install
|
||||
logger.info(
|
||||
"Skipping attempt to configure and synchronize time with"
|
||||
" chrony server as it has been already done on master.")
|
||||
else:
|
||||
logger.info("Skipping chrony configuration")
|
||||
|
||||
@@ -144,7 +146,8 @@ def main():
|
||||
ntp_srv_servers = []
|
||||
if not options.on_master and options.conf_ntp:
|
||||
# Attempt to sync time with IPA server.
|
||||
# If we're skipping NTP configuration, we also skip the time sync here.
|
||||
# If we're skipping NTP configuration, we also skip the time sync
|
||||
# here.
|
||||
# We assume that NTP servers are discoverable through SRV records
|
||||
# in the DNS.
|
||||
# If that fails, we try to sync directly with IPA server,
|
||||
@@ -166,7 +169,8 @@ def main():
|
||||
break
|
||||
|
||||
if not synced_ntp and not options.ntp_servers:
|
||||
synced_ntp = timeconf.synconce_ntp(cli_server[0], options.debug)
|
||||
synced_ntp = timeconf.synconce_ntp(cli_server[0],
|
||||
options.debug)
|
||||
if not synced_ntp:
|
||||
module.warn(
|
||||
"Unable to sync time with NTP "
|
||||
|
||||
@@ -80,16 +80,17 @@ from ansible.module_utils.ansible_ipa_client import (
|
||||
options, sysrestore, paths, configure_ssh_config, configure_sshd_config
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(
|
||||
argument_spec = dict(
|
||||
argument_spec=dict(
|
||||
servers=dict(required=True, type='list'),
|
||||
no_ssh=dict(required=False, type='bool', default='no'),
|
||||
ssh_trust_dns=dict(required=False, type='bool', default='no'),
|
||||
no_sshd=dict(required=False, type='bool', default='no'),
|
||||
sssd=dict(required=False, type='bool', default='no'),
|
||||
),
|
||||
supports_check_mode = True,
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
||||
module._ansible_debug = True
|
||||
@@ -104,7 +105,7 @@ def main():
|
||||
|
||||
fstore = sysrestore.FileStore(paths.IPA_CLIENT_SYSRESTORE)
|
||||
|
||||
#os.environ['KRB5CCNAME'] = paths.IPA_DNS_CCACHE
|
||||
# os.environ['KRB5CCNAME'] = paths.IPA_DNS_CCACHE
|
||||
|
||||
changed = False
|
||||
if options.conf_ssh:
|
||||
@@ -117,5 +118,6 @@ def main():
|
||||
|
||||
module.exit_json(changed=changed)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -120,9 +120,10 @@ from ansible.module_utils.ansible_ipa_client import (
|
||||
options, sysrestore, paths, configure_sssd_conf, logger
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(
|
||||
argument_spec = dict(
|
||||
argument_spec=dict(
|
||||
servers=dict(required=True, type='list'),
|
||||
domain=dict(required=True),
|
||||
realm=dict(required=True),
|
||||
@@ -139,10 +140,10 @@ def main():
|
||||
preserve_sssd=dict(required=False, type='bool'),
|
||||
no_krb5_offline_passwords=dict(required=False, type='bool'),
|
||||
),
|
||||
supports_check_mode = True,
|
||||
supports_check_mode=True,
|
||||
)
|
||||
#ansible_log = AnsibleModuleLog(module, logger)
|
||||
#options.set_logger(ansible_log)
|
||||
# ansible_log = AnsibleModuleLog(module, logger)
|
||||
# options.set_logger(ansible_log)
|
||||
|
||||
module._ansible_debug = True
|
||||
cli_server = module.params.get('servers')
|
||||
@@ -178,5 +179,6 @@ def main():
|
||||
|
||||
module.exit_json(changed=True)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -215,6 +215,7 @@ from ansible.module_utils.ansible_ipa_client import (
|
||||
IPA_PYTHON_VERSION
|
||||
)
|
||||
|
||||
|
||||
def get_cert_path(cert_path):
|
||||
"""
|
||||
If a CA certificate is passed in on the command line, use that.
|
||||
@@ -231,6 +232,7 @@ def get_cert_path(cert_path):
|
||||
|
||||
return None
|
||||
|
||||
|
||||
def is_client_configured():
|
||||
"""
|
||||
Check if ipa client is configured.
|
||||
@@ -245,6 +247,7 @@ def is_client_configured():
|
||||
os.path.isfile(os.path.join(paths.IPA_CLIENT_SYSRESTORE,
|
||||
sysrestore.SYSRESTORE_STATEFILE)))
|
||||
|
||||
|
||||
def get_ipa_conf():
|
||||
"""
|
||||
Return IPA configuration read from /etc/ipa/default.conf
|
||||
@@ -265,10 +268,11 @@ def get_ipa_conf():
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(
|
||||
argument_spec = dict(
|
||||
### basic ###
|
||||
argument_spec=dict(
|
||||
# basic
|
||||
domain=dict(required=False, default=None),
|
||||
servers=dict(required=False, type='list', default=None),
|
||||
realm=dict(required=False, default=None),
|
||||
@@ -286,13 +290,14 @@ def main():
|
||||
ip_addresses=dict(required=False, type='list', default=None),
|
||||
all_ip_addresses=dict(required=False, type='bool', default=False),
|
||||
on_master=dict(required=False, type='bool', default=False),
|
||||
### sssd ###
|
||||
enable_dns_updates=dict(required=False, type='bool', default=False),
|
||||
# sssd
|
||||
enable_dns_updates=dict(required=False, type='bool',
|
||||
default=False),
|
||||
),
|
||||
supports_check_mode = True,
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
||||
#module._ansible_debug = True
|
||||
# module._ansible_debug = True
|
||||
options.domain_name = module.params.get('domain')
|
||||
options.servers = module.params.get('servers')
|
||||
options.realm_name = module.params.get('realm')
|
||||
@@ -316,12 +321,13 @@ def main():
|
||||
# servers
|
||||
if options.domain_name is None and options.servers is not None:
|
||||
if len(options.servers) > 0:
|
||||
options.domain_name = options.servers[0][options.servers[0].find(".")+1:]
|
||||
options.domain_name = options.servers[0][
|
||||
options.servers[0].find(".")+1:]
|
||||
|
||||
try:
|
||||
self = options
|
||||
|
||||
### HostNameInstallInterface ###
|
||||
# HostNameInstallInterface
|
||||
|
||||
if options.ip_addresses is not None:
|
||||
for value in options.ip_addresses:
|
||||
@@ -331,7 +337,7 @@ def main():
|
||||
raise ValueError("invalid IP address {0}: {1}".format(
|
||||
value, e))
|
||||
|
||||
### ServiceInstallInterface ###
|
||||
# ServiceInstallInterface
|
||||
|
||||
if options.domain_name:
|
||||
validate_domain_name(options.domain_name)
|
||||
@@ -342,12 +348,12 @@ def main():
|
||||
# NUM_VERSION >= 40690:
|
||||
validate_domain_name(options.realm_name, entity="realm")
|
||||
|
||||
### ClientInstallInterface ###
|
||||
# ClientInstallInterface
|
||||
|
||||
if options.kinit_attempts < 1:
|
||||
raise ValueError("expects an integer greater than 0.")
|
||||
|
||||
### ClientInstallInterface.__init__ ###
|
||||
# ClientInstallInterface.__init__
|
||||
|
||||
if self.servers and not self.domain_name:
|
||||
raise RuntimeError(
|
||||
@@ -372,18 +378,18 @@ def main():
|
||||
if self.enable_dns_updates:
|
||||
raise RuntimeError(
|
||||
"--ip-address cannot be used together with"
|
||||
" --enable-dns-updates")
|
||||
" --enable-dns-updates")
|
||||
|
||||
if self.all_ip_addresses:
|
||||
raise RuntimeError(
|
||||
"--ip-address cannot be used together with"
|
||||
"--all-ip-addresses")
|
||||
|
||||
### SSSDInstallInterface ###
|
||||
# SSSDInstallInterface
|
||||
|
||||
self.no_sssd = False
|
||||
|
||||
### ClientInstall ###
|
||||
# ClientInstall
|
||||
|
||||
if options.ca_cert_files is not None:
|
||||
for value in options.ca_cert_files:
|
||||
@@ -396,18 +402,20 @@ def main():
|
||||
if not os.path.isfile(value):
|
||||
raise ValueError("'%s' is not a file" % value)
|
||||
if not os.path.isabs(value):
|
||||
raise ValueError("'%s' is not an absolute file path" % value)
|
||||
raise ValueError("'%s' is not an absolute file path" %
|
||||
value)
|
||||
|
||||
try:
|
||||
x509.load_certificate_from_file(value)
|
||||
except Exception:
|
||||
raise ValueError("'%s' is not a valid certificate file" % value)
|
||||
raise ValueError("'%s' is not a valid certificate file" %
|
||||
value)
|
||||
|
||||
#self.prompt_password = self.interactive
|
||||
# self.prompt_password = self.interactive
|
||||
|
||||
self.no_ac = False
|
||||
|
||||
### ClientInstall.__init__ ###
|
||||
# ClientInstall.__init__
|
||||
|
||||
if self.firefox_dir and not self.configure_firefox:
|
||||
raise RuntimeError(
|
||||
@@ -417,7 +425,7 @@ def main():
|
||||
except (RuntimeError, ValueError) as e:
|
||||
module.fail_json(msg=str(e))
|
||||
|
||||
### ipaclient.install.client.init ###
|
||||
# ipaclient.install.client.init
|
||||
|
||||
# root_logger
|
||||
options.debug = False
|
||||
@@ -427,30 +435,31 @@ def main():
|
||||
options.domain = None
|
||||
options.server = options.servers
|
||||
options.realm = options.realm_name
|
||||
#installer.primary = installer.fixed_primary
|
||||
#if installer.principal:
|
||||
# installer.password = installer.admin_password
|
||||
#else:
|
||||
# installer.password = installer.host_password
|
||||
# installer.primary = installer.fixed_primary
|
||||
# if installer.principal:
|
||||
# installer.password = installer.admin_password
|
||||
# else:
|
||||
# installer.password = installer.host_password
|
||||
installer.hostname = installer.host_name
|
||||
options.conf_ntp = not options.no_ntp
|
||||
#installer.trust_sshfp = installer.ssh_trust_dns
|
||||
#installer.conf_ssh = not installer.no_ssh
|
||||
#installer.conf_sshd = not installer.no_sshd
|
||||
#installer.conf_sudo = not installer.no_sudo
|
||||
#installer.create_sshfp = not installer.no_dns_sshfp
|
||||
# installer.trust_sshfp = installer.ssh_trust_dns
|
||||
# installer.conf_ssh = not installer.no_ssh
|
||||
# installer.conf_sshd = not installer.no_sshd
|
||||
# installer.conf_sudo = not installer.no_sudo
|
||||
# installer.create_sshfp = not installer.no_dns_sshfp
|
||||
if installer.ca_cert_files:
|
||||
installer.ca_cert_file = installer.ca_cert_files[-1]
|
||||
else:
|
||||
installer.ca_cert_file = None
|
||||
#installer.location = installer.automount_location
|
||||
# installer.location = installer.automount_location
|
||||
installer.dns_updates = installer.enable_dns_updates
|
||||
#installer.krb5_offline_passwords = not installer.no_krb5_offline_passwords
|
||||
# installer.krb5_offline_passwords = \
|
||||
# not installer.no_krb5_offline_passwords
|
||||
installer.sssd = not installer.no_sssd
|
||||
|
||||
try:
|
||||
|
||||
### client ###
|
||||
# client
|
||||
|
||||
# global variables
|
||||
hostname = None
|
||||
@@ -466,7 +475,7 @@ def main():
|
||||
cli_basedn = None
|
||||
# end of global variables
|
||||
|
||||
### client.install_check ###
|
||||
# client.install_check
|
||||
|
||||
logger.info("This program will set up FreeIPA client.")
|
||||
logger.info("Version %s", version.VERSION)
|
||||
@@ -484,14 +493,14 @@ def main():
|
||||
|
||||
tasks.check_selinux_status()
|
||||
|
||||
#if is_ipa_client_installed(fstore, on_master=options.on_master):
|
||||
# logger.error("IPA client is already configured on this system.")
|
||||
# logger.info(
|
||||
# "If you want to reinstall the IPA client, uninstall it first "
|
||||
# "using 'ipa-client-install --uninstall'.")
|
||||
# raise ScriptError(
|
||||
# "IPA client is already configured on this system.",
|
||||
# rval=CLIENT_ALREADY_CONFIGURED)
|
||||
# if is_ipa_client_installed(fstore, on_master=options.on_master):
|
||||
# logger.error("IPA client is already configured on this system.")
|
||||
# logger.info(
|
||||
# "If you want to reinstall the IPA client, uninstall it first "
|
||||
# "using 'ipa-client-install --uninstall'.")
|
||||
# raise ScriptError(
|
||||
# "IPA client is already configured on this system.",
|
||||
# rval=CLIENT_ALREADY_CONFIGURED)
|
||||
|
||||
if check_ldap_conf is not None:
|
||||
check_ldap_conf()
|
||||
@@ -509,16 +518,16 @@ def main():
|
||||
pass
|
||||
|
||||
# password, principal and keytab are checked in tasks/install.yml
|
||||
#if options.unattended and (
|
||||
# options.password is None and
|
||||
# options.principal is None and
|
||||
# options.keytab is None and
|
||||
# options.prompt_password is False and
|
||||
# not options.on_master
|
||||
#):
|
||||
# raise ScriptError(
|
||||
# "One of password / principal / keytab is required.",
|
||||
# rval=CLIENT_INSTALL_ERROR)
|
||||
# if options.unattended and (
|
||||
# options.password is None and
|
||||
# options.principal is None and
|
||||
# options.keytab is None and
|
||||
# options.prompt_password is False and
|
||||
# not options.on_master
|
||||
# ):
|
||||
# raise ScriptError(
|
||||
# "One of password / principal / keytab is required.",
|
||||
# rval=CLIENT_INSTALL_ERROR)
|
||||
|
||||
if options.hostname:
|
||||
hostname = options.hostname
|
||||
@@ -549,17 +558,17 @@ def main():
|
||||
# --no-sssd is not supported any more for rhel-based distros
|
||||
if not tasks.is_nosssd_supported() and not options.sssd:
|
||||
raise ScriptError(
|
||||
"Option '--no-sssd' is incompatible with the 'authselect' tool "
|
||||
"provided by this distribution for configuring system "
|
||||
"authentication resources",
|
||||
"Option '--no-sssd' is incompatible with the 'authselect' "
|
||||
"tool provided by this distribution for configuring "
|
||||
"system authentication resources",
|
||||
rval=CLIENT_INSTALL_ERROR)
|
||||
|
||||
# --noac is not supported any more for rhel-based distros
|
||||
if not tasks.is_nosssd_supported() and options.no_ac:
|
||||
raise ScriptError(
|
||||
"Option '--noac' is incompatible with the 'authselect' tool "
|
||||
"provided by this distribution for configuring system "
|
||||
"authentication resources",
|
||||
"Option '--noac' is incompatible with the 'authselect' "
|
||||
"tool provided by this distribution for configuring "
|
||||
"system authentication resources",
|
||||
rval=CLIENT_INSTALL_ERROR)
|
||||
|
||||
# when installing with '--no-sssd' option, check whether nss-ldap is
|
||||
@@ -579,15 +588,15 @@ def main():
|
||||
rval=CLIENT_INSTALL_ERROR)
|
||||
|
||||
# principal and keytab are checked in tasks/install.yml
|
||||
#if options.keytab and options.principal:
|
||||
# raise ScriptError(
|
||||
# "Options 'principal' and 'keytab' cannot be used together.",
|
||||
# rval=CLIENT_INSTALL_ERROR)
|
||||
# if options.keytab and options.principal:
|
||||
# raise ScriptError(
|
||||
# "Options 'principal' and 'keytab' cannot be used together.",
|
||||
# rval=CLIENT_INSTALL_ERROR)
|
||||
|
||||
# keytab and force_join are checked in tasks/install.yml
|
||||
#if options.keytab and options.force_join:
|
||||
# logger.warning("Option 'force-join' has no additional effect "
|
||||
# "when used with together with option 'keytab'.")
|
||||
# if options.keytab and options.force_join:
|
||||
# logger.warning("Option 'force-join' has no additional effect "
|
||||
# "when used with together with option 'keytab'.")
|
||||
|
||||
# Added with freeipa-4.7.1 >>>
|
||||
# Remove invalid keytab file
|
||||
@@ -606,7 +615,8 @@ def main():
|
||||
not options.ca_cert_file and
|
||||
get_cert_path(options.ca_cert_file) == paths.IPA_CA_CRT
|
||||
):
|
||||
logger.warning("Using existing certificate '%s'.", paths.IPA_CA_CRT)
|
||||
logger.warning("Using existing certificate '%s'.",
|
||||
paths.IPA_CA_CRT)
|
||||
|
||||
if not check_ip_addresses(options):
|
||||
raise ScriptError(
|
||||
@@ -625,9 +635,9 @@ def main():
|
||||
)
|
||||
|
||||
if options.server and ret != 0:
|
||||
# There is no point to continue with installation as server list was
|
||||
# passed as a fixed list of server and thus we cannot discover any
|
||||
# better result
|
||||
# There is no point to continue with installation as server list
|
||||
# was passed as a fixed list of server and thus we cannot discover
|
||||
# any better result
|
||||
logger.error(
|
||||
"Failed to verify that %s is an IPA Server.",
|
||||
', '.join(options.server))
|
||||
@@ -675,7 +685,8 @@ def main():
|
||||
# logger.info(
|
||||
# "DNS discovery failed to determine your DNS domain")
|
||||
# cli_domain = user_input(
|
||||
# "Provide the domain name of your IPA server (ex: example.com)",
|
||||
# "Provide the domain name of your IPA server "
|
||||
# "(ex: example.com)",
|
||||
# allow_empty=False)
|
||||
# cli_domain_source = 'Provided interactively'
|
||||
# logger.debug(
|
||||
@@ -714,7 +725,7 @@ def main():
|
||||
# ]
|
||||
# cli_server_source = 'Provided interactively'
|
||||
# logger.debug(
|
||||
# "will use interactively provided server: %s", cli_server[0])
|
||||
# "will use interactively provided server: %s", cli_server[0])
|
||||
ret = ds.search(
|
||||
domain=cli_domain,
|
||||
servers=cli_server,
|
||||
@@ -722,8 +733,8 @@ def main():
|
||||
ca_cert_path=get_cert_path(options.ca_cert_file))
|
||||
|
||||
else:
|
||||
# Only set dnsok to True if we were not passed in one or more servers
|
||||
# and if DNS discovery actually worked.
|
||||
# Only set dnsok to True if we were not passed in one or more
|
||||
# servers and if DNS discovery actually worked.
|
||||
if not options.server:
|
||||
(server, domain) = ds.check_domain(
|
||||
ds.domain, set(), "Validating DNS Discovery")
|
||||
@@ -793,29 +804,29 @@ def main():
|
||||
logger.info("Discovery was successful!")
|
||||
elif not options.unattended:
|
||||
raise ScriptError("No interactive installation")
|
||||
# if not options.server:
|
||||
# logger.warning(
|
||||
# "The failure to use DNS to find your IPA "
|
||||
# "server indicates that your resolv.conf file is not properly "
|
||||
# "configured.")
|
||||
# logger.info(
|
||||
# "Autodiscovery of servers for failover cannot work "
|
||||
# "with this configuration.")
|
||||
# logger.info(
|
||||
# "If you proceed with the installation, services "
|
||||
# "will be configured to always access the discovered server for "
|
||||
# "all operations and will not fail over to other servers in case "
|
||||
# "of failure.")
|
||||
# if not user_input(
|
||||
# "Proceed with fixed values and no DNS discovery?", False):
|
||||
# raise ScriptError(rval=CLIENT_INSTALL_ERROR)
|
||||
# if not options.server:
|
||||
# logger.warning(
|
||||
# "The failure to use DNS to find your IPA "
|
||||
# "server indicates that your resolv.conf file is not properly "
|
||||
# "configured.")
|
||||
# logger.info(
|
||||
# "Autodiscovery of servers for failover cannot work "
|
||||
# "with this configuration.")
|
||||
# logger.info(
|
||||
# "If you proceed with the installation, services "
|
||||
# "will be configured to always access the discovered server for "
|
||||
# "all operations and will not fail over to other servers in case "
|
||||
# "of failure.")
|
||||
# if not user_input(
|
||||
# "Proceed with fixed values and no DNS discovery?", False):
|
||||
# raise ScriptError(rval=CLIENT_INSTALL_ERROR)
|
||||
|
||||
# Do not ask for time source
|
||||
#if options.conf_ntp:
|
||||
# if not options.on_master and not options.unattended and not (
|
||||
# options.ntp_servers or options.ntp_pool):
|
||||
# options.ntp_servers, options.ntp_pool = \
|
||||
# timeconf.get_time_source()
|
||||
# if options.conf_ntp:
|
||||
# if not options.on_master and not options.unattended and not (
|
||||
# options.ntp_servers or options.ntp_pool):
|
||||
# options.ntp_servers, options.ntp_pool = \
|
||||
# timeconf.get_time_source()
|
||||
|
||||
cli_realm = ds.realm
|
||||
cli_realm_source = ds.realm_source
|
||||
@@ -823,11 +834,13 @@ def main():
|
||||
|
||||
if options.realm_name and options.realm_name != cli_realm:
|
||||
logger.error(
|
||||
"The provided realm name [%s] does not match discovered one [%s]",
|
||||
"The provided realm name [%s] does not match discovered "
|
||||
"one [%s]",
|
||||
options.realm_name, cli_realm)
|
||||
logger.debug("(%s: %s)", cli_realm, cli_realm_source)
|
||||
raise ScriptError(
|
||||
"The provided realm name [%s] does not match discovered one [%s]" % (options.realm_name, cli_realm),
|
||||
"The provided realm name [%s] does not match discovered "
|
||||
"one [%s]" % (options.realm_name, cli_realm),
|
||||
rval=CLIENT_INSTALL_ERROR)
|
||||
|
||||
cli_basedn = ds.basedn
|
||||
@@ -874,22 +887,22 @@ def main():
|
||||
"installation may fail.")
|
||||
break
|
||||
|
||||
#logger.info()
|
||||
#if not options.unattended and not user_input(
|
||||
# "Continue to configure the system with these values?", False):
|
||||
# raise ScriptError(rval=CLIENT_INSTALL_ERROR)
|
||||
# logger.info()
|
||||
# if not options.unattended and not user_input(
|
||||
# "Continue to configure the system with these values?", False):
|
||||
# raise ScriptError(rval=CLIENT_INSTALL_ERROR)
|
||||
|
||||
except ScriptError as e:
|
||||
module.fail_json(msg=str(e))
|
||||
|
||||
#########################################################################
|
||||
|
||||
### client._install ###
|
||||
# client._install
|
||||
|
||||
# May not happen in here at this time
|
||||
#if not options.on_master:
|
||||
# # Try removing old principals from the keytab
|
||||
# purge_host_keytab(cli_realm)
|
||||
# if not options.on_master:
|
||||
# # Try removing old principals from the keytab
|
||||
# purge_host_keytab(cli_realm)
|
||||
|
||||
# Check if ipa client is already configured
|
||||
if is_client_configured():
|
||||
@@ -922,5 +935,6 @@ def main():
|
||||
client_already_configured=client_already_configured,
|
||||
ipa_python_version=IPA_PYTHON_VERSION)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -108,9 +108,10 @@ from ansible.module_utils.ansible_ipa_client import (
|
||||
SECURE_PATH, paths, kinit_keytab, run, GSSError, configure_krb5_conf
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
module = AnsibleModule(
|
||||
argument_spec = dict(
|
||||
argument_spec=dict(
|
||||
servers=dict(required=True, type='list'),
|
||||
domain=dict(required=True),
|
||||
realm=dict(required=True),
|
||||
@@ -118,7 +119,7 @@ def main():
|
||||
kdc=dict(required=True),
|
||||
kinit_attempts=dict(required=False, type='int', default=5),
|
||||
),
|
||||
supports_check_mode = True,
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
||||
module._ansible_debug = True
|
||||
@@ -167,46 +168,46 @@ def main():
|
||||
# Second try: Validate krb5 keytab with temporary krb5
|
||||
# configuration
|
||||
if not krb5_conf_ok:
|
||||
try:
|
||||
(krb_fd, krb_name) = tempfile.mkstemp()
|
||||
os.close(krb_fd)
|
||||
configure_krb5_conf(
|
||||
cli_realm=realm,
|
||||
cli_domain=domain,
|
||||
cli_server=servers,
|
||||
cli_kdc=kdc,
|
||||
dnsok=False,
|
||||
filename=krb_name,
|
||||
client_domain=client_domain,
|
||||
client_hostname=hostname,
|
||||
configure_sssd=sssd,
|
||||
force=False)
|
||||
try:
|
||||
(krb_fd, krb_name) = tempfile.mkstemp()
|
||||
os.close(krb_fd)
|
||||
configure_krb5_conf(
|
||||
cli_realm=realm,
|
||||
cli_domain=domain,
|
||||
cli_server=servers,
|
||||
cli_kdc=kdc,
|
||||
dnsok=False,
|
||||
filename=krb_name,
|
||||
client_domain=client_domain,
|
||||
client_hostname=hostname,
|
||||
configure_sssd=sssd,
|
||||
force=False)
|
||||
|
||||
try:
|
||||
kinit_keytab(host_principal, paths.KRB5_KEYTAB,
|
||||
paths.IPA_DNS_CCACHE,
|
||||
config=krb_name,
|
||||
attempts=kinit_attempts)
|
||||
krb5_keytab_ok = True
|
||||
try:
|
||||
kinit_keytab(host_principal, paths.KRB5_KEYTAB,
|
||||
paths.IPA_DNS_CCACHE,
|
||||
config=krb_name,
|
||||
attempts=kinit_attempts)
|
||||
krb5_keytab_ok = True
|
||||
|
||||
# Test IPA
|
||||
env['KRB5_CONFIG'] = krb_name
|
||||
try:
|
||||
result = run(["/usr/bin/ipa", "ping"], raiseonerr=False,
|
||||
env=env)
|
||||
if result.returncode == 0:
|
||||
ping_test_ok = True
|
||||
except OSError:
|
||||
pass
|
||||
# Test IPA
|
||||
env['KRB5_CONFIG'] = krb_name
|
||||
try:
|
||||
result = run(["/usr/bin/ipa", "ping"], raiseonerr=False,
|
||||
env=env)
|
||||
if result.returncode == 0:
|
||||
ping_test_ok = True
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
except GSSError:
|
||||
pass
|
||||
except GSSError:
|
||||
pass
|
||||
|
||||
finally:
|
||||
try:
|
||||
os.remove(krb_name)
|
||||
except OSError:
|
||||
module.fail_json(msg="Could not remove %s" % krb_name)
|
||||
finally:
|
||||
try:
|
||||
os.remove(krb_name)
|
||||
except OSError:
|
||||
module.fail_json(msg="Could not remove %s" % krb_name)
|
||||
|
||||
module.exit_json(changed=False,
|
||||
krb5_keytab_ok=krb5_keytab_ok,
|
||||
@@ -214,5 +215,6 @@ def main():
|
||||
ca_crt_exists=ca_crt_exists,
|
||||
ping_test_ok=ping_test_ok)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -26,11 +26,12 @@ from ipapython.version import NUM_VERSION, VERSION
|
||||
|
||||
if NUM_VERSION < 30201:
|
||||
# See ipapython/version.py
|
||||
IPA_MAJOR,IPA_MINOR,IPA_RELEASE = [ int(x) for x in VERSION.split(".", 2) ]
|
||||
IPA_MAJOR, IPA_MINOR, IPA_RELEASE = [int(x) for x in VERSION.split(".", 2)]
|
||||
IPA_PYTHON_VERSION = IPA_MAJOR*10000 + IPA_MINOR*100 + IPA_RELEASE
|
||||
else:
|
||||
IPA_PYTHON_VERSION = NUM_VERSION
|
||||
|
||||
|
||||
class installer_obj(object):
|
||||
def __init__(self):
|
||||
pass
|
||||
@@ -38,20 +39,20 @@ class installer_obj(object):
|
||||
def set_logger(self, logger):
|
||||
self.logger = logger
|
||||
|
||||
#def __getattribute__(self, attr):
|
||||
# def __getattribute__(self, attr):
|
||||
# value = super(installer_obj, self).__getattribute__(attr)
|
||||
# if not attr.startswith("--") and not attr.endswith("--"):
|
||||
# logger.debug(
|
||||
# " <-- Accessing installer.%s (%s)" % (attr, repr(value)))
|
||||
# return value
|
||||
|
||||
#def __getattr__(self, attr):
|
||||
# #logger.info(" --> ADDING missing installer.%s" % attr)
|
||||
# def __getattr__(self, attr):
|
||||
# # logger.info(" --> ADDING missing installer.%s" % attr)
|
||||
# self.logger.warn(" --> ADDING missing installer.%s" % attr)
|
||||
# setattr(self, attr, None)
|
||||
# return getattr(self, attr)
|
||||
|
||||
#def __setattr__(self, attr, value):
|
||||
# def __setattr__(self, attr, value):
|
||||
# logger.debug(" --> Setting installer.%s to %s" % (attr, repr(value)))
|
||||
# return super(installer_obj, self).__setattr__(attr, value)
|
||||
|
||||
@@ -59,6 +60,7 @@ class installer_obj(object):
|
||||
for name in self.__dict__:
|
||||
yield self, name
|
||||
|
||||
|
||||
# Initialize installer settings
|
||||
installer = installer_obj()
|
||||
# Create options
|
||||
@@ -174,10 +176,13 @@ if NUM_VERSION >= 40400:
|
||||
else:
|
||||
get_ca_cert = None
|
||||
get_ca_certs = ipa_client_install.get_ca_certs
|
||||
SECURE_PATH = ("/bin:/sbin:/usr/kerberos/bin:/usr/kerberos/sbin:/usr/bin:/usr/sbin")
|
||||
SECURE_PATH = ("/bin:/sbin:/usr/kerberos/bin:/usr/kerberos/sbin:"
|
||||
"/usr/bin:/usr/sbin")
|
||||
|
||||
get_server_connection_interface = ipa_client_install.get_server_connection_interface
|
||||
configure_nsswitch_database = ipa_client_install.configure_nsswitch_database
|
||||
get_server_connection_interface = \
|
||||
ipa_client_install.get_server_connection_interface
|
||||
configure_nsswitch_database = \
|
||||
ipa_client_install.configure_nsswitch_database
|
||||
disable_ra = ipa_client_install.disable_ra
|
||||
client_dns = ipa_client_install.client_dns
|
||||
configure_certmonger = ipa_client_install.configure_certmonger
|
||||
@@ -250,7 +255,7 @@ def ansible_module_get_parsed_ip_addresses(ansible_module,
|
||||
if ip_addresses is None:
|
||||
return None
|
||||
|
||||
ip_addrs = [ ]
|
||||
ip_addrs = []
|
||||
for ip in ip_addresses:
|
||||
try:
|
||||
ip_parsed = ipautil.CheckedIPAddress(ip)
|
||||
|
||||
Reference in New Issue
Block a user