From 197847338601732ce80d7c0c840536e5fca667aa Mon Sep 17 00:00:00 2001 From: ONODERA Masaru <46081939+masa-orca@users.noreply.github.com> Date: Sun, 4 Aug 2024 01:29:58 +0900 Subject: [PATCH] Delete denied parameters from host interfaces (#1356) --- ...6-zabbix_host-delete-denied-parameters.yml | 2 ++ plugins/modules/zabbix_host.py | 21 ++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/1356-zabbix_host-delete-denied-parameters.yml diff --git a/changelogs/fragments/1356-zabbix_host-delete-denied-parameters.yml b/changelogs/fragments/1356-zabbix_host-delete-denied-parameters.yml new file mode 100644 index 000000000..8b804925d --- /dev/null +++ b/changelogs/fragments/1356-zabbix_host-delete-denied-parameters.yml @@ -0,0 +1,2 @@ +bugfixes: + - zabbix_host - delete denied parameter from interfaces diff --git a/plugins/modules/zabbix_host.py b/plugins/modules/zabbix_host.py index bdf010aba..b423d4260 100644 --- a/plugins/modules/zabbix_host.py +++ b/plugins/modules/zabbix_host.py @@ -966,9 +966,28 @@ def update_exist_interfaces_with_defaults(exist_interfaces): "privprotocol": 0, "privpassphrase": "" } + allowed_fields = [ + 'hostid', + 'type', + 'ip', + 'dns', + 'port', + 'useip', + 'main', + 'details', + 'interface_ref', + 'items', + 'interfaceid' + ] for interface in exist_interfaces: + normalized_interface = interface + denied_fields = list(set(interface.keys()) - set(allowed_fields)) + normalized_interface = zabbix_utils.helper_normalize_data( + interface, del_keys=denied_fields + )[0] + new_interface = default_interface.copy() - new_interface.update(interface) + new_interface.update(normalized_interface) new_interface["details"] = default_interface_details.copy() if "details" in interface: new_interface["details"].update(interface["details"])