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 support for Tower Smart inventories #41458

Merged
merged 5 commits into from
Jun 13, 2018
Merged

Conversation

jaevans
Copy link
Contributor

@jaevans jaevans commented Jun 12, 2018

SUMMARY

Add support for tower_inventory with kind smart. Fixes #41456

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

tower_inventory

ANSIBLE VERSION
ansible 2.5.4
  config file = None
  configured module search path = [u'/Users/evanjame/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/Cellar/ansible/2.5.4/libexec/lib/python2.7/site-packages/ansible
  executable location = /usr/local/bin/ansible
  python version = 2.7.15 (default, May  1 2018, 16:44:37) [GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)]
ADDITIONAL INFORMATION

This simply adds support for the kind and host_filter parameters, which are passed to the tower_cli module.


James Evans added 2 commits June 12, 2018 12:52
Add kind and host_filter fields and pass through to tower_cli.
@ansibot
Copy link
Contributor

ansibot commented Jun 12, 2018

@ansibot ansibot added affects_2.7 This issue/PR affects Ansible v2.7 bug This issue/PR relates to a bug. community_review In order to be merged, this PR must follow the community review workflow. module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. new_contributor This PR is the first contribution by a new community member. support:community This issue/PR relates to code supported by the Ansible community. labels Jun 12, 2018
@ansibot
Copy link
Contributor

ansibot commented Jun 12, 2018

The test ansible-test sanity --test ansible-doc --python 2.6 [explain] failed with 1 error:

lib/ansible/modules/web_infrastructure/ansible_tower/tower_inventory.py:0:0: missing documentation (or could not parse documentation): pop() takes at most 1 argument (2 given)

The test ansible-test sanity --test ansible-doc --python 2.7 [explain] failed with 1 error:

lib/ansible/modules/web_infrastructure/ansible_tower/tower_inventory.py:0:0: missing documentation (or could not parse documentation): pop() takes at most 1 argument (2 given)

The test ansible-test sanity --test ansible-doc --python 3.5 [explain] failed with 1 error:

lib/ansible/modules/web_infrastructure/ansible_tower/tower_inventory.py:0:0: missing documentation (or could not parse documentation): pop() takes at most 1 argument (2 given)

The test ansible-test sanity --test ansible-doc --python 3.6 [explain] failed with 1 error:

lib/ansible/modules/web_infrastructure/ansible_tower/tower_inventory.py:0:0: missing documentation (or could not parse documentation): pop() takes at most 1 argument (2 given)

The test ansible-test sanity --test ansible-doc --python 3.7 [explain] failed with 1 error:

lib/ansible/modules/web_infrastructure/ansible_tower/tower_inventory.py:0:0: missing documentation (or could not parse documentation): pop() takes at most 1 argument (2 given)

The test ansible-test sanity --test docs-build [explain] failed with the error:

Command "/usr/bin/python test/sanity/code-smell/docs-build.py" returned exit status 1.
>>> Standard Error
Traceback (most recent call last):
  File "test/sanity/code-smell/docs-build.py", line 101, in <module>
    main()
  File "test/sanity/code-smell/docs-build.py", line 17, in main
    raise subprocess.CalledProcessError(sphinx.returncode, cmd, output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['make', 'singlehtmldocs']' returned non-zero exit status 2.

click here for bot help

@ansibot ansibot added needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed community_review In order to be merged, this PR must follow the community review workflow. labels Jun 12, 2018
@@ -102,7 +113,8 @@ def main():

if state == 'present':
result = inventory.modify(name=name, organization=org['id'], variables=variables,
description=description, create_on_missing=True)
description=description, kind=kind, host_filter=host_filter,
Copy link
Member

Choose a reason for hiding this comment

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

@ryanpetrello do you think there may be any problems with past versions by passing kind & host_filter? I would say probably not, as long as the tower-cli version was up-to-date, it may send an extra field, but that would be ignored by the API.

Copy link
Contributor

Choose a reason for hiding this comment

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

I just tested a Tower 3.1.x install to be sure, and it seems fine to me:

curl -sk "https://admin:pass@some-tower-3.1.6.amazonaws.com/api/v2/inventories/?kind=smart&host_filter=foo" | python -m json.tool
{
    "count": 0,
    "next": null,
    "previous": null,
    "results": []
}

@ansibot ansibot removed the needs_triage Needs a first human triage before being processed. label Jun 13, 2018
@@ -37,6 +37,13 @@
variables:
description:
- Inventory variables. Use C(@) to get from file.
kind:
Copy link
Contributor

Choose a reason for hiding this comment

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

These need version_added: "2.6" values.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added, thank you!

@ansibot ansibot added community_review In order to be merged, this PR must follow the community review workflow. and removed needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Jun 13, 2018
@AlanCoding
Copy link
Member

shipit

1 similar comment
@ryanpetrello
Copy link
Contributor

shipit

@ansibot ansibot added automerge This PR was automatically merged by ansibot. shipit This PR is ready to be merged by Core and removed community_review In order to be merged, this PR must follow the community review workflow. labels Jun 13, 2018
@ansibot ansibot merged commit 75443b2 into ansible:devel Jun 13, 2018
@jaevans jaevans deleted the smart-inventories branch June 14, 2018 03:37
jacum pushed a commit to jacum/ansible that referenced this pull request Jun 26, 2018
* Support Smart Inventories

Add kind and host_filter fields and pass through to tower_cli.

* Add documentation for new Smart Inventories options

* Add missing description header for host_filter documentation

* Add version added tags to new options

* Bumped vesion_added to 2.7
@gundalow
Copy link
Contributor

Hi,
I'm randomly selecting some PRs to see how it was for you, with the aim of making it easier for future contributors. As a new contributor I'm particularly interested as you don't have any prior knowledge of the Ansible process.

  1. Generally speaking, how was the process for you?
  2. Did it make sense what to do to progress the PR?
  3. Did you read any of the developer (dev_guide) or contributor documentation?
  4. What in the documentation was useful or confusing, missing or could be improved
  5. Did you know you could run ansible-test locally?
  6. What areas would you be interested in contributing to?

ansible/community#353

@gundalow gundalow added the contrib_follow_up https://github.com/ansible/community/issues/353 label Oct 27, 2018
@matburt
Copy link
Member

matburt commented Oct 28, 2018

@gundalow I think we've got a good handle on things ;)

@jaevans
Copy link
Contributor Author

jaevans commented Oct 31, 2018

  1. Relatively painless. This was a small change that didn't touch any other subsystems, so it was very self contained. The biggest problem I had was understanding the documentation on documenting options. This led to a cryptic error from the CI system. I had to read the validate-module code to understand why it was failing. (see item 5 below)
  2. Once I figured out my issue with the document fragment, yes.
  3. Yes, I read everything I could find before I started. The change had been running internally for a while before we tried to contribute back.
  4. I believe that most of the areas I had issues with have already been cleaned up. I wasn't able to find the documentation on option documentation until after I had corrected the issue.
  5. Not until I reverse engineered the CI setup! 😄
  6. As our company expands use of Ansible, I will be working to fix bugs and add (small) features that we need.

@gundalow
Copy link
Contributor

gundalow commented Nov 1, 2018

@jaevans thank you very much for taking the time to provide this feedback, it truly is useful.

The CI errors for module documentation is a not something I'd considered before.

Do you think a troubleshooting section on https://docs.ansible.com/ansible/devel/dev_guide/developing_modules_documenting.html could help, ie list some of the common errors, detail how to fix them.

@dagwieers dagwieers added the tower Tower community label Feb 8, 2019
@ansible ansible locked and limited conversation to collaborators Jun 13, 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 automerge This PR was automatically merged by ansibot. bug This issue/PR relates to a bug. contrib_follow_up https://github.com/ansible/community/issues/353 module This issue/PR relates to a module. new_contributor This PR is the first contribution by a new community member. shipit This PR is ready to be merged by Core support:community This issue/PR relates to code supported by the Ansible community. tower Tower community
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tower_inventory module cannot create smart inventories
7 participants