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"])