Extends variables in yaml

582 views
Skip to first unread message

Micael Malta

unread,
Dec 8, 2014, 12:46:56 PM12/8/14
to ansible...@googlegroups.com
I have a question: How to extends variables:

In group_vars/all, i have a variable config and i want in host_vars/my_server to extend it

How to do that?

Toshio Kuratomi

unread,
Dec 10, 2014, 10:47:00 AM12/10/14
to ansible...@googlegroups.com

Could you give an example of what you want to achieve?I think that would make your question clearer.

Thanks,
Toshio

--
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/53f7058b-ce6a-49f9-83b6-d1ff1f83791d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mirko Friedenhagen

unread,
Dec 10, 2014, 12:41:47 PM12/10/14
to ansible-project
What about:

Extending a list? In Python-Syntax
group_vars/all.yml: packages = ["a", "b"]
host_vars/host1.yml: packages.extend(["c", "d"])

Endresult for packages for host1: ["a", ""b", "c", "d"]

Is this possible in yaml?




Regards Mirko
--
http://illegalstateexception.blogspot.com/
https://github.com/mfriedenhagen/ (http://osrc.dfm.io/mfriedenhagen)
https://bitbucket.org/mfriedenhagen/
> https://groups.google.com/d/msgid/ansible-project/CAG9juEqz9-o0T%2BL%2BctaqPxf7%3DA29%3DCC5N6q8dran5K51z3ffxg%40mail.gmail.com.

Brian Coca

unread,
Dec 10, 2014, 1:06:16 PM12/10/14
to ansible...@googlegroups.com
ansible is not a programming language, variables are really pretty
static, they can be overwritten but not really modified.

If you want to create a new list that has the contents of 2 other
lists, look at the set theory filters:

with_items: packages|union(extra_packages)

that should give you what you want.

--
Brian Coca
Reply all
Reply to author
Forward
0 new messages