Created
January 23, 2018 20:31
-
-
Save privateip/2ab7bfc7b93eafe004d17bf21edc1f51 to your computer and use it in GitHub Desktop.
example netconf with native connection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
# (c) 2018, Red Hat, Inc. | |
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) | |
from __future__ import absolute_import, division, print_function | |
__metaclass__ = type | |
ANSIBLE_METADATA = {'metadata_version': '1.1', | |
'status': ['preview'], | |
'supported_by': 'community'} | |
DOCUMENTATION = ''' | |
''' | |
EXAMPLES = ''' | |
''' | |
RETURN = ''' | |
''' | |
from ansible.module_utils.basic import AnsibleModule | |
from ansible.module_utils.connection import Connection | |
from ansible.module_utils._text import to_text | |
def main(): | |
argument_spec = dict() | |
module = AnsibleModule(argument_spec=argument_spec, | |
supports_check_mode=True) | |
try: | |
m = Connection(module._socket_path) | |
capabilities = module.from_json(m.get_capabilities()) | |
server_capabilities = capabilities.get('server_capabilities') | |
except Exeption as exc: | |
module.fail_json(msg=to_text(exc)) | |
result = {'changed': False, 'capabilities': capabilities} | |
module.exit_json(**result) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment