FAQ
Hi Michael,

Has this ever been implemented ?

With Vault especially, it seems like a sensible pattern to have a separate
encrypted file in vars/ for credentials, next to main.yml

Having to specify include_vars or vars_files explicitly each time feels a
little clumsy : shouldn't one reasonably expect a directory named "vars" to
have some magic meaning and consider all of its contents automatically
(like group_vars and inventory directories do) ?

Since vars/ also doesn't serve as a default path for include_vars in role
tasks (AFAIK, you have to explicitly say "../vars/xxx.yml"), technically it
might as well be just "roles/x/vars.yml", right ?


Variable files can't do includes, no.

vars_files is the way to go.


On Tue, May 21, 2013 at 9:45 AM, benno joy <benn...@gmail.com
<javascript:>> wrote:
Actually i meant vars_files: but i guess even that doesn't seem to work
in vars/main.yml, so i guess the only option might be to include it in your
main playbook. but i will wait for others to also comment.

Thanks,
Benno


On Tue, May 21, 2013 at 6:34 PM, <jsch...@juniper.net <javascript:>>
wrote:
Thank you, but this does not seem to be working. Are you sure it's
"var_files" and not "vars_files"? I've tried a number of options, with and
without quotes around the filename, but no luck.

I do appreciate your help, thank you again!

On Tuesday, May 21, 2013 8:48:57 AM UTC-4, benno joy wrote:

Could you try this for now

in main.yml
var_files:
- "../var1.yml"

Also i guess a feature request has been made for automatic inclusion of
all vars file, so down the line this should work without manual inclusion.

- Benno




On Tue, May 21, 2013 at 6:01 PM, wrote:

I'm using roles for template building, and would like to understand
the use the of the vars directory a bit more. From the docs, I see that
ansible will automatically pick up roles/{role}/vars/main.yml. But let's
say that I want to put multiple var files in the vars directory. Is there
a way to tell ansible to pickup not only main.yml, but every other *.yml
file in that directory as well?

Thank you!

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

For more options, visit https://groups.google.com/groups/opt_out.

--
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 <javascript:>.
For more options, visit https://groups.google.com/groups/opt_out.

--
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 <javascript:>.
For more options, visit https://groups.google.com/groups/opt_out.



--
Michael DeHaan <mic...@ansibleworks.com <javascript:>>
CTO, AnsibleWorks, Inc.
http://www.ansibleworks.com/
--
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-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/77d45732-6092-4310-8861-eb18f6c53bb6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Michael DeHaan at Jul 2, 2014 at 10:16 pm
    "Has this ever been implemented?"

    Vault yes, the feature about multiple files in vars/ automatically being
    loaded? No.

    Files in vars/ are not all automatically loaded - it would absolutely break
    certain classes of playbooks, so we can't/won't go there.

    include_vars is a good solution from the task file for specific files.



    On Wed, Jul 2, 2014 at 12:10 PM, Renaud Guerin wrote:

    Hi Michael,

    Has this ever been implemented ?

    With Vault especially, it seems like a sensible pattern to have a separate
    encrypted file in vars/ for credentials, next to main.yml

    Having to specify include_vars or vars_files explicitly each time feels a
    little clumsy : shouldn't one reasonably expect a directory named "vars"
    to have some magic meaning and consider all of its contents automatically
    (like group_vars and inventory directories do) ?

    Since vars/ also doesn't serve as a default path for include_vars in role
    tasks (AFAIK, you have to explicitly say "../vars/xxx.yml"), technically it
    might as well be just "roles/x/vars.yml", right ?


    Variable files can't do includes, no.

    vars_files is the way to go.

    On Tue, May 21, 2013 at 9:45 AM, benno joy wrote:

    Actually i meant vars_files: but i guess even that doesn't seem to work
    in vars/main.yml, so i guess the only option might be to include it in your
    main playbook. but i will wait for others to also comment.

    Thanks,
    Benno

    On Tue, May 21, 2013 at 6:34 PM, wrote:

    Thank you, but this does not seem to be working. Are you sure it's
    "var_files" and not "vars_files"? I've tried a number of options, with and
    without quotes around the filename, but no luck.

    I do appreciate your help, thank you again!

    On Tuesday, May 21, 2013 8:48:57 AM UTC-4, benno joy wrote:

    Could you try this for now

    in main.yml
    var_files:
    - "../var1.yml"

    Also i guess a feature request has been made for automatic inclusion
    of all vars file, so down the line this should work without manual
    inclusion.

    - Benno




    On Tue, May 21, 2013 at 6:01 PM, wrote:

    I'm using roles for template building, and would like to understand
    the use the of the vars directory a bit more. From the docs, I see that
    ansible will automatically pick up roles/{role}/vars/main.yml. But let's
    say that I want to put multiple var files in the vars directory. Is there
    a way to tell ansible to pickup not only main.yml, but every other *.yml
    file in that directory as well?

    Thank you!

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

    For more options, visit https://groups.google.com/groups/opt_out.

    --
    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.
    For more options, visit https://groups.google.com/groups/opt_out.

    --
    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.
    For more options, visit https://groups.google.com/groups/opt_out.



    --
    Michael DeHaan <mic...@ansibleworks.com>

    CTO, AnsibleWorks, Inc.
    http://www.ansibleworks.com/

    --
    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-project+unsubscribe@googlegroups.com.
    To post to this group, send email to ansible-project@googlegroups.com.
    To view this discussion on the web visit
    https://groups.google.com/d/msgid/ansible-project/77d45732-6092-4310-8861-eb18f6c53bb6%40googlegroups.com
    <https://groups.google.com/d/msgid/ansible-project/77d45732-6092-4310-8861-eb18f6c53bb6%40googlegroups.com?utm_medium=email&utm_source=footer>
    .
    For more options, visit https://groups.google.com/d/optout.
    --
    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-project+unsubscribe@googlegroups.com.
    To post to this group, send email to ansible-project@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CA%2BnsWgx47zF0b8RNmqqZGW1S4Y0o%3DQkUthU6WxLJzQ6PBw%3DTsQ%40mail.gmail.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupansible-project @
postedJul 2, '14 at 4:10p
activeJul 2, '14 at 10:16p
posts2
users2

2 users in discussion

Michael DeHaan: 1 post Renaud Guerin: 1 post

People

Translate

site design / logo © 2021 Grokbase