nested playbooks

267 views
Skip to first unread message

Dave Cottlehuber

unread,
Jul 5, 2016, 10:34:25 AM7/5/16
to ansible...@googlegroups.com
Hi

My nested playbooks fail with this error:

$ ansible-playbook site.yml --limit dev

ERROR! no action detected in task. This often indicates a misspelled
module name, or incorrect module path.

The error appears to have been in '/projects/ansible/base.yml': line 2,
column 3, but may
be elsewhere in the file depending on the exact syntax problem.

The offending line appears to be:

---
- hosts: base
^ here

I couldn't find a working example or docs of nested playbooks. I only
see it mentioned here[1]:

"Playbooks can include other playbooks too, but that’s mentioned in
a later section."

This is what I currently have:

# site.yml
---
- name: site | deploy and configure all the things
hosts: all
become: yes
gather_facts: yes
vars_files:
- vars/users.yml
- vars/iocage.yml
tasks:
- include: base.yml
- include: dev.yml
- include: mgmt.yml

base,dev,mgmt are all largely the same, matching inventory groups of the
same name:

# base.yml
---
- hosts: base
become: yes
gather_facts: yes
roles:
- pkg
- batbelt
- inventory
- ntpd

etc.

what am I missing?

Dave Cottlehuber
Skunkwerks, GmbH

[1]: http://docs.ansible.com/ansible/playbooks_roles.html

Kai Stian Olstad

unread,
Jul 5, 2016, 11:04:29 AM7/5/16
to ansible...@googlegroups.com
On 05. juli 2016 16:34, Dave Cottlehuber wrote:
> I couldn't find a working example or docs of nested playbooks. I only
> see it mentioned here[1]:
>
> "Playbooks can include other playbooks too, but that’s mentioned in
> a later section."
>
> This is what I currently have:
>
> # site.yml
> ---
> - name: site | deploy and configure all the things
> hosts: all
> become: yes
> gather_facts: yes
> vars_files:
> - vars/users.yml
> - vars/iocage.yml
> tasks:
> - include: base.yml
> - include: dev.yml
> - include: mgmt.yml

You have included base, dev and mgmt as task files, not as playbooks.

Just remove the spaces in front and they will be includes as playbooks.

- name: site | deploy and configure all the things
hosts: all
become: yes
gather_facts: yes
vars_files:
- vars/users.yml
- vars/iocage.yml
tasks:

- include: base.yml
- include: dev.yml
- include: mgmt.yml

Since you don't have any tasks in the site.yml playbook you can remove
tasks:

--
Kai Stian Olstad
Reply all
Reply to author
Forward
0 new messages