Ansible filter fails when parsers have a dash in their names?
See original GitHub issueI realise I should probably be asking this in community.general…
Does the community.general.jc
ansible filter simply fail for parsers with a dash in their names?
---
- name: JC test
block:
- name: List files in /tmp using ls -1l /tmp
ansible.builtin.command: ls -1l /tmp
check_mode: false
changed_when: false
register: jc_ls_1l
- name: Set a fact for the result of ls -1l /tmp
ansible.builtin.set_fact:
jc_ls: "{{ jc_ls_1l.stdout | community.general.jc('ls') }}"
- name: Debug list files in /tmp
ansible.builtin.debug:
var: jc_ls
- name: List packages using dpkg -l
ansible.builtin.command: dpkg -l
environment:
COLUMNS: 500
check_mode: false
changed_when: false
register: jc_dpkg_l
- name: Set a fact for the result of dpkg -l
ansible.builtin.set_fact:
jc_dpkg: "{{ jc_dpkg_l.stdout | community.general.jc('dpkg-l') }}"
tags:
- jc
...
Results in:
TASK [jc : List files in /tmp using ls -1l /tmp] *******************************
ok: [localhost]
TASK [jc : Set a fact for the result of ls -1l /tmp] ***************************
ok: [localhost]
TASK [jc : Debug list files in /tmp] *******************************************
ok: [localhost] => {
"jc_ls": [
{
"date": "Nov 7 22:07",
"filename": "ansible_ansible.legacy.command_payload_sn843j60",
"flags": "drwx------",
"group": "root",
"links": 2,
"owner": "root",
"size": 4096
}
]
}
TASK [jc : List packages using dpkg -l] ****************************************
ok: [localhost]
TASK [jc : Set a fact for the result of dpkg -l] *******************************
fatal: [localhost]: FAILED! => {"msg": "Error in jc filter plugin: No module named 'jc.parsers.dpkg-l'"}
Or am I doing something daft?
Issue Analytics
- State:
- Created 10 months ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Using filters to manipulate data - Ansible Documentation
Filters let you transform JSON data into YAML data, split a URL to extract the hostname, get the SHA1 hash of a string,...
Read more >hyphen in dictionary key breaks json_query #33163 - GitHub
Files identified in the description: lib/ansible/plugins/filter/json_query.py. If these files are inaccurate, please update the component name ...
Read more >Filters — Ansible Documentation
Filters can help you manage missing or undefined variables by providing defaults or making some variable optional. If you configure Ansible to ignore...
Read more >Ansible templating skips string after a dash - Stack Overflow
If you have VARIABLE NAMES that contain a dash, you can use vars : ... Ansible 2.8.5 seems allow dash/hyphen in the variables....
Read more >Filter JSON Data in Ansible Using json_query | The NTC Mag
The built-in json_query filter provides the functionality for filtering, shaping, and transforming JSON data. It uses the third-party jmespath ...
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
Good plan, I’ll leave that to you 😉 .
Yeah it probably makes sense to update the parser parameter comments on that documentation page. I think we can just submit a PR with the updated verbiage and it will go into the next release.