# Mak

**URL:** <https://forum.ansible.com/t/mak/13081>\
**Category:** Ansible Project\
**Created:** [July 7, 2013, 10:51pm UTC](https://forum.ansible.com/t/mak/13081 "2013-07-07T22:51:22Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joost\_Cassee](https://avatars.discourse-cdn.com/v4/letter/j/898d66/32.png) [@Joost\_Cassee](https://forum.ansible.com/u/Joost_Cassee)\
**Post date:** [July 7, 2013, 10:51pm UTC](https://forum.ansible.com/t/mak/13081/1 "2013-07-07T22:51:22Z")

</div>

Hi,

I am just learning Ansible, coming from Puppet and having looked into Salt a bit. The simplicity is refreshing, but I was surprised by the number of files and directories I needed to create in order to use roles. (Maybe they are designed only to be used if you grow beyond a certain complexity level, but the docs suggest them as best practice.)

The tasks, handlers and vars directories seem a bit overkill:

- If roles/x/tasks/main.yml exists, tasks listed therein will be added to the play
- If roles/x/handlers/main.yml exists, handlers listed therein will be added to the play
- If roles/x/vars/main.yml exists, variables listed therein will be added to the play

Would a pull request be accepted that also looks for these files:

- roles/x/tasks.yml
- roles/x/handlers.yml
- roles/x/vars.yml

Regards,  
Joost

PS. The section Group By Roles in the Best Practices confused me for a while after having read about roles.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [July 7, 2013, 11:30pm UTC](https://forum.ansible.com/t/mak/13081/2 "2013-07-07T23:30:54Z")

</div>

You can choose to just create one of the many directories and will be fine if you do that.

I don’t think they are overkill.

---

<div class="post-metadata">

**Author:** ![Joost\_Cassee](https://avatars.discourse-cdn.com/v4/letter/j/898d66/32.png) [@Joost\_Cassee](https://forum.ansible.com/u/Joost_Cassee)\
**Post date:** [July 7, 2013, 11:43pm UTC](https://forum.ansible.com/t/mak/13081/3 "2013-07-07T23:43:08Z")

</div>

Hi Michael,

What I meant was that the tasks, handlers and vars directories  
themselves seem overkill. Why force a directory that only contains one  
file?

Regards,  
Joost

---

<div class="post-metadata">

**Author:** ![Mark\_Mandel](https://avatars.discourse-cdn.com/v4/letter/m/bc79bd/32.png) [@Mark\_Mandel](https://forum.ansible.com/u/Mark_Mandel)\
**Post date:** [July 7, 2013, 11:54pm UTC](https://forum.ansible.com/t/mak/13081/4 "2013-07-07T23:54:22Z")

</div>

I don’t know about anyone else, but I tend to have a main.yml which then includes multiple other files that are also in the same directory.

Otherwise a huge main.yml becomes quite unwieldy to manage. In that way, I find having separate directories works really well.

Mark

---

<div class="post-metadata">

**Author:** ![Joost\_Cassee](https://avatars.discourse-cdn.com/v4/letter/j/898d66/32.png) [@Joost\_Cassee](https://forum.ansible.com/u/Joost_Cassee)\
**Post date:** [July 8, 2013, 12:19am UTC](https://forum.ansible.com/t/mak/13081/5 "2013-07-08T00:19:54Z")

</div>

Hi Mark,

Ah, so that is common, then. I take it task includes with relative  
filenames are looked up in the tasks/ directory then. (That was one  
detail that was missing from the docs.)

Regards,  
Joost

---

<div class="post-metadata">

**Author:** ![Mark\_Maas](https://avatars.discourse-cdn.com/v4/letter/m/7c8e57/32.png) [@Mark\_Maas](https://forum.ansible.com/u/Mark_Maas)\
**Post date:** [July 8, 2013, 5:26am UTC](https://forum.ansible.com/t/mak/13081/6 "2013-07-08T05:26:26Z")

</div>

Hi,

We tend to have a “common” role, and stuff like “ubuntu-common”, “redhat-common” , etc. And inside those tasks folders we have multiple little playbooks for stuff like configuring NTP, ssmtp, resolv.conf, various little packages and tweaks. And those are then included via the main.yml.

Makes it all very sturdy,

---

<div class="post-metadata">

**Author:** ![Joost\_Cassee](https://avatars.discourse-cdn.com/v4/letter/j/898d66/32.png) [@Joost\_Cassee](https://forum.ansible.com/u/Joost_Cassee)\
**Post date:** [July 8, 2013, 9:05am UTC](https://forum.ansible.com/t/mak/13081/7 "2013-07-08T09:05:38Z")

</div>

Thanks to both Marks for their use-cases. I think I should think about  
roles as being more granular than I initially thought.

My use-case is apparently slightly different. The docs say: "Grouping  
content by roles also allows easy sharing of roles with other users."  
Reuse is often simpler when elements are smaller, and I have many  
small reusable "modules", that set up fail2ban, SSH, Postfix,  
elasticsearch, etc. They are often just a few tasks, one handler and  
one or two files and templates. Because these components are small,  
the "unnecessary" directories are starting to wear me down. 🙂

Maybe I am missing some other organisational structure in Ansible?

Regards,  
Joost

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan](https://avatars.discourse-cdn.com/v4/letter/m/c4cdca/32.png) [@Michael\_DeHaan](https://forum.ansible.com/u/Michael_DeHaan)\
**Post date:** [July 8, 2013, 12:52pm UTC](https://forum.ansible.com/t/mak/13081/8 "2013-07-08T12:52:50Z")

</div>

I don’t think it matters if you are missing something or not, roles are going to be the way they are, because they expand out into greater usages and mean we don’t have two ways to do the same thing.

Ansible is very much intended to be a minimal system, it always has been that way, and we’re not going to introduce a “half playbook” that includes a combo roles/tasks/vars in one file.

Roles pathing is very useful for the way a task file can include other files in the right directories and you can break things up into smaller pieces.

---

<div class="post-metadata">

**Author:** ![Joost\_Cassee](https://avatars.discourse-cdn.com/v4/letter/j/898d66/32.png) [@Joost\_Cassee](https://forum.ansible.com/u/Joost_Cassee)\
**Post date:** [July 8, 2013, 1:21pm UTC](https://forum.ansible.com/t/mak/13081/9 "2013-07-08T13:21:03Z")

</div>

Hi Michael,

I don't think I proposed a combo roles/tasks/vars file, but I won't  
argue my case further.

Thanks for thinking along!

Regards,  
Joost

---

<div class="post-metadata">

**Author:** ![Joost\_Cassee](https://avatars.discourse-cdn.com/v4/letter/j/898d66/32.png) [@Joost\_Cassee](https://forum.ansible.com/u/Joost_Cassee)\
**Post date:** [July 8, 2013, 3:05pm UTC](https://forum.ansible.com/t/mak/13081/10 "2013-07-08T15:05:01Z")

</div>

Hi Mark,

Did you mean you are including playbooks in the role/x/tasks/main.yml  
file? If I include a playbook, Ansible complains: "ERROR: tasks is not  
a legal parameter in an Ansible task or handler".

If you meant to say you have little task lists, do you also find you  
are mirroring the same structure in the handlers directory?

Regards,  
Joost

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [July 8, 2013, 3:33pm UTC](https://forum.ansible.com/t/mak/13081/11 "2013-07-08T15:33:53Z")

</div>

No, what he means is from roles/x/tasks/main.yml you can do

“-include: other.yml”

and have another task file pulled in.

You can’t include playbooks from tasks.

---

<div class="post-metadata">

**Author:** ![Mark\_Maas](https://avatars.discourse-cdn.com/v4/letter/m/7c8e57/32.png) [@Mark\_Maas](https://forum.ansible.com/u/Mark_Maas)\
**Post date:** [July 8, 2013, 6:03pm UTC](https://forum.ansible.com/t/mak/13081/12 "2013-07-08T18:03:10Z")

</div>

Yes that exactly:

inside roles/x/tasks/main.yml:

- include ssh.yml
- include: smtp.yml
- include: ssh.yml  
etc.

And those yml’s are right next to the main.yml

All look like this:

---

<div class="post-metadata">

**Author:** ![Joost\_Cassee](https://avatars.discourse-cdn.com/v4/letter/j/898d66/32.png) [@Joost\_Cassee](https://forum.ansible.com/u/Joost_Cassee)\
**Post date:** [July 8, 2013, 7:38pm UTC](https://forum.ansible.com/t/mak/13081/13 "2013-07-08T19:38:51Z")

</div>

Hi Mark,

Detailed explanation. I would have expected the ssh, smtp, etc. tasks  
to be usable outside of the x role, and thus pulled from outside the  
role directory. Probably imprinting from Puppet and the like. 🙂  
Interesting to see another perspective. I'll try it out.

Thanks!

Regards,  
Joost

---

<div class="post-metadata">

**Author:** ![Mark\_Maas](https://avatars.discourse-cdn.com/v4/letter/m/7c8e57/32.png) [@Mark\_Maas](https://forum.ansible.com/u/Mark_Maas)\
**Post date:** [July 9, 2013, 4:43am UTC](https://forum.ansible.com/t/mak/13081/14 "2013-07-09T04:43:20Z")

</div>

I wanted the site.yml to be “pretty” when you look at it.

Therefore I do not want to “clutter” it with:

roles:

- ssh
- smtp
- ntp
- apache
- banner
- motd
- defaultbash
- dir\_colors
- etc,
- etc.

see? That list can become way too long for my taste.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [July 10, 2013, 1:06am UTC](https://forum.ansible.com/t/mak/13081/15 "2013-07-10T01:06:56Z")

</div>

Yes, totally, that’s it!

You can easily have a common.yml that includes a lot of tiny task files that all live in the same task directory.

---

<div class="post-metadata">

**Author:** ![max2](https://avatars.discourse-cdn.com/v4/letter/m/e480ec/32.png) [@max2](https://forum.ansible.com/u/max2)\
**Post date:** [August 20, 2013, 3:57pm UTC](https://forum.ansible.com/t/mak/13081/16 "2013-08-20T15:57:06Z")

</div>

Hey guys, we’ve configured aws through configuration, and everything is working fine. We’re trying to now load/deploy all the code to our aws servers. We were told to use main.yml, but when we run this command:

ansible-playbook -vvv ~/repos/edx-configuration/playbooks/roles/edxapp/tasks/main.yml -e ‘region=eu-west-1 key=edX name=edx-configuration’

We are getting:

ERROR: file is not a legal parameter in an Ansible Playbook

Would you have any suggestions?

Thanks very much,

Max

---

<div class="post-metadata">

**Author:** ![James\_Cammarata1](https://avatars.discourse-cdn.com/v4/letter/j/d26b3c/32.png) [@James\_Cammarata1](https://forum.ansible.com/u/James_Cammarata1)\
**Post date:** [August 20, 2013, 8:15pm UTC](https://forum.ansible.com/t/mak/13081/17 "2013-08-20T20:15:23Z")

</div>

It looks like you’re trying to run the role directly, which is not correct. You should create a playbook and include the roles there. For example:

---

<div class="post-metadata">

**Author:** ![Savvas\_Nicholas](https://avatars.discourse-cdn.com/v4/letter/s/9f8e36/32.png) [@Savvas\_Nicholas](https://forum.ansible.com/u/Savvas_Nicholas)\
**Post date:** [August 20, 2013, 10:40pm UTC](https://forum.ansible.com/t/mak/13081/18 "2013-08-20T22:40:14Z")

</div>

Are there any pre-written playbooks that will configure the site as intended across all the 12 AWS instances that were created using the Cloudformation method mentioned here: [https://github.com/edx/configuration/wiki/AWS-Installation](https://github.com/edx/configuration/wiki/AWS-Installation)?

---

<div class="post-metadata">

**Author:** ![max2](https://avatars.discourse-cdn.com/v4/letter/m/e480ec/32.png) [@max2](https://forum.ansible.com/u/max2)\
**Post date:** [August 21, 2013, 11:55am UTC](https://forum.ansible.com/t/mak/13081/19 "2013-08-21T11:55:43Z")

</div>

@jamescammarata I’m not sure I understand what you mean, could you please elaborate further?

---

<div class="post-metadata">

**Author:** ![James\_Cammarata1](https://avatars.discourse-cdn.com/v4/letter/j/d26b3c/32.png) [@James\_Cammarata1](https://forum.ansible.com/u/James_Cammarata1)\
**Post date:** [August 21, 2013, 12:30pm UTC](https://forum.ansible.com/t/mak/13081/20 "2013-08-21T12:30:30Z")

</div>

Please review the getting started documentation on our site as well as the playbook documentation here:

[http://www.ansibleworks.com/docs/playbooks.html](http://www.ansibleworks.com/docs/playbooks.html)

Roles are typically a group of related commands, and do not contain the full information required to run a play.
