From b1623bc3a342a769df00782e4ffe3fdb663f678b Mon Sep 17 00:00:00 2001 From: dlehrman Date: Thu, 22 Aug 2024 01:40:27 -0400 Subject: [PATCH] Exclude DNS View from filter criteria when configure_for_dns is false (#229) * Exclude DNS View from filter criteria when configure_for_dns is false This logic was already applied to scenarios that were not updating a name (lines 715-719). This commit simply applies the same logic to scenarios where names are being updated. Signed-off-by: David Ehrman * Add changelog fragment Signed-off-by: David Ehrman --------- Signed-off-by: David Ehrman --- changelogs/fragments/229-handle-host-rename-without-dns.yml | 4 ++++ plugins/module_utils/api.py | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/229-handle-host-rename-without-dns.yml diff --git a/changelogs/fragments/229-handle-host-rename-without-dns.yml b/changelogs/fragments/229-handle-host-rename-without-dns.yml new file mode 100644 index 00000000..bf540a20 --- /dev/null +++ b/changelogs/fragments/229-handle-host-rename-without-dns.yml @@ -0,0 +1,4 @@ +--- +bugfixes: + - nios_host_record - rename logic included DNS view in filter critera, even when DNS had been bypassed. Omits DNS view from filter critera when renaming a host object and DNS is bypassed. (https://github.com/infobloxopen/infoblox-ansible/issues/230) +... diff --git a/plugins/module_utils/api.py b/plugins/module_utils/api.py index 51d47d33..9e8ff037 100644 --- a/plugins/module_utils/api.py +++ b/plugins/module_utils/api.py @@ -695,7 +695,11 @@ def get_object_ref(self, module, ib_obj_type, obj_filter, ib_spec): if old_name and new_name: if (ib_obj_type == NIOS_HOST_RECORD): - test_obj_filter = dict([('name', old_name), ('view', obj_filter['view'])]) + # to check only by old_name if dns bypassing is set + if not obj_filter['configure_for_dns']: + test_obj_filter = dict([('name', old_name)]) + else: + test_obj_filter = dict([('name', old_name), ('view', obj_filter['view'])]) # if there are multiple records with same name and different ip elif (ib_obj_type == NIOS_A_RECORD): test_obj_filter = dict([('name', old_name), ('ipv4addr', obj_filter['ipv4addr'])])