Skip to content

[Bug]: snmptrap module can't process duplicate entries of snmp traps #461

@petetong1989

Description

@petetong1989

Summary

When snmptrap module runs and try collecting the existing resources but failed into Found more than one resource with the same primary key which I don't think the primary key for snmptrap was set properly.
I reviewed our netscaler snmp trap configuration, and it is allowed to add multiple entires of snmp trap but the primary key isn't just trapdestination.

Issue Type

Bug Report

Component Name

snmptraps

Python Version

Python 3.10.14

Ansible Version

ansible [core 2.14.15]
  config file = /Users/pzhang/vscode/Project/network_ansible/ansible.cfg
  configured module search path = ['/Users/pzhang/vscode/Project/network_ansible/library/custom_modules/plugins/modules', '/Users/pzhang/vscode/Project/network_ansible/site-packages/citrix_sdx_ansible/modules']
  ansible python module location = /Users/pzhang/miniconda3/envs/network_ansible/lib/python3.10/site-packages/ansible
  ansible collection location = /Users/pzhang/vscode/Project/network_ansible/site-packages
  executable location = /Users/pzhang/miniconda3/envs/network_ansible/bin/ansible
  python version = 3.10.14 (main, Mar 21 2024, 11:24:58) [Clang 14.0.6 ] (/Users/pzhang/miniconda3/envs/network_ansible/bin/python)
  jinja version = 3.0.0
  libyaml = True

Ansible Configuration

$ ansible-config dump --only-changed

netscaler.adc Collection Version

# /Users/pzhang/vscode/Project/network_ansible/site-packages/ansible_collections
Collection    Version
------------- -------
netscaler.adc 2.6.1

Target NetScaler Version

> show ns version

Equivalent NetScaler CLI Command

Steps to Reproduce

- name: "Set SNMP Traps"
  delegate_to: localhost
  netscaler.adc.snmptrap:
    nsip: "{{ (deployment == 'cluster') | ternary(clip, mgmt_ip) }}"
    state: "{{ item.state | default('present') }}"
    validate_certs: false
    nitro_user: "{{ ansible_user }}"
    nitro_pass: "{{ ansible_ssh_pass }}"
    communityname: "{{ item.communityname }}"
    trapclass: "{{ item.trapclass }}"
    trapdestination: "{{ item.trapdestination }}"
  when: primary_configurable_node
  loop: "{{ snmp_traps }}"
  loop_control:
    label: "{{ 'snmp-trap/' ~ item.trapdestination }}"
  tags:
    - snmpSetting
    - clusterNodeSetting
    - haNodeSetting

Expected Results

I expected snmptrap would be smarter not just using trapdestination as the primary key.

Actual Results

Additional Notes

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions