Prevent 'site' key error when using inventory caching #1297
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related Issue
#833
New Behavior
Regards the Netbox Inventory plugin.
Resolves
KeyError: 'site'
when a caching plugin is used andprefixes: 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
devel
branch.