netbox-community / ansible_modules

NetBox modules for Ansible using Ansible Collections
GNU General Public License v3.0
330 stars 213 forks source link

[Bug]: netbox_prefix should ignore vlan parameter if state==absent #836

Open jsalatiel opened 2 years ago

jsalatiel commented 2 years ago

Ansible NetBox Collection version

v3.8.0

Ansible version

2.11.7

NetBox version

3.2.5

Python version

3.8

Steps to Reproduce

Create a prefix using the following data:

    data:
      prefix: 192.168.0.0/24
      description: description
      vlan:
        name: 'test vlan'
    state: 'present

Now manually delete the prefix and vlan on the webui and re-run the playbook using absent instead of present and the playbook will fail. The module should not try to parse the VLAN if the requested prefix state is absent.

Expected Behavior

The playbook should not fail

Observed Behavior

The playbook fails if the vlan does not exist even if the required state for the prefix is absent

sc68cal commented 2 years ago

Can you provide the output from when it failed please?

jsalatiel commented 2 years ago

Sure.

"msg": "Could not resolve id of vlan: {'name': 'some-manually-deleted-vlan-here'}"}

IMHO it should no try to resolve the vlan id if the state: absent

sc68cal commented 2 years ago

Sorry, I should have been more clear. If you can provide the stack trace, along with the error, that would help us hunt down where the check needs to happen. You can get this by running ansible-playbook and using the -vvv argument.