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

Add a dynamic inventory plugin for Online #44720

Merged
merged 1 commit into from
Sep 3, 2018

Conversation

remyleone
Copy link
Contributor

SUMMARY

Add a dynamic inventory plugin for online

ISSUE TYPE
  • New Module Pull Request
COMPONENT NAME
  • online dynamic inventory
ANSIBLE VERSION
ansible 2.7.0.dev0 (online_dynamic_inventory 04bf7e6a6b) last updated 2018/08/27 18:14:32 (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.7 This issue/PR affects Ansible v2.7 needs_triage Needs a first human triage before being processed. new_plugin This PR includes a new plugin. support:core This issue/PR relates to code supported by the Ansible Engineering Team. labels Aug 27, 2018
@ansibot
Copy link
Contributor

ansibot commented Aug 27, 2018

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

lib/ansible/plugins/inventory/online.py:81:1: E303 too many blank lines (3)
lib/ansible/plugins/inventory/online.py:94:1: E302 expected 2 blank lines, found 1
lib/ansible/plugins/inventory/online.py:100:1: E302 expected 2 blank lines, found 1
lib/ansible/plugins/inventory/online.py:106:1: E302 expected 2 blank lines, found 1
lib/ansible/plugins/inventory/online.py:121:1: E303 too many blank lines (3)
lib/ansible/plugins/inventory/online.py:155:5: E303 too many blank lines (2)
lib/ansible/plugins/inventory/online.py:165:5: E303 too many blank lines (3)
lib/ansible/plugins/inventory/online.py:178:5: E303 too many blank lines (2)

click here for bot help

@ansibot ansibot added ci_verified Changes made in this PR are causing tests to fail. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Aug 27, 2018
@ansibot ansibot removed ci_verified Changes made in this PR are causing tests to fail. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Aug 28, 2018
"location",
"boot_mode",
"power",
"boot_mode",
Copy link

Choose a reason for hiding this comment

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

Two times boot_mode

@remyleone remyleone force-pushed the online_dynamic_inventory branch 2 times, most recently from a4dd99e to c5e0330 Compare August 28, 2018 08:55
@remyleone
Copy link
Contributor Author

Nice to have features:

  • Group by DC
  • Group by RPN

Copy link
Contributor

@Spredzy Spredzy left a comment

Choose a reason for hiding this comment

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

Globally looks good to me. The only blocker is the line that reflects a change on #43715. I'd like us to have an agreement before pushing it.

@@ -0,0 +1,190 @@
# Copyright (c) 2017 Ansible Project
Copy link
Contributor

Choose a reason for hiding this comment

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

s/2017/2018

def _fetch_information(url, token):
headers = {
'Authorization': "Bearer %s" % token,
'Content-type': 'application/json'
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion: Adds an User-Agent header that identifies that its coming from Ansible. (I think we should do that also on the main modules). Not a blocker.

raise AnsibleError("Error while fetching %s: %s" % (url, to_native(e)))

try:
raw_data = to_text(response.read(), errors='surrogate_or_strict')
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems to be related to #43715. Can we get a final agreement on the other PR first before pushing that here?

if not hostname:
return

self.inventory.add_host(host=hostname)
Copy link
Contributor

Choose a reason for hiding this comment

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

I see there is no grouping in this inventory. Is this intentional for the first patch? Fine to me but I'd like to raise that grouping based on os_name of offer allow greater flexibility when dealing with a fleet of machine, might be interesting to add.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm working on a grouping feature that could be easily extended to geographical location and private networking subnets.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done for location and offer

@remyleone remyleone force-pushed the online_dynamic_inventory branch 6 times, most recently from 5f159fe to 14d1ded Compare August 28, 2018 15:37
@ryansb ryansb removed the needs_triage Needs a first human triage before being processed. label Aug 28, 2018
@remyleone remyleone force-pushed the online_dynamic_inventory branch 2 times, most recently from c73c511 to 71fc817 Compare August 29, 2018 09:45
@remyleone
Copy link
Contributor Author

Done for RPN

@ansibot ansibot added the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. label Aug 29, 2018
@ansibot ansibot removed the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. label Aug 29, 2018
@maxamillion
Copy link
Contributor

shipit

@remyleone
Copy link
Contributor Author

shipit

@maxamillion
Copy link
Contributor

rebuild_merge

@ansibot ansibot merged commit f465a25 into ansible:devel Sep 3, 2018
@remyleone remyleone deleted the online_dynamic_inventory branch September 3, 2018 08:02
@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.7 This issue/PR affects Ansible v2.7 new_plugin This PR includes a new plugin. support:core This issue/PR relates to code supported by the Ansible Engineering Team.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants