So you have 2 types of includes, plays or task lists, you are mixing play
level directives in an include inside a play, this is not permitted.
An include inside a play can ONLY have a list of tasks, you are putting
vars: and tasks: directives which implies play. In >=2.0 vars can now be
part of any task, so you can put it with the include itself.
- name: Perform all prerequisite checks
hosts: localhost
tasks:
- include: prereqcheck_directories.yml
vars:
directories:
- directory: "/opt/test"
- directory: "/etc"
- directory: "/xyz"
the included file:
---
- name: Check directories exist
stat:
path: "{{ item.directory }}"
with_items: directories
register: directory_stat
- debug:
var: item.1.directory
with_indexed_items: directories
when: directory_stat.results[item.0].stat.exists
----------
Brian Coca
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/CACVha7cE66a%2Bjwv4%3DTzJxzvUuGqV02jwafR3cns3iJuqG2D7CQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.