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

Insights Dynamic inventory script #36279

Open
wants to merge 3 commits into
base: devel
from

Conversation

Projects
None yet
4 participants
@sheeshkebab

sheeshkebab commented Feb 16, 2018

This is a dynamic inventory script for use with Ansible and Ansible Tower.
It provides ansible inventory to redhat insights users for use with insights playbooks etc.

SUMMARY

Ansible dynamic inventory script which generates json output ( inventory ) for use with playbooks.
Custom inventory is sourced from the redhat insights API using user defined credentials.

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

N/A

ANSIBLE VERSION
ansible 2.4.0.0
ADDITIONAL INFORMATION

This is a fairly basic script that calls the RedHat insights api.
I wrote it because currently there is no way to generate dynamic inventory from Ansible Tower
to uwe in conjunction with Insights generated playbooks.
It bridges the gap between Tower / Insights and downloadable playbooks.


Create insights.py
Provides a method for Ansible and Ansible tower users to consume the inventory with insights..dynamically.
@ansibot

This comment has been minimized.

Contributor

ansibot commented Feb 16, 2018

The test ansible-test sanity --test pylint [explain] failed with 1 error:

contrib/inventory/insights.py:116:0: syntax-error Missing parentheses in call to 'print'. Did you mean print(print "=" * 80)? (<string>, line 116)

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

contrib/inventory/insights.py:116:22: SyntaxError: print "=" * 80

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

contrib/inventory/insights.py:116:22: SyntaxError: print "=" * 80

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

contrib/inventory/insights.py:116:22: SyntaxError: print "=" * 80

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

contrib/inventory/insights.py:9:91: W291 trailing whitespace
contrib/inventory/insights.py:62:1: E302 expected 2 blank lines, found 1
contrib/inventory/insights.py:70:1: E302 expected 2 blank lines, found 1
contrib/inventory/insights.py:73:7: E111 indentation is not a multiple of four
contrib/inventory/insights.py:74:9: E121 continuation line under-indented for hanging indent
contrib/inventory/insights.py:75:10: E121 continuation line under-indented for hanging indent
contrib/inventory/insights.py:79:7: E111 indentation is not a multiple of four
contrib/inventory/insights.py:82:16: E131 continuation line unaligned for hanging indent
contrib/inventory/insights.py:83:17: E121 continuation line under-indented for hanging indent
contrib/inventory/insights.py:93:29: E201 whitespace after '('
contrib/inventory/insights.py:100:15: E225 missing whitespace around operator
contrib/inventory/insights.py:108:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:109:1: W293 blank line contains whitespace
contrib/inventory/insights.py:113:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:114:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:115:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:116:14: E111 indentation is not a multiple of four
contrib/inventory/insights.py:117:14: E111 indentation is not a multiple of four
contrib/inventory/insights.py:118:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:119:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:120:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:121:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:122:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:123:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:126:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:127:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:128:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:130:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:131:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:135:89: W291 trailing whitespace
contrib/inventory/insights.py:139:11: E114 indentation is not a multiple of four (comment)
contrib/inventory/insights.py:139:11: E265 block comment should start with '# '
contrib/inventory/insights.py:140:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:140:31: E203 whitespace before ','
contrib/inventory/insights.py:140:32: E231 missing whitespace after ','
contrib/inventory/insights.py:141:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:143:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:143:43: E712 comparison to True should be 'if cond is True:' or 'if cond:'

The test ansible-test sanity --test replace-urlopen [explain] failed with the error:

Command "test/sanity/code-smell/replace-urlopen.sh" returned exit status 1.
>>> Standard Output
./contrib/inventory/insights.py:          requestresult = urllib2.urlopen(request)
One or more file(s) listed above use urlopen.
Use open_url from module_utils instead of urlopen.

click here for bot help

@sheeshkebab sheeshkebab changed the title from Create insights.py to Insights Dynamic inventory script Feb 16, 2018

@ansibot

This comment has been minimized.

Contributor

ansibot commented Feb 16, 2018

The test ansible-test sanity --test pylint [explain] failed with 1 error:

contrib/inventory/insights.py:118:0: syntax-error invalid syntax (<string>, line 118)

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

contrib/inventory/insights.py:118:23: SyntaxError: print "%s" % ('=') * 80

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

contrib/inventory/insights.py:118:23: SyntaxError: print "%s" % ('=') * 80

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

contrib/inventory/insights.py:118:23: SyntaxError: print "%s" % ('=') * 80

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

contrib/inventory/insights.py:9:91: W291 trailing whitespace
contrib/inventory/insights.py:75:7: E111 indentation is not a multiple of four
contrib/inventory/insights.py:76:9: E121 continuation line under-indented for hanging indent
contrib/inventory/insights.py:77:10: E121 continuation line under-indented for hanging indent
contrib/inventory/insights.py:81:7: E111 indentation is not a multiple of four
contrib/inventory/insights.py:84:16: E131 continuation line unaligned for hanging indent
contrib/inventory/insights.py:85:17: E121 continuation line under-indented for hanging indent
contrib/inventory/insights.py:95:29: E201 whitespace after '('
contrib/inventory/insights.py:102:15: E225 missing whitespace around operator
contrib/inventory/insights.py:110:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:111:1: W293 blank line contains whitespace
contrib/inventory/insights.py:115:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:116:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:117:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:118:14: E111 indentation is not a multiple of four
contrib/inventory/insights.py:119:14: E111 indentation is not a multiple of four
contrib/inventory/insights.py:120:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:121:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:122:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:123:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:124:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:125:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:128:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:129:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:130:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:132:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:133:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:137:89: W291 trailing whitespace
contrib/inventory/insights.py:141:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:141:31: E231 missing whitespace after ','
contrib/inventory/insights.py:142:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:144:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:144:43: E712 comparison to True should be 'if cond is True:' or 'if cond:'

The test ansible-test sanity --test replace-urlopen [explain] failed with the error:

Command "test/sanity/code-smell/replace-urlopen.sh" returned exit status 1.
>>> Standard Output
./contrib/inventory/insights.py:          requestresult = urllib2.urlopen(request)
One or more file(s) listed above use urlopen.
Use open_url from module_utils instead of urlopen.

click here for bot help

@mkrizek mkrizek removed the needs_triage label Feb 16, 2018

@ansibot ansibot added the stale_ci label Feb 24, 2018

@ansibot

This comment has been minimized.

Contributor

ansibot commented Feb 27, 2018

The test ansible-test sanity --test pylint [explain] failed with 1 error:

contrib/inventory/insights.py:119:0: syntax-error invalid syntax (<string>, line 119)

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

contrib/inventory/insights.py:119:23: SyntaxError: print "%s" % ('=') * 80

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

contrib/inventory/insights.py:119:23: SyntaxError: print "%s" % ('=') * 80

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

contrib/inventory/insights.py:119:23: SyntaxError: print "%s" % ('=') * 80

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

contrib/inventory/insights.py:9:91: W291 trailing whitespace
contrib/inventory/insights.py:75:7: E111 indentation is not a multiple of four
contrib/inventory/insights.py:76:9: E121 continuation line under-indented for hanging indent
contrib/inventory/insights.py:77:10: E121 continuation line under-indented for hanging indent
contrib/inventory/insights.py:81:7: E111 indentation is not a multiple of four
contrib/inventory/insights.py:84:16: E131 continuation line unaligned for hanging indent
contrib/inventory/insights.py:85:17: E121 continuation line under-indented for hanging indent
contrib/inventory/insights.py:95:29: E201 whitespace after '('
contrib/inventory/insights.py:102:15: E225 missing whitespace around operator
contrib/inventory/insights.py:111:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:112:1: W293 blank line contains whitespace
contrib/inventory/insights.py:116:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:117:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:118:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:119:14: E111 indentation is not a multiple of four
contrib/inventory/insights.py:120:14: E111 indentation is not a multiple of four
contrib/inventory/insights.py:121:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:122:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:123:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:124:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:125:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:126:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:129:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:130:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:131:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:133:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:134:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:138:89: W291 trailing whitespace
contrib/inventory/insights.py:142:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:142:31: E231 missing whitespace after ','
contrib/inventory/insights.py:143:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:145:11: E111 indentation is not a multiple of four
contrib/inventory/insights.py:145:43: E712 comparison to True should be 'if cond is True:' or 'if cond:'

The test ansible-test sanity --test replace-urlopen [explain] failed with 1 error:

contrib/inventory/insights.py:124:35: use `ansible.module_utils.urls.open_url` instead of `urlopen`

The test ansible-test sanity --test use-compat-six [explain] failed with 1 error:

contrib/inventory/insights.py:60:1: use `ansible.module_utils.six` instead of `six`

click here for bot help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment