devops-coop / ansible-haproxy

Installs and configure HAProxy
Apache License 2.0
96 stars 97 forks source link

Getting around Ansible order of ops for when/with_items (hopefully) #65

Closed clwells closed 7 years ago

clwells commented 7 years ago

If haproxy_global[frontends, backends, etc] aren't defined then 'when' portion won't catch this case before with_items tries to eval the var so you'll get:

TASK [ansible-haproxy : Build up the frontends] ********************************
fatal: [ifx-lb01]: FAILED! => {"failed": true, "msg": "'haproxy_frontends' is undefined"}

Even though the module is defined to avoid this. Providing a default empty array gets around this (and probably makes the 'when' unneeded).

benwebber commented 7 years ago

Good catch. Ansible indeed evaluates with_items before when.

It's a bit tidier to keep the defaults in defaults/main.yml, which I've done in 86a7d82.