struggling with include files

I am seriously struggling with trying to include yml files in my top level play

I have prereqcheck.yml in which I want to set the host for the rest of the included files to use

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”

oh man - thank you :slight_smile:

I wonder that this works, with having the same 'key' called directory
three times. I am not an expert but I would have guessed this should
cause all kinds of trouble, because how can you distinguish between
these three entries?

Johannes

its actually a list of dictionaries with single key
top:

  • dictionary: ‘stuff’

top[0][‘dictionary’] == ‘stuff’