Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent 'site' key error when using inventory caching #1297

Merged
merged 1 commit into from
Aug 28, 2024

Conversation

yaiqsa
Copy link
Contributor

@yaiqsa yaiqsa commented Aug 9, 2024

Related Issue

#833

New Behavior

Regards the Netbox Inventory plugin.
Resolves KeyError: 'site' when a caching plugin is used and prefixes: true

Contrast to Current Behavior

Currently, any time the cache is read, and there are prefixes in the cache, Ansible crashes on a missing 'site' key. This is because the site key is removed from the prefix before storing it in cache. After the fix, the site key is only deleted when it actually exists.

Discussion: Benefits and Drawbacks

Without this change it seems impossible to use an Ansible inventory caching plugin ánd enable prefixes in the Netbox inventory plugin.

Two years ago @endreszabo stated that making this change resulted in an empty prefixes: [] array for any given site for him. When I try to reproduce this I don't get that problem, and all my prefixes are listed under my sites as expected. I suspect that other changes in this project, or Ansible-core have fixed his issue.

Changes to the Documentation

Not necessary as far as I know

Proposed Release Note Entry

Prevent inventory caching error when using prefixes

Double Check

  • I have read the comments and followed the CONTRIBUTING.md.
  • I have explained my PR according to the information in the comments or in a linked issue.
  • My PR targets the devel branch.

@rodvand rodvand merged commit 21db4a9 into netbox-community:devel Aug 28, 2024
45 of 50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants