Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use Ansible's JINJA2 filters like json_query in "jinja2" CLI tool? #115

Open
malayamanas opened this issue Jul 4, 2023 · 1 comment

Comments

@malayamanas
Copy link

How to use Ansible's JINJA2 filters like json_query in "jinja2" CLI tool?

How to use EXTENSIONS ?

jinja2

Usage: jinja2 [options]

Options:
--version show program's version number and exit
-h, --help show this help message and exit
--format=FORMAT format of input variables: auto, env, ini, json,
querystring, yaml, yml
-e EXTENSIONS, --extension=EXTENSIONS
extra jinja2 extensions to load
-D key=value Define template variable in the form of key=value
-s SECTION, --section=SECTION
Use only this section from the configuration
--strict Disallow undefined variables to be used within the
template
-o FILE, --outfile=FILE
File to use for output. Default is stdout.

@jensborch
Copy link

I think you can install jinja2-ansible-filters, something like:

pip install jinja2-ansible-filters
jinja2 mytemplate.j2 myvars.yml --format=yml -e jinja2_ansible_filters.AnsibleCoreFiltersExtension

but I have not tried it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants