AttributeError: "'None' has no attribute when using loop_control

Posted on

Would anyone know if there is an issue with using loop_control with a custom module? We've tested this same exact code with the debug module and there was no issue with skipping the task if the hash to loop was NOT defined. However, when using a custom, loop_control appears to NOT obey the when condition for that hash. The code we are using is below:

- hosts: ...
   vars:
      #my_hash:
       # - a: b
       #   c: d
       # - e: f
       #    g: h  

- name: "Test custom module"
   custom_test_module:
     print: {{ item.a }}
  loop: "{{ my_hash}}"
  loop_control:
    label: "{{ item.a}}"              
  when: my_hash

Responses