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

j2_environment extensions not available while generating config #1448

Open
alexharv074 opened this issue Mar 1, 2024 · 2 comments
Open

j2_environment extensions not available while generating config #1448

alexharv074 opened this issue Mar 1, 2024 · 2 comments

Comments

@alexharv074
Copy link
Contributor

Subject of the issue

Attempting to use J2 extensions such as this fails:

j2_environment:
  extensions:
    - jinja2_ansible_filters.AnsibleCoreFiltersExtension

project_code: "{{ var.BucketName | regex_replace('^[^a-zA-Z]+', '') }}"

This could be the expected behaviour although if so it is confusing and some of the code in the Reader class also seems to imply that the author expected these extensions to be available.

It could be a bug or something that requires better docs.

Your environment

  • version of sceptre (sceptre --version) latest
  • version of python (python --version) 3.10
  • which OS/distro ubuntu

Steps to reproduce

See above.

Expected behaviour

I expected this to work and the regex_replace filter to be available.

Actual behaviour

sceptre.exceptions.SceptreException: config.yaml - No filter named 'regex_replace'.                                                                                                                   
@zaro0508
Copy link
Contributor

a few questions..

  • did you pip install jinja2-ansible-filters first and is it in your python environment?
  • have you tried any other AnsibleCoreFiltersExtension? and does it work?

@alexharv074
Copy link
Contributor Author

@zaro0508 yes and yes. It's definitely a bug or at least undocumented behaviour. For obvious reasons, the custom J2 extensions cannot be loaded at the time of the first layer of J2 rendering that renders the config.yaml itself in the reader class.

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