Skip to content

Commit

Permalink
ipa_service: Add skip_host_check option (#4417) (#4436)
Browse files Browse the repository at this point in the history
* ipa_service: Add `skip_host_check` option

* Update plugins/modules/identity/ipa/ipa_service.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/modules/identity/ipa/ipa_service.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/modules/identity/ipa/ipa_service.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* 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 <felix@fontein.de>
(cherry picked from commit 1b357ba)

Co-authored-by: sodd <sodd@users.noreply.github.com>
  • Loading branch information
patchback[bot] and sodd authored Apr 1, 2022
1 parent 2fcb77f commit 868edfa
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
4 changes: 4 additions & 0 deletions changelogs/fragments/4417-ipa_service-add-skip_host_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
minor_changes:
- ipa_service - add ``skip_host_check`` parameter.
(https://github.com/ansible-collections/community.general/pull/4417).
17 changes: 14 additions & 3 deletions plugins/modules/identity/ipa/ipa_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@
- 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
Expand Down Expand Up @@ -111,17 +119,19 @@ def service_remove_host(self, name, item):
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]
Expand All @@ -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:
Expand Down Expand Up @@ -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']))
Expand Down

0 comments on commit 868edfa

Please sign in to comment.