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

Ansible filters #104

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Ansible filters #104

wants to merge 4 commits into from

Conversation

rpersee
Copy link

@rpersee rpersee commented Jun 21, 2022

Hi,

This adds support for Ansible filters (without importing each one manually like you would have to do with #86 ?).
This would also solve #91 and #85 (and my need to use the Ansible password_hash filter).
Maybe you could look at it and tell me if there are things that need to be fixed?

Thanks

jinja2cli/cli.py Outdated
Comment on lines 224 to 226
from ansible.plugins.filter.core import FilterModule

return FilterModule().filters()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we try...except ImportError and print a more useful message to say that ansible-core is missing? Just so we can suggest how to resolve the issue.

Added import error message when `Ansible Core` is not installed (and
`--ansible` is used).
Importing all filters from `ansible.plugins.filter`.
@rpersee
Copy link
Author

rpersee commented Jun 22, 2022

Filters in ansible always seem to be contained under the following structure: <base module>.plugins.filter.<*.py> > ModuleFilter.filters(). So I reformatted the code to be more generic and added the ability to import filters from Ansible Collections (like ansible.utils, ansible.netcommon, community.general, ...).
To use the basic filters you can use --ansible core or --ansible <collection> for any additionnal Ansible Collection (like --ansible community.general for random_mac filter for example).

@rpersee
Copy link
Author

rpersee commented Apr 23, 2023

What's up dude?

@mattrobenolt
Copy link
Owner

What's up dude?

Hey man, how's it going?

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

Successfully merging this pull request may close these issues.

2 participants