# Variables in Playbooks

**URL:** <https://forum.ansible.com/t/variables-in-playbooks/11532>\
**Category:** Ansible Project\
**Created:** [May 11, 2012, 11:00am UTC](https://forum.ansible.com/t/variables-in-playbooks/11532 "2012-05-11T11:00:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Art\_Zemon](https://avatars.discourse-cdn.com/v4/letter/a/3da27b/32.png) [@Art\_Zemon](https://forum.ansible.com/u/Art_Zemon)\
**Post date:** [May 11, 2012, 11:00am UTC](https://forum.ansible.com/t/variables-in-playbooks/11532/1 "2012-05-11T11:00:12Z")

</div>

Hello,

I have a couple of questions about variables in playbooks.

1. Is there a way to get to ansible variables in a playbook? Trying to get to the IPv4 address, neither {{ ansible\_eth0.ipv4.address }} nor $ansible\_eth0.ipv4.address work. The {{}} syntax yields the MAC address. The $ syntax gets passed through to the command unchanged (did not match anything at all).
2. StuddlyCaps don’t seem to work but I don’t see anything in the vars section of the docs about acceptable variable names. E.g., I can use “customer\_email” but not “customerEmail”. The latter gets passed through to the command as $customerEmail instead of having the value substituted.

Thanks,  
– Art Z.

---

<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 11, 2012, 11:07am UTC](https://forum.ansible.com/t/variables-in-playbooks/11532/2 "2012-05-11T11:07:06Z")

</div>

Which version of Ansible?

---

<div class="post-metadata">

**Author:** ![Jeroen\_Hoekx](https://avatars.discourse-cdn.com/v4/letter/j/ba9def/32.png) [@Jeroen\_Hoekx](https://forum.ansible.com/u/Jeroen_Hoekx)\
**Post date:** [May 11, 2012, 11:26am UTC](https://forum.ansible.com/t/variables-in-playbooks/11532/3 "2012-05-11T11:26:36Z")

</div>

Hi Art,

> Is there a way to get to ansible variables in a playbook? Trying to get to  
> the IPv4 address, neither {{ ansible\_eth0.ipv4.address }} nor  
> $ansible\_eth0.ipv4.address work. The {{}} syntax yields the MAC address. The  
> $ syntax gets passed through to the command unchanged (did not match  
> anything at all).

The correct syntax is:  
'''  
&nbsp;&nbsp;tasks:  
&nbsp;&nbsp;- action: shell echo ${ansible\_eth0.ipv4.address}  
'''

That example works all right for me on devel.

> StuddlyCaps don't seem to work but I don't see anything in the vars section  
> of the docs about acceptable variable names. E.g., I can use  
> "customer\_email" but not "customerEmail". The latter gets passed through to  
> the command as $customerEmail instead of having the value substituted.

There is an explicit .lower() on the variable name. It was there in  
the original commit. Do you know why, Michael or Seth?  
[https://github.com/ansible/ansible/commit/5ed2b894d9344ae10ecea37f1376dae00b3d15e3](https://github.com/ansible/ansible/commit/5ed2b894d9344ae10ecea37f1376dae00b3d15e3)

Greetings,

Jeroen

---

<div class="post-metadata">

**Author:** ![Art\_Zemon](https://avatars.discourse-cdn.com/v4/letter/a/3da27b/32.png) [@Art\_Zemon](https://forum.ansible.com/u/Art_Zemon)\
**Post date:** [May 11, 2012, 11:52am UTC](https://forum.ansible.com/t/variables-in-playbooks/11532/4 "2012-05-11T11:52:40Z")

</div>

Michael: devel, pulled yesterday morning (sorry for forgetting to mention it)

Jeroen: thanks. I’ll use that syntax.

– Art Z.

---

<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 11, 2012, 12:10pm UTC](https://forum.ansible.com/t/variables-in-playbooks/11532/5 "2012-05-11T12:10:13Z")

</div>

Yes, there was an email about not calling Jinja2 everywhere I think yesterday.

{{ }} etc

It’s only valid in templates now.

---

<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 11, 2012, 12:11pm UTC](https://forum.ansible.com/t/variables-in-playbooks/11532/6 "2012-05-11T12:11:13Z")

</div>

> There is an explicit .lower() on the variable name. It was there in  
> the original commit. Do you know why, Michael or Seth?  
> [https://github.com/ansible/ansible/commit/5ed2b894d9344ae10ecea37f1376dae00b3d15e3](https://github.com/ansible/ansible/commit/5ed2b894d9344ae10ecea37f1376dae00b3d15e3)

I’m fine with removing it, I bet it came over from the yum function.

I don’t think we need it.
