mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-03-26 21:33:12 +00:00
Reformat everything.
This commit is contained in:
@@ -130,41 +130,41 @@ from ansible_collections.community.general.plugins.module_utils.cmd_runner impor
|
||||
class IPAKeytab:
|
||||
def __init__(self, module, **kwargs):
|
||||
self.module = module
|
||||
self.path = kwargs['path']
|
||||
self.state = kwargs['state']
|
||||
self.principal = kwargs['principal']
|
||||
self.ipa_host = kwargs['ipa_host']
|
||||
self.ldap_uri = kwargs['ldap_uri']
|
||||
self.bind_dn = kwargs['bind_dn']
|
||||
self.bind_pw = kwargs['bind_pw']
|
||||
self.password = kwargs['password']
|
||||
self.ca_cert = kwargs['ca_cert']
|
||||
self.sasl_mech = kwargs['sasl_mech']
|
||||
self.retrieve_mode = kwargs['retrieve_mode']
|
||||
self.encryption_types = kwargs['encryption_types']
|
||||
self.path = kwargs["path"]
|
||||
self.state = kwargs["state"]
|
||||
self.principal = kwargs["principal"]
|
||||
self.ipa_host = kwargs["ipa_host"]
|
||||
self.ldap_uri = kwargs["ldap_uri"]
|
||||
self.bind_dn = kwargs["bind_dn"]
|
||||
self.bind_pw = kwargs["bind_pw"]
|
||||
self.password = kwargs["password"]
|
||||
self.ca_cert = kwargs["ca_cert"]
|
||||
self.sasl_mech = kwargs["sasl_mech"]
|
||||
self.retrieve_mode = kwargs["retrieve_mode"]
|
||||
self.encryption_types = kwargs["encryption_types"]
|
||||
|
||||
self.runner = CmdRunner(
|
||||
module,
|
||||
command='ipa-getkeytab',
|
||||
command="ipa-getkeytab",
|
||||
arg_formats=dict(
|
||||
retrieve_mode=cmd_runner_fmt.as_bool('--retrieve'),
|
||||
path=cmd_runner_fmt.as_opt_val('--keytab'),
|
||||
ipa_host=cmd_runner_fmt.as_opt_val('--server'),
|
||||
principal=cmd_runner_fmt.as_opt_val('--principal'),
|
||||
ldap_uri=cmd_runner_fmt.as_opt_val('--ldapuri'),
|
||||
bind_dn=cmd_runner_fmt.as_opt_val('--binddn'),
|
||||
bind_pw=cmd_runner_fmt.as_opt_val('--bindpw'),
|
||||
password=cmd_runner_fmt.as_opt_val('--password'),
|
||||
ca_cert=cmd_runner_fmt.as_opt_val('--cacert'),
|
||||
sasl_mech=cmd_runner_fmt.as_opt_val('--mech'),
|
||||
encryption_types=cmd_runner_fmt.as_opt_val('--enctypes'),
|
||||
)
|
||||
retrieve_mode=cmd_runner_fmt.as_bool("--retrieve"),
|
||||
path=cmd_runner_fmt.as_opt_val("--keytab"),
|
||||
ipa_host=cmd_runner_fmt.as_opt_val("--server"),
|
||||
principal=cmd_runner_fmt.as_opt_val("--principal"),
|
||||
ldap_uri=cmd_runner_fmt.as_opt_val("--ldapuri"),
|
||||
bind_dn=cmd_runner_fmt.as_opt_val("--binddn"),
|
||||
bind_pw=cmd_runner_fmt.as_opt_val("--bindpw"),
|
||||
password=cmd_runner_fmt.as_opt_val("--password"),
|
||||
ca_cert=cmd_runner_fmt.as_opt_val("--cacert"),
|
||||
sasl_mech=cmd_runner_fmt.as_opt_val("--mech"),
|
||||
encryption_types=cmd_runner_fmt.as_opt_val("--enctypes"),
|
||||
),
|
||||
)
|
||||
|
||||
def _exec(self, check_rc=True):
|
||||
with self.runner(
|
||||
"retrieve_mode path ipa_host principal ldap_uri bind_dn bind_pw password ca_cert sasl_mech encryption_types",
|
||||
check_rc=check_rc
|
||||
check_rc=check_rc,
|
||||
) as ctx:
|
||||
rc, out, err = ctx.run()
|
||||
return out
|
||||
@@ -172,47 +172,48 @@ class IPAKeytab:
|
||||
|
||||
def main():
|
||||
arg_spec = dict(
|
||||
path=dict(type='path', required=True, aliases=["keytab"]),
|
||||
state=dict(default='present', choices=['present', 'absent']),
|
||||
principal=dict(type='str', required=True),
|
||||
ipa_host=dict(type='str'),
|
||||
ldap_uri=dict(type='str'),
|
||||
bind_dn=dict(type='str'),
|
||||
bind_pw=dict(type='str'),
|
||||
password=dict(type='str', no_log=True),
|
||||
ca_cert=dict(type='path'),
|
||||
sasl_mech=dict(type='str', choices=["GSSAPI", "EXTERNAL"]),
|
||||
retrieve_mode=dict(type='bool'),
|
||||
encryption_types=dict(type='str'),
|
||||
force=dict(type='bool'),
|
||||
path=dict(type="path", required=True, aliases=["keytab"]),
|
||||
state=dict(default="present", choices=["present", "absent"]),
|
||||
principal=dict(type="str", required=True),
|
||||
ipa_host=dict(type="str"),
|
||||
ldap_uri=dict(type="str"),
|
||||
bind_dn=dict(type="str"),
|
||||
bind_pw=dict(type="str"),
|
||||
password=dict(type="str", no_log=True),
|
||||
ca_cert=dict(type="path"),
|
||||
sasl_mech=dict(type="str", choices=["GSSAPI", "EXTERNAL"]),
|
||||
retrieve_mode=dict(type="bool"),
|
||||
encryption_types=dict(type="str"),
|
||||
force=dict(type="bool"),
|
||||
)
|
||||
module = AnsibleModule(
|
||||
argument_spec=arg_spec,
|
||||
mutually_exclusive=[('ipa_host', 'ldap_uri'), ('retrieve_mode', 'password')],
|
||||
mutually_exclusive=[("ipa_host", "ldap_uri"), ("retrieve_mode", "password")],
|
||||
supports_check_mode=True,
|
||||
)
|
||||
|
||||
path = module.params['path']
|
||||
state = module.params['state']
|
||||
force = module.params['force']
|
||||
path = module.params["path"]
|
||||
state = module.params["state"]
|
||||
force = module.params["force"]
|
||||
|
||||
keytab = IPAKeytab(module,
|
||||
path=path,
|
||||
state=state,
|
||||
principal=module.params['principal'],
|
||||
ipa_host=module.params['ipa_host'],
|
||||
ldap_uri=module.params['ldap_uri'],
|
||||
bind_dn=module.params['bind_dn'],
|
||||
bind_pw=module.params['bind_pw'],
|
||||
password=module.params['password'],
|
||||
ca_cert=module.params['ca_cert'],
|
||||
sasl_mech=module.params['sasl_mech'],
|
||||
retrieve_mode=module.params['retrieve_mode'],
|
||||
encryption_types=module.params['encryption_types'],
|
||||
)
|
||||
keytab = IPAKeytab(
|
||||
module,
|
||||
path=path,
|
||||
state=state,
|
||||
principal=module.params["principal"],
|
||||
ipa_host=module.params["ipa_host"],
|
||||
ldap_uri=module.params["ldap_uri"],
|
||||
bind_dn=module.params["bind_dn"],
|
||||
bind_pw=module.params["bind_pw"],
|
||||
password=module.params["password"],
|
||||
ca_cert=module.params["ca_cert"],
|
||||
sasl_mech=module.params["sasl_mech"],
|
||||
retrieve_mode=module.params["retrieve_mode"],
|
||||
encryption_types=module.params["encryption_types"],
|
||||
)
|
||||
|
||||
changed = False
|
||||
if state == 'present':
|
||||
if state == "present":
|
||||
if os.path.exists(path):
|
||||
if force and not module.check_mode:
|
||||
try:
|
||||
@@ -227,7 +228,7 @@ def main():
|
||||
changed = True
|
||||
keytab._exec()
|
||||
|
||||
if state == 'absent':
|
||||
if state == "absent":
|
||||
if os.path.exists(path):
|
||||
changed = True
|
||||
if not module.check_mode:
|
||||
@@ -239,5 +240,5 @@ def main():
|
||||
module.exit_json(changed=changed)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user