# roles defined after include statement are ignored

**URL:** <https://forum.ansible.com/t/roles-defined-after-include-statement-are-ignored/15116>\
**Category:** Ansible Project\
**Created:** [April 30, 2014, 12:45pm UTC](https://forum.ansible.com/t/roles-defined-after-include-statement-are-ignored/15116 "2014-04-30T12:45:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Manu\_J](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@Manu\_J](https://forum.ansible.com/u/Manu_J)\
**Post date:** [April 30, 2014, 12:45pm UTC](https://forum.ansible.com/t/roles-defined-after-include-statement-are-ignored/15116/1 "2014-04-30T12:45:25Z")

</div>

I have a playbook which looks like this

- hosts: all  
include: rails-servers.yml  
roles:
- statsd
- app

The roles in rails-servers.yml are executed. but app & statsd roles are not executed by ansible (using 1.5).  
If I remove the include statement it gets executed. I get no errors when I run ansible. The roles are silently ignored.

rails-servers is a common playbook and this particular server needs some extra roles (statsd and app). What’s the

idiomatic way of doing it in ansible?

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [April 30, 2014, 1:15pm UTC](https://forum.ansible.com/t/roles-defined-after-include-statement-are-ignored/15116/2 "2014-04-30T13:15:11Z")

</div>

There is no play level include statement – it simply doesn’t exist.

You don’t include roles files, you just list them in the roles section and they are loaded out of the configured roles path.

What version of Ansible are you running? I would have expected this invalid keyword to raise an error in recent versions.

---

<div class="post-metadata">

**Author:** ![Manu\_J](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@Manu\_J](https://forum.ansible.com/u/Manu_J)\
**Post date:** [May 2, 2014, 5:02am UTC](https://forum.ansible.com/t/roles-defined-after-include-statement-are-ignored/15116/3 "2014-05-02T05:02:14Z")

</div>

Solved. This was a syntax problem.

This works

# file: site.yml

- hosts: all  
include: rails-servers.yml

# file: rail-servers.yml

- hosts: all  
roles:
- mysql
- ruby
- memcached

This does not work

# file: site.yml

- hosts: all

include: rails-servers.yml  
roles:

- statsd
- app

# file: rail-servers.yml

- hosts: all  
roles:
- mysql
- ruby
- memcached

When I do this, the roles in rails-servers.yml (mysql / ruby / memcached) are executed but the roles in site.yml (statsd / app) are silently ignored.

Solved it by changing the syntax to

# file: site.yml

- include: rails-servers.yml
- hosts: all

roles:

- statsd
- app

# file: rail-servers.yml

- hosts: all  
roles:
- mysql
- ruby
- memcached

This is not clearly explained in the documentation. Btw I think there was some misunderstanding of terminology in the original  
email. I was using include at play level but at playbook level.
