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

---
- name: Perform all prerequisite checks
  hosts: localhost
  tasks:
    - include: prereqcheck_directories.yml
    #- include: prereqcheck_users.yml
    #- include: prereqcheck_owner.yml

for my included file I have

---
- vars:
    directories:
      - directory: "/opt/test"
      - directory: "/etc"
      - directory: "/xyz"

- tasks:
    - 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

if I add the hosts in prereqcheck_directories.yml then I can run it 
independently

However if I try to run my top level play, I get...
fatal: [localhost]: FAILED! => {"failed": true, "reason": "ERROR! no action 
detected in task\n\nThe error appears to have been in 
'/home/daviesp/D4/solarisbase/tasks/prereqcheck_directories.yml': line 2, 
column 3, but may\nbe elsewhere in the file depending on the exact syntax 
problem.\n\nThe offending line appears to be:\n\n---\n- vars:\n  ^ here\n"}


Various other attempts invariable end in a syntax error
What am I doing wrong here? I have searched ansible docs for some guidance 
on how to indent using include files but cannot find what I am looking for.

How do I include different plays all using the same host set at the top 
level?

-- 
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/99ec46e9-07f5-4af3-91ee-2297cc38a6e0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to