Skip to content

Commit e78351e

Browse files
committed
Fix cloudflare_proxy conditional to use bool filter
The cloudflare_proxy variable is set as a host variable in INI inventory files generated by Terraform. INI inventory treats all values as strings, so `cloudflare_proxy=true` arrives as the string "True". Newer Ansible versions enforce that `when:` conditionals must evaluate to actual booleans, causing a fatal error. Adding `| bool` filter converts the string to a proper boolean.
1 parent b14698a commit e78351e

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

climate-nginx-base/tasks/main.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,15 @@
6868
src: cloudflare-update-ip-ranges.sh
6969
dest: /usr/local/bin/cloudflare-update-ip-ranges.sh
7070
mode: '0755'
71-
when: cloudflare_proxy
71+
when: cloudflare_proxy | bool
7272
tags: climate-nginx-base
7373

7474
# Run Cloudflare IP address retrieval script if proxying through cloudflare
7575
- name: Run Cloudflare IP address retrieval script
7676
become: true
7777
ansible.builtin.shell:
7878
cmd: /usr/local/bin/cloudflare-update-ip-ranges.sh
79-
when: cloudflare_proxy
79+
when: cloudflare_proxy | bool
8080
tags: climate-nginx-base
8181

8282
# If proxying through cloudflare, set crontab to run the cloudflare-update-ip-ranges.sh script once a week
@@ -90,7 +90,7 @@
9090
day: "*"
9191
month: "*"
9292
weekday: "1"
93-
when: cloudflare_proxy
93+
when: cloudflare_proxy | bool
9494
tags: climate-nginx-base
9595

9696
# Remove blocklist file if nginx_blocklist is empty

0 commit comments

Comments
 (0)