-
Notifications
You must be signed in to change notification settings - Fork 234
Inventory: Remove unnecessary lists around singular host vars #141 #155
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
Inventory: Remove unnecessary lists around singular host vars #141 #155
Conversation
9392cf4
to
432cf82
Compare
This is still a work in progress, not actually ready to merge. Need to do a lot more testing. |
73581bf
to
f7d2db2
Compare
3619d15
to
c1a6ff7
Compare
This is getting closer. Currently working on #56 adding integration tests as part of this to ensure the work on the I've found the Got caught for a little bit on ansible/ansible#68963 |
b7d1015
to
f8090f7
Compare
f88a08a
to
31f2f3b
Compare
Until netbox-community/netbox#4496 is released
2435a51
to
a26d5b0
Compare
…ta (netbox-community#56) Also: * Update .gitignore and galaxy.yml build_ignore with various development files to ignore. * Added .editorconfig with indentation settings for .py and .yml files
d17e8c9
to
5536ebf
Compare
…on-default options Includes testing the Constructed inherited options. Also added the same inventory from the past v0.2.0 release. I compared its output to the output of the actualy v0.2.0 release and can confirm nothing has changed - only added new host_vars (config_context, regions) since then, and changed the test data slightly. (ie. there should be no breaking change for existing users of this collection)
5536ebf
to
a6825ce
Compare
Ok, @FragmentedPacket this is finally ready for a proper review. Here's a summary of what this pull request includes:
More details:
|
@DouglasHeriot I will try and get to this during the weekend. Work has been kicking my butt so haven't had the mental capacity to walk through the PR. Thanks for all your effort! |
plugins/inventory/nb_inventory.py
Outdated
- If True, all host vars are contained inside single-element arrays for legacy compatibility. Group names will be plural (ie. "sites_mysite" instead of "site_mysite") | ||
default: True | ||
type: boolean | ||
version_added: "0.1.11" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update version to 0.2.1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
# Keep looping until the region has no parent | ||
while region_id is not None: | ||
region_slug = self.regions_lookup[region_id] | ||
if region_slug in regions: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested this and appears it doesn't get stuck in a loop, but maybe my test data isn't correct for L710-L712
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No this will never get stuck in a loop – wasn't sure how defensively I should be programming against the Netbox API. It would only be in theory if Netbox had a corrupt database that somehow had a loop in it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok no problem. I don't feel strongly on either having it or not so we can leave it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've left this in but updated the comment to be more clear.
.travis.yml
Outdated
- ansible-test sanity -v --requirements --python $PYTHON_VER --skip-test pep8 --skip-test validate-modules | ||
|
||
# Unit tests, with code coverage | ||
- ansible-test units -vvvv --coverage --python $PYTHON_VER |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After looking at the tests, what is the least amount of verbosity can we get away with these commands? The test output is pretty heavy with setup information for all this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah it's very verbose. I wasn't sure whether to go for enough information to debug any issues, or just enough to read and see where it failed. These could probably all be changed to just -v
or -vv
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that is definitely something to consider. I'll leave that decision up to you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed it to -v
. Should be enough for most cases.
* Mostly updated comments to be clearer. * Changed argument name * Reduced verbosity of travis tests
Netbox 2.8.1 release fixed netbox-community/netbox#4496
@DouglasHeriot Thanks a lot for this. I can't tell you how much I appreciate your work on this. Great work and the quality is superb. |
@FragmentedPacket thanks for being prompt and easy to work with! |
Implements #141
There's a new
plurals
option on the inventory. It isTrue
by default to maintain backwards compatibility. When set toFalse
, thegroup_by
options andhost_vars
all change names to become singular, and unnecessary lists around singular vars are removed.Once #153 is merged to start on #56 inventory unit tests, I'll add some unit tests for
plurals
too.