Ansible: "msg": "You need to install \"jc\" prior to running jc filter"
See original GitHub issueInstalled jc locally and w/ ansible-galaxy for some reason it’s not being found:
---
- name: "Get Junos OS configuration"
hosts: junos_all
connection: local
gather_facts: no
tasks:
- name: run show version on remote devices
juniper.device.command:
commands: show system uptime
register: output
- name: Print response
debug:
var: "{{ output.stdout_lines | community.general.jc('System booted') }}"
jc --version
jc version 1.16.1
https://github.com/kellyjonbrazil/jc
© 2019-2021 Kelly Brazil
dig example.com | jc --dig
[{"id":30676,"opcode":"QUERY","status":"NOERROR","flags":["qr","rd","ra"],"query_num":1,"answer_num":1,"authority_num":0,"additional_num":1,"opt_pseudosection":{"edns":{"version":0,"flags":[],"udp":1220}},"question":{"name":"example.com.","class":"IN","type":"A"},"answer":[{"name":"example.com.","class":"IN","type":"A","ttl":17,"data":"93.184.216.34"}],"query_time":44,"server":"192.168.32.11#53(192.168.32.11)","when":"Thu Aug 26 11:25:12 PDT 2021","rcvd":56,"when_epoch":1630002312,"when_epoch_utc":null}]
ansible --version
ansible [core 2.11.4]
config file = /Users/nmoore/code/neteng/automation/junos/ansible/ansible.cfg
configured module search path = ['/Users/nmoore/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/ansible
ansible collection location = /Users/nmoore/.ansible/collections:/usr/share/ansible/collections
executable location = /Library/Frameworks/Python.framework/Versions/3.9/bin/ansible
python version = 3.9.6 (v3.9.6:db3ff76da1, Jun 28 2021, 11:49:53) [Clang 6.0 (clang-600.0.57)]
jinja version = 3.0.1
libyaml = True
ag collection list
# /Users/nmoore/.ansible/collections/ansible_collections
Collection Version
---------------------- -------
cisco.meraki 2.4.2
community.general 3.5.0
juniper.device 1.0.0
paloaltonetworks.panos 2.7.0
Issue Analytics
- State:
- Created 2 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
community.general.jc filter – Convert output of many shell ...
To install it, use: ansible-galaxy collection install community.general . You need further requirements to be able to use this filter plugin, ...
Read more >ansible-sample/jc.yml at master - filter - GitHub
fatal: [localhost]: FAILED! =>. # msg: You need to install "jc" prior to running jc filter. # require: # pip install jc. tasks:...
Read more >"You need to install 'jmespath' prior to running json_query filter ...
It seems that: Ansible is using the non-default version python3.8; The module jmespath needs to be installed for both versions separately.
Read more >Parsing Command Output in Ansible with JC - Brazil's Blog
Installation. To use the jc filter plugin, you just need to install jc and the community.general collection on the Ansible controller.
Read more >jc · PyPI
Argument Command or Filetype Documentation
‑‑acpi acpi command parser details
‑‑airport airport ‑I command parser details
‑‑airport‑s airport ‑s command parser details
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
BTW, you can also parse the first 5 lines using the
jc
key/value parser (kv
):should produce this:
(Actually you’ll, probably have to join that list with
\n
)I think you just need to do the join before it goes to
jc
:(I changed the 5 to 6 since I noticed an extra
\n
at the beginning of the output. Hope that works)Thanks for the suggestion - I’ll look into signing up!