1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

clarify jc filter usage in the example (#5396)

* Update jc.py

##### SUMMARY
<!— Your description here –>


##### ISSUE TYPE
- Docs Pull Request

+label: docsite_pr

* Update jc.py

* Update plugins/filter/jc.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update jc.py

* Update plugins/filter/jc.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update jc.py

* Update jc.py

* Update jc.py

* Update plugins/filter/jc.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/filter/jc.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* change all of the tags to be FQMN

FQMN = fully qualified module name

* Update jc.py

* Update plugins/filter/jc.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update jc.py

* Update jc.py

* Update plugins/filter/jc.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update jc.py

* Update plugins/filter/jc.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update plugins/filter/jc.py

Co-authored-by: Felix Fontein <felix@fontein.de>

Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
Ron Green 2022-10-24 20:25:24 +03:00 committed by GitHub
parent b9d0864957
commit 70c57dcb6a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -38,10 +38,16 @@ DOCUMENTATION = '''
type: boolean type: boolean
default: false default: false
requirements: requirements:
- jc (https://github.com/kellyjonbrazil/jc) - jc installed as a Python library (U(https://pypi.org/project/jc/))
''' '''
EXAMPLES = ''' EXAMPLES = '''
- 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
- name: Run command - name: Run command
ansible.builtin.command: uname -a ansible.builtin.command: uname -a
register: result register: result
@ -94,15 +100,19 @@ def jc(data, parser, quiet=True, raw=False):
dictionary or list of dictionaries dictionary or list of dictionaries
Example: Example:
- name: run date command - name: run date command
hosts: ubuntu hosts: ubuntu
tasks: tasks:
- shell: date - 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
- ansible.builtin.shell: date
register: result register: result
- set_fact: - ansible.builtin.set_fact:
myvar: "{{ result.stdout | community.general.jc('date') }}" myvar: "{{ result.stdout | community.general.jc('date') }}"
- debug: - ansible.builtin.debug:
msg: "{{ myvar }}" msg: "{{ myvar }}"
produces: produces:
@ -124,7 +134,7 @@ def jc(data, parser, quiet=True, raw=False):
""" """
if not HAS_LIB: if not HAS_LIB:
raise AnsibleError('You need to install "jc" prior to running jc filter') raise AnsibleError('You need to install "jc" as a Python library on the Ansible controller prior to running jc filter')
try: try:
jc_parser = importlib.import_module('jc.parsers.' + parser) jc_parser = importlib.import_module('jc.parsers.' + parser)