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
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tasks/dnsmasq.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

tags: dnsmasq
loop:
- { dest: '/etc/dnsmasq.d/10-consul', group: 'root', when: ansible_os_family|lower != "freebsd" }
Expand Down
2 changes: 1 addition & 1 deletion tasks/install_linux_repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
name: "{{ consul_repo_prerequisites }}"
state: present
become: true
when: (consul_os_repo_prerequisites)
when: (consul_repo_prerequisites)
tags: installation

- name: Populate service facts
Expand Down