On 5 December 2013 20:48, Kahlil Hodgson <[email protected]>wrote:

> I wonder if merging could be handled explicitly with a jinja filter,
> say, something like:
>
>     mysql: prod_mysql | merge(default_mysql)
>
> That way the merging would be explicit and encapsulated in the playbook.
>

I agree it would be a good feature if merging dicts or not could be set
more granullary.

About your example, I think this is already possible with Jinja2, something
like

{{ default_mysql.update(prod_mysql) }}

But allowing merges or not per variable, instead of inventory wide as per
ansible.cfg is more difficult. Code wise, the merging happens (or not)
when loading the inventory, before a host is contacted for the first time,
and before the playbook starts to run, so this example can't be implemented
(at least without a major update to ansible.)

I think going that path would add a lot of unnecessary complexity, e.g. the
following ugly example :)


GROUP: all
mysql:
  _meta_merge: True
  server: some_default_value1
  port: some_default_value2

GROUP: production
mysql:
  _meta_merge: True
  port: some_default_value3

GROUP: production
mysql:
  _meta_merge: True
  port: some_default_value4



Serge


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

Reply via email to