mirror of
https://github.com/freeipa/ansible-freeipa.git
synced 2026-05-06 21:33:14 +00:00
ipadnsforwardzone: Allow execution of plugin in client host.
Update dnsforwardzone README file and add tests for executing plugin with
`ipaapi_context` set to `client`.
A new test playbook can be found at:
tests/dnsforwardzone/test_dnsforwardzone_client_context.yml
The new test file can be executed in a FreeIPA client host that is
not a server. In this case, it should be defined in the `ipaclients`
group, in the inventory file.
Due to differences in data returned when running ipadnsforwardzone in
a client context, some values had to be modified so that comparision
works, avoiding unnecessary IPA API calls.
This commit is contained in:
@@ -160,6 +160,19 @@ def forwarder_list(forwarders):
|
||||
return fwd_list
|
||||
|
||||
|
||||
def fix_resource_data_types(resource):
|
||||
"""Fix resource data types."""
|
||||
# When running in client context, some data might
|
||||
# not come as a list, so we need to fix it before
|
||||
# applying any modifications to it.
|
||||
forwarders = resource["idnsforwarders"]
|
||||
if isinstance(forwarders, str):
|
||||
forwarders = [forwarders]
|
||||
elif isinstance(forwarders, tuple):
|
||||
forwarders = list(forwarders)
|
||||
resource["idnsforwarders"] = forwarders
|
||||
|
||||
|
||||
def main():
|
||||
ansible_module = IPAAnsibleModule(
|
||||
argument_spec=dict(
|
||||
@@ -288,6 +301,7 @@ def main():
|
||||
continue
|
||||
|
||||
else: # existing_resource is not None
|
||||
fix_resource_data_types(existing_resource)
|
||||
if state != "absent":
|
||||
if forwarders:
|
||||
forwarders = list(
|
||||
|
||||
Reference in New Issue
Block a user