community.general.jc (8.5.0) — filter

Convert output of many shell commands and file-types to JSON

| "added in version" 1.1.0 of community.general"

Authors: Kelly Brazil (@kellyjonbrazil)

Install collection

Install with ansible-galaxy collection install community.general:==8.5.0


Add to requirements.yml

  collections:
    - name: community.general
      version: 8.5.0

Description

Convert output of many shell commands and file-types to JSON.

Uses the L(jc library,https://github.com/kellyjonbrazil/jc).


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Install the prereqs of the jc filter (jc Python package) on the Ansible controller
  delegate_to: localhost
  ansible.builtin.pip:
    name: jc
    state: present
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Run command
  ansible.builtin.command: uname -a
  register: result
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Convert command's result to JSON
  ansible.builtin.debug:
    msg: "{{ result.stdout | community.general.jc('uname') }}"

Inputs

    
raw:
    default: false
    description: Set to V(true) to return pre-processed JSON.
    type: boolean

quiet:
    default: true
    description: Set to V(false) to not suppress warnings.
    type: boolean

_input:
    description: The data to convert.
    required: true
    type: string

parser:
    description:
    - The correct parser for the input data.
    - For example V(ifconfig).
    - 'Note: use underscores instead of dashes (if any) in the parser module name.'
    - See U(https://github.com/kellyjonbrazil/jc#parsers) for the latest list of parsers.
    required: true
    type: string

Outputs

_value:
  description: The processed output.
  type: any