# Playbook reflections.

**URL:** <https://forum.ansible.com/t/playbook-reflections/11597>\
**Category:** Ansible Project\
**Created:** [June 1, 2012, 7:27pm UTC](https://forum.ansible.com/t/playbook-reflections/11597 "2012-06-01T19:27:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brad\_Olson](https://avatars.discourse-cdn.com/v4/letter/b/779978/32.png) [@Brad\_Olson](https://forum.ansible.com/u/Brad_Olson)\
**Post date:** [June 1, 2012, 7:27pm UTC](https://forum.ansible.com/t/playbook-reflections/11597/1 "2012-06-01T19:27:05Z")

</div>

I just finished another take at describing a modest infrastructure in  
playbooks. Trying to keep simplicity at the forefront, I found myself  
wishing for a couple modest enhancements:

1. Process vars\_files BEFORE vars. Use case is I set a lot of defaults  
in common vars file, then want to interplate those values into more  
specific variables, for example:

in vars file:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;app\_base\_path: /usr/local/src/someapp

in setup:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;subapp\_base\_path: ${app\_base\_path}/subapps/myapp

2. Conditional imports for tasks files. Use case is where I want to  
apply a bundle of tasks based on distro or some other choice that  
lends itself more to interpolation than hosts/groups filters, for  
example:

- include: - [ "tasks/${facter\_operatingsystem}\_webserver.yml", "vars/  
defaultos\_webserver.yml" ]

---

<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:** [June 1, 2012, 7:43pm UTC](https://forum.ansible.com/t/playbook-reflections/11597/2 "2012-06-01T19:43:32Z")

</div>

> I just finished another take at describing a modest infrastructure in  
> playbooks. Trying to keep simplicity at the forefront, I found myself  
> wishing for a couple modest enhancements:
> 
> 1. Process vars\_files BEFORE vars. Use case is I set a lot of defaults  
> in common vars file, then want to interplate those values into more  
> specific variables, for example:

People like to use vars to define path prefixes, so this isn’t going to happen.

> 1. Conditional imports for tasks files. Use case is where I want to  
> apply a bundle of tasks based on distro or some other choice that  
> lends itself more to interpolation than hosts/groups filters, for  
> example:
> 
> - include: - [ “tasks/${facter\_operatingsystem}\_webserver.yml”, “vars/  
> defaultos\_webserver.yml” ]

This seems like it drives playbooks towards gross levels of complexity where you don’t know  
what they will do.

Auditability (vs alternatives) was a major design goal, so I’m quite opposed to this kind of automagic.

This is where you should define groups of hosts and target the right plays at the right groups.

–Michael

---

<div class="post-metadata">

**Author:** ![Brad\_Olson](https://avatars.discourse-cdn.com/v4/letter/b/779978/32.png) [@Brad\_Olson](https://forum.ansible.com/u/Brad_Olson)\
**Post date:** [June 5, 2012, 1:45pm UTC](https://forum.ansible.com/t/playbook-reflections/11597/3 "2012-06-05T13:45:50Z")

</div>

> \> 1. Process vars\_files BEFORE vars.
> 
> People like to use vars to define path prefixes, so this isn't going to happen.

That's a good hint. I can accomplish my use case that way.

> \> - include: - [ "tasks/${facter\_operatingsystem}\_webserver.yml", "vars/  
> \> defaultos\_webserver.yml" ]
> 
> This seems like it drives playbooks towards gross levels of complexity where you don't know  
> what they will do.
> 
> Auditability (vs alternatives) was a major design goal, so I'm quite opposed to this kind of automagic.

I appreciate you holding the ground against complexity--even when I'm  
the one who is asking for it :).

Still, this complexity already exists for vars files. Seems like here  
I'm just asking for some parity in tasks files. You're right that  
groups could be used to accomplish this, but then I ask, can't groups  
also accomplish what conditional vars\_file imports do? Why the  
difference?

---

<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:** [June 5, 2012, 9:08pm UTC](https://forum.ansible.com/t/playbook-reflections/11597/4 "2012-06-05T21:08:49Z")

</div>

We are not going to break backwards compat for this, sorry.

-- Michael
