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 undefined variable for repo installs #491

Closed
wants to merge 2 commits into from

Conversation

sandipb
Copy link
Contributor

@sandipb sandipb commented Jul 15, 2022

#460 introduced an typo causing repo installations to fail

TASK [ansible-consul : Install OS packages] ***********************************************************************************************************************
fatal: [neptune]: FAILED! => {"msg": "The conditional check '(consul_os_repo_prerequisites)' failed. The error was: error while evaluating conditional ((consul_os_repo_prerequisites)): 'consul_os_repo_prerequisites' is undefined\n\nThe error appears to be in '***/.cache/roles/ansible-consul/tasks/install_linux_repo.yml': line 4, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: Install OS packages\n  ^ here\n"}

Also reported here: #466

ansible-collections#460 introduced an typo causing repo installations to fail
@sandipb sandipb changed the title Fix undefined variable Fix undefined variable for repo installs Jul 15, 2022
Trying to fix
```
102 No Jinja2 in when
tasks/dnsmasq.yml:31
Task/Handler: Create Dnsmasq configuration
Error: [E102] No Jinja2 in when
```
@@ -37,7 +37,7 @@
mode: 0644
become: true
notify: restart dnsmasq
when: "{{ item.when }}"
when: item.when
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
when: item.when
when: "{{ dnsmasq_item.when }}"

See #488.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nre-ableton
The lint error was about jinja expressions being used in when. It only expected pure python expressions. Have you tried this out by lint?

Copy link
Contributor

@nre-ableton nre-ableton Jul 19, 2022

Choose a reason for hiding this comment

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

@sandipb True, but there are several other places in this role where such expressions are used, which is why my PR disabled the expression for the time being. I think that changing the other usages and re-enabling the warning deserves a separate PR.

However, my suggestion is not so much about the Jinja2 expressions but rather the use of item, which will be undefined and fail. That was named to dnsmasq_item here.

If you prefer, you could also do:

Suggested change
when: item.when
when: dnsmasq_item.when

Copy link
Member

Choose a reason for hiding this comment

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

Duplicate

@sandipb sandipb deleted the patch-1 branch December 12, 2022 16:33
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.

3 participants