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
Onesixtyone inventory plugin (Fixes #41443) #53036
Conversation
The test
The test
The test
The test
The test
The test
The test
The test
The test
|
The test
The test
The test
The test
The test
The test
The test
The test
The test
|
The test
The test
The test
The test
The test
The test
The test
The test
|
The test
The test
The test
The test
The test
The test
The test
|
The test
The test
The test
The test
The test
The test
The test
|
d90201d
to
3d577f0
Compare
The test
The test
The test
The test
The test
The test
The test
|
- organize errors/exceptions - add trailing ',' - remove '^' from regex
bacb574
to
80b8e51
Compare
DOCUMENTATION = ''' | ||
name: onesixtyone | ||
plugin_type: inventory | ||
version_added: "2.8" |
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.
version_added: "2.8" | |
version_added: "2.9" |
try: | ||
from netaddr import IPSet | ||
HAS_NETADDR = True | ||
except Exception: |
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.
ImportError?
NAME = 'onesixtyone' | ||
|
||
def __init__(self): | ||
super(InventoryModule, self).__init__() |
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.
Empty proxy-init doesn't make sense and should be removed.
# Find the onesixtyone binary | ||
try: | ||
self._onesixtyone = get_bin_path(self.NAME, True) | ||
except Exception: |
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.
Please, use actual exception which may happen. Wholesale catch-all is bad.
} | ||
platforms.update(self.get_option('platform')) | ||
|
||
for platform, rule in platforms.items(): |
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.
for platform, rule in platforms.items(): | |
return next(platform for platform, rule in platforms.items() if rule.match(text), 'unknown') |
communities_tempfile.flush() | ||
|
||
# add command-line option -c | ||
cmd.append('-c') |
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.
It'd be probably better readable with
cmd.append('-c') | |
cmd.extend(('-c', communities_tempfile.name)) |
instead
|
||
# execute | ||
try: | ||
self.display.vvv("running command: {cmd}".format(cmd=cmd_string)) |
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.
This should go outside of try block
matches = None | ||
|
||
for line in cmd_output.splitlines(): | ||
self.display.vvv("parsing output line: {line}".format(line=line)) |
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.
this should probably go to the debug level
if host.endswith('.in-addr.arpa'): | ||
obj.display.vvv("Reverse DNS for host {host} contains 'in-addr.arpa', using {ansible_host}`".format(host=host, ansible_host=ansible_host)) | ||
host = ansible_host | ||
except Exception: |
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 wholesale exceptions plz
Hi @victorock, Thank you very much for your interest in Ansible. This plugin/module is no longer maintained in this repository and has been migrated to https://github.com/ansible-collections/community.general |
SUMMARY
Add inventory plugin for onesixtyone, which is lightweight and fast in discovery of devices running SNMP.
Fixes #41443
ISSUE TYPE
COMPONENT NAME
onesixtyone
ADDITIONAL INFORMATION