Hi everyone!
I’m not a day-to-day user of Ansible, but I am the developer of a tool called JC that JSONifies the output of many commands and file-types and I got some feedback that it might be good to integrate JC into Ansible as a plugin so admins can execute arbitrary commands on the remote devices and receive structured data back.
I’m reading the dev docs and it looks like something like this would be a Filter Plugin. Is that correct?
JC is written in Python (only supports Python 3.6+). JC supports 55 command and file-type parsers that run on Linux, macOS, and FreeBSD.
Is this something that would have any real-world use-cases? I heard a use-case would be for gathering data on devices that don’t have Python installed on them since the filter would be run on the controller. Would it be relatively simple to wrap JC into the appropriate plugin type?
https://github.com/kellyjonbrazil/jc
I’m happy to start working on this, but want to make sure I’m barking up the right tree.
Thanks,
Kelly
I should add that, when used as a library, JC actually returns a Dict or List of Dicts, not JSON, but can easily convert to JSON before sending to the end-user, if needed.
Hi everyone!
I'm not a day-to-day user of Ansible, but I am the developer of a tool called JC that JSONifies the output of many commands and file-types and I got some feedback that it might be good to integrate JC into Ansible as a plugin so admins can execute arbitrary commands on the remote devices and receive structured data back.
I'm reading the dev docs and it looks like something like this would be a Filter Plugin. Is that correct?
JC is written in Python (only supports Python 3.6+). JC supports 55 command and file-type parsers that run on Linux, macOS, and FreeBSD.
Is this something that would have any real-world use-cases? I heard a use-case would be for gathering data on devices that don't have Python installed on them since the filter would be run on the controller. Would it be relatively simple to wrap JC into the appropriate plugin type?
https://github.com/kellyjonbrazil/jc
I'm happy to start working on this, but want to make sure I'm barking up the right tree.
Hello Kelly!
Thank you for reaching out, the timing is perfect because I was just
discussing the possibility of using jc as the backend for something
the other day in a discussion about parsing unstructured output into
structured data (big fan of your work by the way).
I'd love to have JC as a filter plugin in the ansible.posix
Collection[0]! Thank you for suggesting it.
I'd also like to explore the idea of a module_util that provided the
main integration interface for modules[1] to utilize JC for backend
processing of data coming from arbitrary commands run by the
module_util basic cli helper functions[2] such as run_command.
However, for the use case of the module_util we'd have to consider
vendoring JC into that Ansible Collection so that it may be properly
bundled and sent to the remote nodes as part of the AnsiballZ
payload[3] without requiring JC to be installed on every remote node
under Ansible's management.
Let me know your thoughts, I look forward to continuing this discussion.
Thank you,
-AdamM
[0] - https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html
[1] - https://docs.ansible.com/ansible/latest/dev_guide/developing_modules_general.html
[2] - https://github.com/ansible/ansible/blob/devel/lib/ansible/module_utils/basic.py
[3] - https://docs.ansible.com/ansible/2.9/dev_guide/developing_program_flow_modules.html#ansiballz
Hi Adam,
Excellent - I’m fully supportive and am happy to assist in any way. Looking forward to working on this project!
Kelly
Hi Adam,
Excellent - I'm fully supportive and am happy to assist in any way. Looking forward to working on this project!
Kelly,
Sounds good, I don't know when/if I'd have the cycles to commit to
doing any work towards this effort but I'm on board with it. Something
else that was brought up to me recently is that the insights-core[0]
project has over 200 parsers for various linux things and might be of
interest to either JC, Ansible, or both so I'm planning to try and
find some time to look at these and see where/how we can utilize them.
I've also been considering the best place for the JC integration and I
think community.general is a solid place for it. If you have the time
and/or inclination, I'd be happy to review a pull request against the
community.general[1] Collection.
Thank you again,
-AdamM
[0] - https://github.com/RedHatInsights/insights-core
[1] - https://github.com/ansible-collections/community.general
Hi Adam,
Very interesting - thank you for sending those resources. I’ll check them out. I’ll see if I can get a first stab at a community.general collection going.
Cheers,
Kelly
Hi Adam,
I created a basic PR: https://github.com/ansible-collections/community.general/pull/750
More than happy to extend this as needed.
Thanks,
Kelly