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

fix: conditional statements jinja2 warning #685

Merged
merged 3 commits into from
Jan 15, 2024
Merged

Conversation

iisojunn
Copy link
Contributor

@iisojunn iisojunn commented Jan 12, 2024

When ansible-core version is updated from 2.15.4 to 2.15.8 the following warning occurs:
[WARNING]: conditional statements should not include jinja2 templating delimiters such as {{ }} or {% %}

Fixed by removing the delimeters.

Proposed changes

Describe the use case and detail of the change. If this PR addresses an issue on GitHub, make sure to include a link to that issue using one of the supported keywords here in this description (not in the title of the PR).

Checklist

Before creating a PR, run through this checklist and mark each as complete:

  • I have read the CONTRIBUTING document.
  • I have added Molecule tests that prove my fix is effective or that my feature works.
  • I have checked that any relevant Molecule tests pass after adding my changes.
  • I have updated any relevant documentation (defaults/main/*.yml, README.md and CHANGELOG.md).

When ansible-core version is updated from 2.15.4 to 2.15.8
the following warning occurs:
[WARNING]: conditional statements should not include jinja2 templating
delimiters such as {{ }} or {% %}

Fixed by removing the delimeters.

Signed-off-by: Ilari Iso-Junno <[email protected]>
@iisojunn iisojunn requested a review from alessfg as a code owner January 12, 2024 16:01
@alessfg alessfg added this to the 0.24.3 milestone Jan 12, 2024
@alessfg alessfg added the bug Something isn't working label Jan 12, 2024
if ansible_facts['distribution'] | lower in ['alpine', 'ubuntu'] else ansible_facts['distribution_major_version'] in nginx_distributions[ansible_facts['distribution'] | lower]['versions'] | string }}"
- "{{ ansible_facts['architecture'] in nginx_distributions[ansible_facts['distribution'] | lower]['architectures'] }}"
- ansible_facts['distribution'] | lower in nginx_distributions.keys() | list
- (ansible_facts['distribution_version'] | regex_search('\\d{1,2}\\.\\d{2}') | float in nginx_distributions[ansible_facts['distribution'] | lower]['versions'] | map('float')
Copy link
Collaborator

@alessfg alessfg Jan 12, 2024

Choose a reason for hiding this comment

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

Can you move the parentheses back to where they were? I've run into situations using the "X if Y" conditional in Ansible has led to issues when the "X" was not wrapped in parentheses.

Copy link
Collaborator

@alessfg alessfg left a comment

Choose a reason for hiding this comment

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

See the comment I made in the review 😄

@iisojunn
Copy link
Contributor Author

iisojunn commented Jan 12, 2024 via email

@alessfg
Copy link
Collaborator

alessfg commented Jan 12, 2024

It's not needed in this case, but it's there for consistency around this role and the config role. That being said, after removing the curly braces and double quotes, something (e.g. parentheses) had to be used to ensure that it works given that it's a multiline conditional. I'll readd them on Monday 😄

@alessfg alessfg self-requested a review January 15, 2024 19:11
@alessfg
Copy link
Collaborator

alessfg commented Jan 15, 2024

I ended up flattening everything into a single line 👌

@alessfg alessfg merged commit d8a5917 into nginxinc:main Jan 15, 2024
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging this pull request may close these issues.

2 participants