Using YAML ansible-playbook -e EXTRA_VARS

392 views
Skip to first unread message

Paulo Gabriel Poiati

unread,
Feb 11, 2015, 11:56:32 AM2/11/15
to ansible...@googlegroups.com
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.

Matt Martz

unread,
Feb 11, 2015, 11:58:52 AM2/11/15
to ansible...@googlegroups.com
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.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CABqSV%3D%2BucfK91wekdR5hB7p%2BQf1zvXaYE3XOYLzjqCCOG4ndMg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.



--
Matt Martz
@sivel
sivel.net

Paulo Gabriel Poiati

unread,
Feb 11, 2015, 12:21:01 PM2/11/15
to ansible...@googlegroups.com
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 ##############

---
foo: 10

############# OUTPUT ################

PLAY [test] *******************************************************************

GATHERING FACTS ***************************************************************
ok: [testserver]

TASK: [command echo {{ foo | mandatory }}] ************************************
fatal: [testserver] => One or more undefined variables: 'foo' is undefined

FATAL: all hosts have already failed -- aborting

PLAY RECAP ********************************************************************
           to retry, use: --limit @/Users/poiati/site.retry

testserver                 : ok=1    changed=0    unreachable=1    failed=0

J Hawkesworth

unread,
Feb 11, 2015, 4:34:42 PM2/11/15
to ansible...@googlegroups.com
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.

Paulo Gabriel Poiati

unread,
Feb 11, 2015, 11:43:23 PM2/11/15
to ansible...@googlegroups.com
This is exactly the problem, thank you so much. I think the ansible-playbook help needs some documentation improvement.

--
You received this message because you are subscribed to a topic in the Google Groups "Ansible Project" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ansible-project/XpcGvejde_g/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ansible-proje...@googlegroups.com.

To post to this group, send email to ansible...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages