I think your filter plugin could be more easily written: hash_a.update(hash_b)
perhaps? If you send in a pull request, this seems reasonable to have as a core filter. I'd probably call it 'update' if I'm correct on the above, which I think I am. If not, perhaps "merge". On Fri, Oct 24, 2014 at 6:08 PM, Evgeny Goldin <[email protected]> wrote: > Not really. Python doesn't allow to merge two hashes using "{{ env1 + env2 > }}". Here's what worked for me: > > playbooks/filter_plugins/filters.py: > > ------------------------------------------------ > def merge( hash_a, hash_b ): > return dict(hash_a.items() + hash_b.items()); > > class FilterModule( object ): > def filters( self ): > return { 'merge' : merge } > ------------------------------------------------ > > and then: > > environment: "{{ env1 | merge( env2 ) }}" > > > On Friday, August 1, 2014 3:14:11 PM UTC+2, Michael DeHaan wrote: >> >> So that's a thing already with {{ dict1 + dict2 }}? >> >> Nice. >> >> >> >> >> On Fri, Aug 1, 2014 at 8:53 AM, Brian Coca <[email protected]> wrote: >> >>> dict1 + dict2 >>> >>> I also have an update to 'set theory' that will allow you to do >>> dict1|union(dict2) >>> >>> >>> -- >>> 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/CADn%2BHswCwhz%2B7c%2Bn8f2jdRm0-1% >>> 2BDjp6Rqrt%2BgYyXThTauGfMNg%40mail.gmail.com >>> <https://groups.google.com/d/msgid/ansible-project/CADn%2BHswCwhz%2B7c%2Bn8f2jdRm0-1%2BDjp6Rqrt%2BgYyXThTauGfMNg%40mail.gmail.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 [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/5bbe2eda-80db-438a-b5a8-0eef1561df98%40googlegroups.com > <https://groups.google.com/d/msgid/ansible-project/5bbe2eda-80db-438a-b5a8-0eef1561df98%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 [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/CA%2BnsWgyUrfpT4KWar%3DjDrv%2BRDmemW1a3Ga4Kdio-oMd0ywHWSw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
