Using YAML ansible-playbook -e EXTRA_VARS

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.

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.

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 ##############

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

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