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

Use constructable with NetBox dynamic inventory #45913

Merged
merged 1 commit into from
Oct 11, 2018

Conversation

remyleone
Copy link
Contributor

SUMMARY

As mention by @s-hertel in #45741 (comment)
Constructable can be used to simplify inventory.

The goal of this PR is to refactor the code of the NetBox inventory using Constructable to avoid adding new functions every time a new attribute for an host is added.

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME
  • lib/ansible/plugins/inventory/netbox.py
ANSIBLE VERSION
ansible 2.8.0.dev0 (netbox_constructable 5415677520) last updated 2018/09/20 15:10:57 (GMT +200)
  config file = None
  configured module search path = [u'/Users/sieben/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/sieben/workspace/ansible/lib/ansible
  executable location = /Users/sieben/workspace/ansible/bin/ansible
  python version = 2.7.15 (default, Jun 17 2018, 12:46:58) [GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.2)]

@ansibot ansibot added affects_2.8 This issue/PR affects Ansible v2.8 feature This issue/PR relates to a feature request. inventory Inventory category needs_triage Needs a first human triage before being processed. support:community This issue/PR relates to code supported by the Ansible community. labels Sep 20, 2018
@remyleone remyleone changed the title Use constructable with NetBox dynamic inventory WIP: Use constructable with NetBox dynamic inventory Sep 20, 2018
@ansibot ansibot added the WIP This issue/PR is a work in progress. Nevertheless it was shared for getting input from peers. label Sep 20, 2018
Copy link
Contributor

@s-hertel s-hertel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, a simple example or two would be nice too

@s-hertel s-hertel removed the needs_triage Needs a first human triage before being processed. label Sep 21, 2018
@ansibot
Copy link
Contributor

ansibot commented Sep 27, 2018

The test ansible-test sanity --test pep8 [explain] failed with 2 errors:

lib/ansible/plugins/inventory/netbox.py:88:1: W293 blank line contains whitespace
lib/ansible/plugins/inventory/netbox.py:90:37: W291 trailing whitespace

click here for bot help

@ansibot ansibot added the ci_verified Changes made in this PR are causing tests to fail. label Sep 27, 2018
@remyleone remyleone force-pushed the netbox_constructable branch 2 times, most recently from df67008 to 36763a1 Compare September 27, 2018 09:07
@ansibot ansibot removed the ci_verified Changes made in this PR are causing tests to fail. label Sep 27, 2018
@remyleone
Copy link
Contributor Author

@s-hertel I've added an example in the documentation. I've also tested and it works. Could we merge it?

@remyleone remyleone changed the title WIP: Use constructable with NetBox dynamic inventory Use constructable with NetBox dynamic inventory Sep 27, 2018
@ansibot ansibot removed the WIP This issue/PR is a work in progress. Nevertheless it was shared for getting input from peers. label Sep 27, 2018
@remyleone
Copy link
Contributor Author

@gundalow Could we merge it?

timeout:
description: Timeout for Netbox requests in seconds
type: int
default: 60
compose:
description: List of custom ansible host vars to create from the device object fetched from NetBox
default: {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need version_added here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Netbox is not present in 2.7 so I guess that all of it will be present for 2.8

@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Oct 6, 2018
@remyleone
Copy link
Contributor Author

@gundalow Could we merge it?

@ansibot ansibot removed the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Oct 8, 2018
@remyleone
Copy link
Contributor Author

@s-hertel Could we merge it?

@remyleone
Copy link
Contributor Author

@gundalow Could we merge it?

@remyleone
Copy link
Contributor Author

@Anthony25 could you review?

@aruhier
Copy link
Contributor

aruhier commented Oct 11, 2018

LGTM

@gundalow gundalow merged commit a892548 into ansible:devel Oct 11, 2018
@gundalow
Copy link
Contributor

Merged into devel for release in Ansible 2.8

Tomorrow9 pushed a commit to Tomorrow9/ansible that referenced this pull request Dec 4, 2018
@ansible ansible locked and limited conversation to collaborators Jul 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.8 This issue/PR affects Ansible v2.8 feature This issue/PR relates to a feature request. inventory Inventory category support:community This issue/PR relates to code supported by the Ansible community.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants