I have implemented a dynamic inventory for Ansible, during its execution it defines a group variable that I'm using later in a playbook.
In the playbook, I'm using it twice:
- for looping over its contents:
tasks: - include_tasks: include/restart.yaml loop: "{{ host_set | default(['all']) }}" loop_control: loop_var: h - and as a means to set serial conditionally
serial: "{{ host_set | default(false) | ternary('100%', '5') }}"
The behavior I get that I can't explain is that the host_set variable is defined and populated correctly during task execution, but when trying to set serial it seems to be undefined.
Is this expected behavior, are Ansible group variables undefined when setting a play's attributes, but pop up later when task execution for that particular play begins?