From 854b356e77f50668d2cb9bfea822e50f360f0f33 Mon Sep 17 00:00:00 2001 From: lenseB <118888708+lenseB@users.noreply.github.com> Date: Wed, 29 Nov 2023 11:19:14 +0100 Subject: [PATCH 1/5] Create two_hostrecords_same_name.yml Added changelog fragment (description in https://docs.ansible.com/ansible/latest/community/development_process.html#community-changelogs) --- two_hostrecords_same_name.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 two_hostrecords_same_name.yml diff --git a/two_hostrecords_same_name.yml b/two_hostrecords_same_name.yml new file mode 100644 index 00000000..79bcba73 --- /dev/null +++ b/two_hostrecords_same_name.yml @@ -0,0 +1,2 @@ +bugfixes: + - nios_host_record - "if len(ib_obj_ref) > 1" in module_utils/api.py results in weird behaviour. Adding "or (len(ib_obj_ref) >= 1 and ib_obj_type == NIOS_HOST_RECORD)" to the if-statement results in the wanted behaviour. From 489501d9c44cfa01e938e0925a94b1ade6f3a41c Mon Sep 17 00:00:00 2001 From: lenseB <118888708+lenseB@users.noreply.github.com> Date: Wed, 29 Nov 2023 11:29:12 +0100 Subject: [PATCH 2/5] Create two_hostrecords_same_hostname.yml Added changelog fragmet (method described in https://docs.ansible.com/ansible/latest/community/development_process.html#changelogs-how-to) --- changelogs/fragments/two_hostrecords_same_hostname.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 changelogs/fragments/two_hostrecords_same_hostname.yml diff --git a/changelogs/fragments/two_hostrecords_same_hostname.yml b/changelogs/fragments/two_hostrecords_same_hostname.yml new file mode 100644 index 00000000..86612607 --- /dev/null +++ b/changelogs/fragments/two_hostrecords_same_hostname.yml @@ -0,0 +1,2 @@ +- bugfixes: + - nios_host_record - "if len(ib_obj_ref) > 1" in module_utils/api.py results in weird behaviour. Adding "or (len(ib_obj_ref) >= 1 and ib_obj_type == NIOS_HOST_RECORD)" to the if-statement results in the wanted behaviour. From fe8b19ece51496cff5b52b134123f81b59d4ff75 Mon Sep 17 00:00:00 2001 From: lenseB <118888708+lenseB@users.noreply.github.com> Date: Wed, 29 Nov 2023 11:30:25 +0100 Subject: [PATCH 3/5] Delete two_hostrecords_same_name.yml --- two_hostrecords_same_name.yml | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 two_hostrecords_same_name.yml diff --git a/two_hostrecords_same_name.yml b/two_hostrecords_same_name.yml deleted file mode 100644 index 79bcba73..00000000 --- a/two_hostrecords_same_name.yml +++ /dev/null @@ -1,2 +0,0 @@ -bugfixes: - - nios_host_record - "if len(ib_obj_ref) > 1" in module_utils/api.py results in weird behaviour. Adding "or (len(ib_obj_ref) >= 1 and ib_obj_type == NIOS_HOST_RECORD)" to the if-statement results in the wanted behaviour. From 4dc16e36a8c9a2f5ef195bef56e6251632ef90d8 Mon Sep 17 00:00:00 2001 From: lenseB <118888708+lenseB@users.noreply.github.com> Date: Wed, 29 Nov 2023 11:31:07 +0100 Subject: [PATCH 4/5] Update two_hostrecords_same_hostname.yml accidental "-" --- changelogs/fragments/two_hostrecords_same_hostname.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/fragments/two_hostrecords_same_hostname.yml b/changelogs/fragments/two_hostrecords_same_hostname.yml index 86612607..79bcba73 100644 --- a/changelogs/fragments/two_hostrecords_same_hostname.yml +++ b/changelogs/fragments/two_hostrecords_same_hostname.yml @@ -1,2 +1,2 @@ -- bugfixes: +bugfixes: - nios_host_record - "if len(ib_obj_ref) > 1" in module_utils/api.py results in weird behaviour. Adding "or (len(ib_obj_ref) >= 1 and ib_obj_type == NIOS_HOST_RECORD)" to the if-statement results in the wanted behaviour. From 58cb936c8e76bd71280af3e5c70f55ca31ddd6fe Mon Sep 17 00:00:00 2001 From: lenseB <118888708+lenseB@users.noreply.github.com> Date: Wed, 29 Nov 2023 11:40:09 +0100 Subject: [PATCH 5/5] Update api.py for the case of using the "nios_host_record"-module: - when there is one hostrecord with the same name already, it should behave like there are already >=2 hostrecords. - therefore the if-statement needs to be adjusted thatthe else-statement in line 343 is not executed --- plugins/module_utils/api.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/module_utils/api.py b/plugins/module_utils/api.py index 51c51257..449402df 100644 --- a/plugins/module_utils/api.py +++ b/plugins/module_utils/api.py @@ -326,7 +326,7 @@ def run(self, ib_obj_type, ib_spec): del proposed_object['view'] if ib_obj_ref: - if len(ib_obj_ref) > 1: + if len(ib_obj_ref) > 1 or (len(ib_obj_ref) >= 1 and ib_obj_type == NIOS_HOST_RECORD): for each in ib_obj_ref: # To check for existing A_record with same name with input A_record by IP if each.get('ipv4addr') and each.get('ipv4addr') == proposed_object.get('ipv4addr'):