--- - name: Include file list include_vars: "local.yaml" - name: Defined local-path-storage state to present set_fact: storage_localpath_state: present when: - storage_localpath|bool - name: find state of local-path-storage set_fact: storage_localpath_state: absent when: - not storage_localpath|bool - name: local-path-storage need to be {{ storage_localpath_state }} k8s: state: "{{ storage_localpath_state }}" context: "{{ my_context }}" merge_type: merge resource_definition: "{{ lookup('file', 'local/' + item) | from_yaml }}" with_items: - "{{ storage_localpath_files_list }}"