# Using YAML ansible-playbook -e EXTRA\_VARS

**URL:** <https://forum.ansible.com/t/using-yaml-ansible-playbook-e-extra-vars/17502>\
**Category:** Ansible Project\
**Created:** [February 11, 2015, 4:39pm UTC](https://forum.ansible.com/t/using-yaml-ansible-playbook-e-extra-vars/17502 "2015-02-11T16:39:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paulo\_Gabriel\_Poiati](https://avatars.discourse-cdn.com/v4/letter/p/858c86/32.png) [@Paulo\_Gabriel\_Poiati](https://forum.ansible.com/u/Paulo_Gabriel_Poiati)\
**Post date:** [February 11, 2015, 4:39pm UTC](https://forum.ansible.com/t/using-yaml-ansible-playbook-e-extra-vars/17502/1 "2015-02-11T16:39:12Z")

</div>

Hello all,

I’m struggle with this command line option. How can I use an YAML file with the `-e` option?

`$ ansilble-playbook -e /path/to/my/var.yml playbook.yml` doesn’t works.

I’m using ansible 1.8.2.

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [February 11, 2015, 4:58pm UTC](https://forum.ansible.com/t/using-yaml-ansible-playbook-e-extra-vars/17502/2 "2015-02-11T16:58:09Z")

</div>

What specifically does “doesn’t work” mean. Can you provide any further details? It may be beneficial to include a sample play and vars file for testing.

---

<div class="post-metadata">

**Author:** ![Paulo\_Gabriel\_Poiati](https://avatars.discourse-cdn.com/v4/letter/p/858c86/32.png) [@Paulo\_Gabriel\_Poiati](https://forum.ansible.com/u/Paulo_Gabriel_Poiati)\
**Post date:** [February 11, 2015, 5:21pm UTC](https://forum.ansible.com/t/using-yaml-ansible-playbook-e-extra-vars/17502/3 "2015-02-11T17:21:00Z")

</div>

Sorry Matt,

Here it is:

I’m running the command:

$ ansible-playbook -e vars.yml site.yml

############# site.yml ##############

- hosts: ‘test’

tasks:

- command: echo {{ foo | mandatory }}

############# vars.yml ##############

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [February 11, 2015, 9:34pm UTC](https://forum.ansible.com/t/using-yaml-ansible-playbook-e-extra-vars/17502/4 "2015-02-11T21:34:42Z")

</div>

I can’t test this right now but I think you need to add @ when you want the vars to be loaded from a file:  
i.e.

$ ansilble-playbook -e “@var.yml” playbook.yml

Documentation only shows example for json, but reading the text implies it would also work with yaml.

[http://docs.ansible.com/playbooks\_variables.html#passing-variables-on-the-command-line](http://docs.ansible.com/playbooks_variables.html#passing-variables-on-the-command-line)

---

<div class="post-metadata">

**Author:** ![Paulo\_Gabriel\_Poiati](https://avatars.discourse-cdn.com/v4/letter/p/858c86/32.png) [@Paulo\_Gabriel\_Poiati](https://forum.ansible.com/u/Paulo_Gabriel_Poiati)\
**Post date:** [February 12, 2015, 4:43am UTC](https://forum.ansible.com/t/using-yaml-ansible-playbook-e-extra-vars/17502/5 "2015-02-12T04:43:19Z")

</div>

This is exactly the problem, thank you so much. I think the ansible-playbook help needs some documentation improvement.
