From 868edfa664addaf075cad2c5b4b00f71e9608cf7 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Fri, 1 Apr 2022 23:07:23 +0200 Subject: [PATCH] ipa_service: Add `skip_host_check` option (#4417) (#4436) * ipa_service: Add `skip_host_check` option * Update plugins/modules/identity/ipa/ipa_service.py Co-authored-by: Felix Fontein * Update plugins/modules/identity/ipa/ipa_service.py Co-authored-by: Felix Fontein * Update plugins/modules/identity/ipa/ipa_service.py Co-authored-by: Felix Fontein * changelogs/fragments: Add 4417-ipa_service-add-skip_host_check.yml Co-authored-by: sodd <4178855+sodd@users.noreply.github.com> Co-authored-by: Felix Fontein (cherry picked from commit 1b357bade7f570653d0163410a15b2b39a57e625) Co-authored-by: sodd --- .../4417-ipa_service-add-skip_host_check.yml | 4 ++++ plugins/modules/identity/ipa/ipa_service.py | 17 ++++++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/4417-ipa_service-add-skip_host_check.yml diff --git a/changelogs/fragments/4417-ipa_service-add-skip_host_check.yml b/changelogs/fragments/4417-ipa_service-add-skip_host_check.yml new file mode 100644 index 0000000000..f4e5d6e49c --- /dev/null +++ b/changelogs/fragments/4417-ipa_service-add-skip_host_check.yml @@ -0,0 +1,4 @@ +--- +minor_changes: + - ipa_service - add ``skip_host_check`` parameter. + (https://github.com/ansible-collections/community.general/pull/4417). diff --git a/plugins/modules/identity/ipa/ipa_service.py b/plugins/modules/identity/ipa/ipa_service.py index f85b80d44e..63c6d8216d 100644 --- a/plugins/modules/identity/ipa/ipa_service.py +++ b/plugins/modules/identity/ipa/ipa_service.py @@ -32,6 +32,14 @@ options: - Force principal name even if host is not in DNS. required: false type: bool + skip_host_check: + description: + - Force service to be created even when host object does not exist to manage it. + - This is only used on creation, not for updating existing services. + required: false + type: bool + default: false + version_added: 4.7.0 state: description: State to ensure. required: false @@ -111,17 +119,19 @@ class ServiceIPAClient(IPAClient): return self._post_json(method='service_remove_host', name=name, item={'host': item}) -def get_service_dict(force=None, krbcanonicalname=None): +def get_service_dict(force=None, krbcanonicalname=None, skip_host_check=None): data = {} if force is not None: data['force'] = force if krbcanonicalname is not None: data['krbcanonicalname'] = krbcanonicalname + if skip_host_check is not None: + data['skip_host_check'] = skip_host_check return data def get_service_diff(client, ipa_host, module_service): - non_updateable_keys = ['force', 'krbcanonicalname'] + non_updateable_keys = ['force', 'krbcanonicalname', 'skip_host_check'] for key in non_updateable_keys: if key in module_service: del module_service[key] @@ -135,7 +145,7 @@ def ensure(module, client): hosts = module.params['hosts'] ipa_service = client.service_find(name=name) - module_service = get_service_dict(force=module.params['force']) + module_service = get_service_dict(force=module.params['force'], skip_host_check=module.params['skip_host_check']) changed = False if state in ['present', 'enabled', 'disabled']: if not ipa_service: @@ -183,6 +193,7 @@ def main(): argument_spec.update( krbcanonicalname=dict(type='str', required=True, aliases=['name']), force=dict(type='bool', required=False), + skip_host_check=dict(type='bool', default=False, required=False), hosts=dict(type='list', required=False, elements='str'), state=dict(type='str', required=False, default='present', choices=['present', 'absent']))