there was a but in 1.8 with hash_merge, have you tried in 1.9?

On Wed, May 13, 2015 at 1:35 PM, Michail Alexakis <[email protected]> wrote:
> Hello Adam,
>
> I allready have set it to "merge", actually that's the reason i posted this
> question (because it doesn't seem to merge).
> Have you tried the example above? I tested it under ansible==1.8.4. Maybe i
> am missing something obvious.
>
>
>
> On Wednesday, May 13, 2015 at 7:41:11 PM UTC+3, Adam Hamsik wrote:
>>
>> Have a look at hash_behaviour in ansible.cfg and set it to merge. But be
>> aware that it's usually sign of bad design.
>>
>> On Tuesday, May 12, 2015 at 7:56:52 PM UTC+2, Michail Alexakis wrote:
>>>
>>> Hello,
>>>
>>> any answer to this question?
>>>
>>>
>>> On Friday, May 8, 2015 at 9:51:13 PM UTC+3, Michail Alexakis wrote:
>>>>
>>>> Hello list,
>>>>
>>>> I have encountered some not expected results when i tried to include
>>>> (with include_vars) multiple var files in the beginning of a play.
>>>>
>>>> I normally use the "merge" hash behavior (ansible.cfg) because it seems
>>>> more natural to me: i usually have highly nested variable dicts
>>>> and i wish to add or override just parts of them based on the group/host
>>>> hierarchy.
>>>>
>>>> Now, i tried to include some variables in the beginning of a play (at
>>>> "pre_tasks" phase, but i don't thing it's relevant), to override some
>>>> parts of existing dicts with piece of information regarding other
>>>> present hosts (e.g. IPs for standby servers). It didn't succeed.
>>>>
>>>> Consider the following example:
>>>>
>>>> ```
>>>> # vars file: play_vars/baz-a.yml
>>>> baz:
>>>>   a: 1
>>>> ```
>>>>
>>>> ```
>>>> # vars file: play_vars/baz-b.yml
>>>> baz:
>>>>   b: 2
>>>> ```
>>>>
>>>> ```
>>>> ---
>>>> # playbook: play.yml
>>>> - hosts: all
>>>>
>>>>   pre_tasks:
>>>>   - include_vars: play_vars/baz-a.yml
>>>>   - include_vars: play_vars/baz-b.yml
>>>>
>>>>   tasks:
>>>>   - debug: var=baz
>>>> ```
>>>>
>>>> When playing play.yml, i get:  "baz": {"b": 2} while expecting "baz":
>>>> {"a":1, "b":2}.
>>>> Is this normal? Note, this is happening under hash_behavior=merge.
>>>>
>>>>
>>>>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/0e9f27ef-d22a-4108-882d-2263c9bb38d6%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.



-- 
Brian Coca

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAJ5XC8mbfFvs%3DmNZ6JUJ4Xn3LTFvF2wZVYATFFak%3DV3FRySpeQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to