nautobot-ansible icon indicating copy to clipboard operation
nautobot-ansible copied to clipboard

Plugin Module errors after if it runs against an existing firewall policy

Open gneville-ot opened this issue 10 months ago • 0 comments

ISSUE TYPE
  • Bug Report
SOFTWARE VERSIONS
pynautobot

1.5.0

Ansible:

2.12.2

Nautobot:

1.5.0

Collection:

4.5.0

SUMMARY

When running the plugin module against an existing firewall policy that already exists the task will error.

STEPS TO REPRODUCE

Create a firewall policy and then have the plugin module run against the same policy.

Note: due to https://github.com/nautobot/nautobot-ansible/issues/245 if the firewall policy is created by the module first time it will error as explained in the linked PR. If you run it again you'll get the error reported in this issue.

- name: "SETUP FIREWALL POLICY"
  networktocode.nautobot.plugin:
    url: "{{ nb_url }}"
    token: "{{ nb_token }}"
    validate_certs: "{{ nb_validate_certs }}"
    api_version: "{{ nb_api_version }}"
    plugin: "firewall"
    endpoint: "policy"
    identifiers:
      name: "MY_POLICY"
    attrs:
      description: "My policy"
      status: "active"
      assigned_devices:
       - device: 1f51f71c-35f3-49fe-8d38-18be7bf5964b
         weight: 100
    state: "present"
EXPECTED RESULTS

The task results in no changes and is a success.

ACTUAL RESULTS

The task returns an error

      File "/usr/local/lib/python3.8/dist-packages/pynautobot/core/response.py", line 344, in serialize
        current_val = [v.id if isinstance(v, Record) else v for v in current_val]
      File "/usr/local/lib/python3.8/dist-packages/pynautobot/core/response.py", line 344, in <listcomp>
        current_val = [v.id if isinstance(v, Record) else v for v in current_val]
      File "/usr/local/lib/python3.8/dist-packages/pynautobot/core/response.py", line 190, in __getattr__
        raise AttributeError('object has no attribute "{}"'.format(k))
    AttributeError: object has no attribute "id"

gneville-ot avatar Sep 01 '23 12:09 gneville-ot