ansible-collections / dellemc.os6

GNU General Public License v3.0
8 stars 13 forks source link

SNMP configuration is not idempotent #27

Open squeeb opened 3 years ago

squeeb commented 3 years ago
SUMMARY

If an snmp community is already absent, then the play fails with the error:

TASK [dellemc.os6.os6_snmp : Provisioning SNMP configuration for os6] **********************************
fatal: [<REDACTED>]: FAILED! => {
    "changed": false,
    "command": "no snmp-server community <REDACTED>",
    "rc": -32603
}

MSG:

no snmp-server community <REDACTED>

Error:That community does not exists.

<REDACTED>(config)#
ISSUE TYPE
COMPONENT NAME

dellemc.os6.os6_snmp

ANSIBLE VERSION
ansible 2.10.5
  config file = /Volumes/Shared/squeeb/Code/ansible/ansible-oob-provisioning/ansible.cfg
  configured module search path = ['/Users/squeeb/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/squeeb/.pyenv/versions/3.9.1/lib/python3.9/site-packages/ansible
  executable location = /Users/squeeb/.pyenv/versions/3.9.1/bin/ansible
  python version = 3.9.1 (default, Feb  7 2021, 19:59:19) [Clang 12.0.0 (clang-1200.0.32.29)]
CONFIGURATION
ANSIBLE_PIPELINING(/Volumes/Shared/squeeb/Code/ansible/ansible-oob-provisioning/ansible.cfg) = True
COLLECTIONS_PATHS(/Volumes/Shared/squeeb/Code/ansible/ansible-oob-provisioning/ansible.cfg) = ['/Volumes/Shared/squeeb/Code/ansible/ansible-oob-provisioning/collections']
DEFAULT_FORKS(/Volumes/Shared/squeeb/Code/ansible/ansible-oob-provisioning/ansible.cfg) = 50
DEFAULT_HOST_LIST(/Volumes/Shared/squeeb/Code/ansible/ansible-oob-provisioning/ansible.cfg) = ['/Volumes/Shared/squeeb/Code/ansible/ansible-oob-provisioning/hosts']
DEFAULT_STDOUT_CALLBACK(/Volumes/Shared/squeeb/Code/ansible/ansible-oob-provisioning/ansible.cfg) = debug
DEFAULT_TIMEOUT(/Volumes/Shared/squeeb/Code/ansible/ansible-oob-provisioning/ansible.cfg) = 60
HOST_KEY_CHECKING(/Volumes/Shared/squeeb/Code/ansible/ansible-oob-provisioning/ansible.cfg) = False
RETRY_FILES_ENABLED(/Volumes/Shared/squeeb/Code/ansible/ansible-oob-provisioning/ansible.cfg) = False
OS / ENVIRONMENT
<REDACTED>#show version

Machine Description............... Dell Networking Switch
System Model ID................... N1548
Machine Type...................... Dell Networking N1548
Serial Number..................... CN0V143P2829889E0099A04
Manufacturer...................... 0xbc00
Burned In MAC Address............. 4CD9.8FE3.5515
System Object ID.................. 1.3.6.1.4.1.674.10895.3065
SOC Version....................... BCM56150_A0
HW Version........................ 2
CPLD Version...................... 16

unit active      backup      current-active next-active
---- ----------- ----------- -------------- --------------
1    6.3.3.14    6.3.3.14    6.3.3.14       6.3.3.14
STEPS TO REPRODUCE

Using the following playbook, the os6_snmp task fails when trying to remove an snmp community that has already been removed.

in group_vars/all.yaml:

snmp_communities:
  - name: '<REDACTED>'
    access_mode: 'ro'
    state: 'absent'
  - name: '<REDACTED>'
    access_mode: 'rw'
    state: 'absent'

in the playbook:

os6_snmp:
  snmp_community: '{{ snmp_communities }}'
EXPECTED RESULTS

task should be skipped if communities are not present

ACTUAL RESULTS
fatal: [<REDACTED>]: FAILED! => {
    "changed": false,
    "command": "no snmp-server community <REDACTED>",
    "invocation": {
        "module_args": {
            "after": null,
            "backup": false,
            "backup_options": null,
            "before": null,
            "config": null,
            "lines": null,
            "match": "line",
            "parents": null,
            "provider": null,
            "replace": "line",
            "save": false,
            "src": "\nno snmp-server community <REDACTED>\nno snmp-server community <REDACTED>\nsnmp-server contact \"<REDACTED>@<REDACTED>\"\nsnmp-server location \"<REDACTED>\"\n",
            "update": "merge"
        }
    },
    "rc": -32603
}

MSG:

no snmp-server community <REDACTED>

Error:That community does not exists.

<REDACTED>(config)#