You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The when: conditionals are not evaluated before with_items: variable references are resolved
STEPS TO REPRODUCE
- debug: msg="{{ bootstrap_sshguard_whitelist }}"
when: bootstrap_sshguard_whitelist is defined
- name: sshguard whitelist entries
lineinfile:
dest: /etc/sshguard/whitelist
regexp: '.*{{ item.ip }}.*$'
line: "{{ item.ip }} # {{ item.comment }}"
state: present
when:
- bootstrap_sshguard_whitelist is defined
- st.stat is defined
- st.stat.exists
with_items:
- "{{ bootstrap_sshguard_whitelist }}"
notify:
- reload sshguard
EXPECTED RESULTS
When boostrap_sshguard_whitelist is NOT defined the "sshguard whitelist entries" task should not be executed. But it looks like the ansible attempts to resolve the "{{ bootstrap_sshguard_whitelist }}" in the with_items:
ISSUE TYPE
COMPONENT NAME
when: conditional
with_items:
ANSIBLE VERSION
CONFIGURATION
Stock devel configuration
OS / ENVIRONMENT
Running macOS Sierra
Managing Ubuntu Xenial
SUMMARY
The when: conditionals are not evaluated before with_items: variable references are resolved
STEPS TO REPRODUCE
EXPECTED RESULTS
When boostrap_sshguard_whitelist is NOT defined the "sshguard whitelist entries" task should not be executed. But it looks like the ansible attempts to resolve the "{{ bootstrap_sshguard_whitelist }}" in the with_items:
ACTUAL RESULTS
The debug is skipped proving bootstrap_sshguard_whitelist is not defined.
The text was updated successfully, but these errors were encountered: