# included task vars

**URL:** <https://forum.ansible.com/t/included-task-vars/11559>\
**Category:** Ansible Project\
**Created:** [May 19, 2012, 2:45am UTC](https://forum.ansible.com/t/included-task-vars/11559 "2012-05-19T02:45:37Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Matthew\_Williams](https://avatars.discourse-cdn.com/v4/letter/m/a3d4f5/32.png) [@Matthew\_Williams](https://forum.ansible.com/u/Matthew_Williams)\
**Post date:** [May 19, 2012, 2:45am UTC](https://forum.ansible.com/t/included-task-vars/11559/1 "2012-05-19T02:45:37Z")

</div>

When trying to get various groups of tasks working nicely from a master playbook… I find the following problem (this is for slapd+ssl):

# slapd-install.yaml

- hosts: all  
vars:  
openssl: ../openssl/  
tasks:
- include: tasks/install.yaml
- include: tasks/configure.yaml
- include: ${openssl}/tasks/setup-cn.yaml cn=${service.slapd.fqdn}
- include: ${openssl}/tasks/upload-ca.yaml cn=${service.slapd.fqdn}
- include: ${openssl}/tasks/genkey.yaml cn=${service.slapd.fqdn}
- include: ${openssl}/tasks/gencsr.yaml cn=${service.slapd.fqdn}

In the context of the playbook, I have what the openssl tasks call the $cn in a different var ($service.slapd.fqdn). I can’t find a way to pass that var on to the tasks as $cn. Even nicer would be if I could simply assign vars from vars:

- hosts: all

vars:  
openssl: ../openssl/  
cn: ${service.slapd.fqdn}  
tasks:

- include: tasks/install.yaml
- include: tasks/configure.yaml
- include: ${openssl}/tasks/setup-cn.yam
- include: ${openssl}/tasks/upload-ca.yaml
- include: ${openssl}/tasks/genkey.yaml
- include: ${openssl}/tasks/gencsr.yaml

Is there a reason why we would _not_ want to template the values in these contexts?

---

<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:** [May 19, 2012, 3:32am UTC](https://forum.ansible.com/t/included-task-vars/11559/2 "2012-05-19T03:32:23Z")

</div>

Sorry, I am not understanding. Perhaps a case of having too much data and not being able to sort out what part of this is a feature request and what part of this is a symptom.

Can you summarize what the problem you are seeing is?

–Michael

---

<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:** [May 19, 2012, 11:47am UTC](https://forum.ansible.com/t/included-task-vars/11559/3 "2012-05-19T11:47:57Z")

</div>

> Is there a reason why we would \*not\* want to template the values in these  
> contexts?

Being able to use vars inside of vars\_files/includes seems like  
something someone may try to do. I'm fine with making that possible.

---

<div class="post-metadata">

**Author:** ![Matthew\_Williams](https://avatars.discourse-cdn.com/v4/letter/m/a3d4f5/32.png) [@Matthew\_Williams](https://forum.ansible.com/u/Matthew_Williams)\
**Post date:** [May 19, 2012, 2:07pm UTC](https://forum.ansible.com/t/included-task-vars/11559/4 "2012-05-19T14:07:51Z")

</div>

Great! I’ll make it so.

---

<div class="post-metadata">

**Author:** ![Matthew\_Williams](https://avatars.discourse-cdn.com/v4/letter/m/a3d4f5/32.png) [@Matthew\_Williams](https://forum.ansible.com/u/Matthew_Williams)\
**Post date:** [May 19, 2012, 2:27pm UTC](https://forum.ansible.com/t/included-task-vars/11559/5 "2012-05-19T14:27:57Z")

</div>

Question, though. Will doing this break or alter this functionality:  
[http://ansible.github.com/playbooks2.html#conditional-execution](http://ansible.github.com/playbooks2.html#conditional-execution)

?

---

<div class="post-metadata">

**Author:** ![Matthew\_Williams](https://avatars.discourse-cdn.com/v4/letter/m/a3d4f5/32.png) [@Matthew\_Williams](https://forum.ansible.com/u/Matthew_Williams)\
**Post date:** [May 19, 2012, 2:37pm UTC](https://forum.ansible.com/t/included-task-vars/11559/6 "2012-05-19T14:37:33Z")

</div>

“this” being allowing:

vars:  
foo: ${bar}

For the purpose of “aliasing” one var for another. Maybe you were only suggesting allowing this:

tasks:

- include: tasks/foo.yaml foo=${bar}

Which shouldn’t cause any problems.

---

<div class="post-metadata">

**Author:** ![Matthew\_Williams](https://avatars.discourse-cdn.com/v4/letter/m/a3d4f5/32.png) [@Matthew\_Williams](https://forum.ansible.com/u/Matthew_Williams)\
**Post date:** [May 19, 2012, 2:43pm UTC](https://forum.ansible.com/t/included-task-vars/11559/7 "2012-05-19T14:43:51Z")

</div>

> “this” being allowing:
> 
> vars:  
> foo: ${bar}
> 
> For the purpose of “aliasing” one var for another.

I’m pretty sure allowing the above is going to break stuff… so I’m going to drop that idea.

> Maybe you were only suggesting allowing this:
> 
> tasks:
> 
> - include: tasks/foo.yaml foo=${bar}
> 
> Which shouldn’t cause any problems.

_this_ actually already works, but I was tricked ( 😉 ) into thinking it wasn’t. I’ll start a new thread on that issue.
