ansible-collections/cisco.nxos

nxos_snmp_server is rendering snmp-server host configuration incorrectly

ledgley opened this issue · 2 comments

SUMMARY

nxos_snmp_server is rendering snmp-server host configuration incorrectly

ISSUE TYPE
  • Bug Report
COMPONENT NAME

cisco.nxos.nxos_snmp_server

ANSIBLE VERSION
ansible 2.10.17
  config file = /Users/edgleyl/.ansible.cfg
  configured module search path = ['/Users/edgleyl/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/edgleyl/venv/brew-ten/lib/python3.9/site-packages/ansible
  executable location = /Users/edgleyl/venv/brew-ten/bin/ansible
  python version = 3.9.12 (main, Mar 26 2022, 15:51:15) [Clang 13.1.6 (clang-1316.0.21.2)]
COLLECTION VERSION
(brew-ten) edgleyl@edgleyl-JSS1242 compliance % ansible-galaxy collection list | grep nxos
cisco.nxos             2.8.1
CONFIGURATION
(brew-ten) edgleyl@edgleyl-JSS1242 compliance % ansible-config dump --only-changed
DEFAULT_CALLBACK_WHITELIST(/Users/edgleyl/.ansible.cfg) = ['timer']
DEFAULT_STDOUT_CALLBACK(/Users/edgleyl/.ansible.cfg) = yaml
HOST_KEY_CHECKING(/Users/edgleyl/.ansible.cfg) = False
INTERPRETER_PYTHON(/Users/edgleyl/.ansible.cfg) = /Users/edgleyl/venv/brew-ten/bin/python
PERSISTENT_COMMAND_TIMEOUT(/Users/edgleyl/.ansible.cfg) = 180
OS / ENVIRONMENT

NXOS 7.0(3)I7(3)

STEPS TO REPRODUCE

This is the data

snmp:
  hosts:
    - community: public
      host: 10.52.5.52
      traps: true
      use_vrf: management
      version: 2c
    - community: public
      host: 10.54.199.25
      traps: true
      use_vrf: management
      version: 2c

This is the task

- name: RENDER SNMP CONFIGURATION
  cisco.nxos.nxos_snmp_server:
    state: rendered
    config: "{{ iscc.snmp }}"
  register: rendered_snmp_config
EXPECTED RESULTS

Expect config to be rendered like this

snmp-server host 10.52.5.52 traps version 2c public
snmp-server host 10.52.5.52 use-vrf management
snmp-server host 10.54.199.25 traps version 2c public
snmp-server host 10.54.199.25 use-vrf management
ACTUAL RESULTS

This is the resulting rendered config

snmp-server host 10.52.5.52 traps use-vrf management version 2c public
snmp-server host 10.54.199.25 traps use-vrf management version 2c public

@ledgley Please have a look at the description for hosts key in the documentation. Lines that appear separately in the running-config would have to be added as separate dictionaries. This had to be done to ensure that idempotence is preserved.

As such, your hosts key should look like:

snmp:
  hosts:
    - community: public
      host: 10.52.5.52
      traps: true
      version: 2c

    - host: 10.52.5.52
      use_vrf: management

    - community: public
      host: 10.54.199.25
      traps: true
      version: 2c

    - host: 10.54.199.25
      use_vrf: management

Please let me know if this solves your issue. Thanks!

Yes it does, thank you! Closing this.