--- - block: - name: "Read template {{ template }}" command: cat '{{template_path}}/{{template}}' changed_when: false register: results - name: Parse JSON templates set_fact: tmpl="{{ results.stdout | from_json }}" when: template.find(".json") != -1 - name: Parse YaML templates set_fact: tmpl="{{ results.stdout | from_yaml }}" when: template.find(".json") == -1 - include_tasks: template.yml when: tmpl.kind == "Template" - include_tasks: resource.yml when: tmpl.kind != "Template" run_once: true