Nesting Playbooks?

216 views
Skip to first unread message

Slim Slam

unread,
Nov 19, 2015, 6:58:35 PM11/19/15
to Ansible Project
Ansible v1.9.4

I have a playbook that I launch with:

$ ansible-playbook build.yml

build.yml includes set_os.yml (just a set of tasks) that launches some ec2 instances. build.yml looks like this.

- name: Build stuff
  hosts
: localhost
  remote_user
: ec2-user
  sudo
: False
  gather_facts
: False
  tasks
:
   
- include: set_os.yml
   
- include: build_soft.yml

At the end of build.yml above, I also include build_soft.yml which is another playbook:

---
- name: Configure the EC2 instance
  hosts
: ec2hosts
  gather_facts
: true
  tasks
:
   
- do something......

Although I've seen examples of multiple plays, Ansible doesn't seem to like this way of including
plays and immediately exists with:

ERROR: gather_facts [or hosts or tasks] is not a legal parameter in an Ansible task or handler

I need to immediately start configuring my new EC2 instances that have been stored in the "ec2hosts" group var. 
Is this way of nesting plays not supported or am I making a mistake somewhere else?

-J




Timothy Gerla

unread,
Nov 19, 2015, 8:44:03 PM11/19/15
to ansible-project
Since build_soft.yml is a full playbook and not just a list of tasks, like set_os.yml, the include shouldn't be indented to the same level. Try de-denting the build_soft.yml as far left as possible, and it should behave as expected.

-Tim

--
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 ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/eb1ca398-2fa6-46dd-bf59-e52efd7f28f3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Slim Slam

unread,
Nov 20, 2015, 11:49:39 AM11/20/15
to Ansible Project
That was it. Thanks.

J
Reply all
Reply to author
Forward
0 new messages