Hi guys,

If we're talking about implementation of new features, this should go to
ansible-devel list

Thanks!


On Fri, Dec 6, 2013 at 2:23 AM, Kahlil Hodgson <
[email protected]> wrote:

> Ergh, hit send too fast.
>
> The branch you want to look at is called 'merge-filter'.
>
> Apologies if this makes no sense because:
>
> 1. I've had a few beers,
> 2. I'm writing this on a tram,
> 3. My python skills are limited.
>
> K
>
> Kahlil (Kal) Hodgson                       GPG: C9A02289
> Head of Technology                         (m) +61 (0) 4 2573 0382
> DealMax Pty Ltd                            (w) +61 (0) 3 9008 5281
>
> Suite 1415
> 401 Docklands Drive
> Docklands VIC 3008 Australia
>
> "All parts should go together without forcing.  You must remember that
> the parts you are reassembling were disassembled by you.  Therefore,
> if you can't get them together again, there must be a reason.  By all
> means, do not use a hammer."  -- IBM maintenance manual, 1925
>
>
>
> On 6 December 2013 18:18, Kahlil Hodgson <[email protected]>
> wrote:
> > Er maybe?
> >
> > Checkout my quick implementation at
> https://github.com/tartansandal/ansible.git
> >
> > If I run the following against it
> >
> > ---
> > - name: merging like a maniac
> >   hosts: localhost
> >   connection: local
> >   vars:
> >     - foo:
> >         - a:
> >           - luck:
> >               a: c
> >               b: d
> >         - b:
> >           - luck:
> >               a: g
> >               e: f
> >     - bar:
> >         - a:
> >           - luck:
> >               z: q
> >               a: t
> >
> >     - baz: "{{ foo | merge(bar) }}"
> >
> >   tasks:
> >       - debug: var=baz
> >
> >
> > I get:
> >
> > <eric:ansible> ansible-playbook stub.yml -i hosts
> >
> > PLAY [merging like a maniac]
> **************************************************
> >
> > GATHERING FACTS
> ***************************************************************
> > ok: [localhost]
> >
> > TASK: [debug var=baz]
> *********************************************************
> > ok: [localhost] => {
> >     "baz": [
> >         {
> >             "a": [
> >                 {
> >                     "luck": {
> >                         "a": "t",
> >                         "b": "d",
> >                         "z": "q"
> >                     }
> >                 }
> >             ]
> >         },
> >         {
> >             "b": [
> >                 {
> >                     "luck": {
> >                         "a": "g",
> >                         "e": "f"
> >                     }
> >                 }
> >             ]
> >         }
> >     ]
> > }
> >
> > PLAY RECAP
> ********************************************************************
> > localhost                  : ok=2    changed=0    unreachable=0
>  failed=0
> >
> >
> >
> > Kahlil (Kal) Hodgson                       GPG: C9A02289
> > Head of Technology                         (m) +61 (0) 4 2573 0382
> > DealMax Pty Ltd                            (w) +61 (0) 3 9008 5281
> >
> > Suite 1415
> > 401 Docklands Drive
> > Docklands VIC 3008 Australia
> >
> > "All parts should go together without forcing.  You must remember that
> > the parts you are reassembling were disassembled by you.  Therefore,
> > if you can't get them together again, there must be a reason.  By all
> > means, do not use a hammer."  -- IBM maintenance manual, 1925
> >
> >
> >
> > On 6 December 2013 14:24, James Martin <[email protected]> wrote:
> >> Kahlil,
> >>
> >> Is this how you'd expect your solution to work?
> >>
> >> I'm thinking in your case you'd have a
> >>
> >> group_vars/all:
> >>
> >> default_mysql:
> >>   setting1: foo
> >>   setting2: bar
> >>   setting3: baz
> >>
> >>
> >> group_vars/prod_mysql
> >>   setting2: bip
> >>
> >>
> >> and maybe you had a role called mysql that internally used "mysql" as
> >> the variable hash?
> >>
> >> - James
> >>
> >> On Thu, Dec 5, 2013 at 2:48 PM, 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.
> >>>
> >>>
> >>> Kahlil (Kal) Hodgson                       GPG: C9A02289
> >>> Head of Technology                         (m) +61 (0) 4 2573 0382
> >>> DealMax Pty Ltd                            (w) +61 (0) 3 9008 5281
> >>>
> >>> Suite 1415
> >>> 401 Docklands Drive
> >>> Docklands VIC 3008 Australia
> >>>
> >>> "All parts should go together without forcing.  You must remember that
> >>> the parts you are reassembling were disassembled by you.  Therefore,
> >>> if you can't get them together again, there must be a reason.  By all
> >>> means, do not use a hammer."  -- IBM maintenance manual, 1925
> >>>
> >>>
> >>>
> >>> On 6 December 2013 04:17, James Martin <[email protected]> wrote:
> >>>> Thanks for the example.  Would it be crazy/possible to implement
> >>>> optional merging dependent on the hash's name?  Seems like for some
> >>>> vars you could possibly want it, in others, not.  So things that are
> >>>> in nature restrictive like sudo would be merged, and others wouldn't.
> >>>>
> >>>> something like:
> >>>>
> >>>> hash_behaviour = replace  # by default we replace all vars except
> >>>> those in merge_hashes
> >>>> merge_hashes = foo, baz, bar
> >>>>
> >>>> - James
> >>>>
> >>>> On Wed, Dec 4, 2013 at 7:43 PM, Brian Coca <[email protected]>
> wrote:
> >>>>> group_vars/all:
> >>>>> tomcat_jvm_settings:
> >>>>>  - debug=on
> >>>>>  - GCfunckymode=True
> >>>>>  - dump_heap=true
> >>>>>
> >>>>> group_vars/prod:
> >>>>> tomcat_jvm_settings:
> >>>>>   - XmxMax: 234324
> >>>>>   - XmxMin: 12342
> >>>>>
> >>>>> with merge off, i can use same settings for dev/qa/staging and
> differnt ones
> >>>>> for prod, if i had merge ON, i would have to always override the
> settings in
> >>>>> prod:
> >>>>>
> >>>>> - debug=off
> >>>>> - GCfunkymode=False
> >>>>> - dump_heap=true
> >>>>>
> >>>>>
> >>>>> but I think a better example is with user access:
> >>>>>
> >>>>> all:
> >>>>> sudoers:
> >>>>>  - devs
> >>>>>  - managers
> >>>>>  - it
> >>>>>  - releng
> >>>>>
> >>>>> staging:
> >>>>> sudoers:
> >>>>>  - managers
> >>>>>  - releng
> >>>>>  - it
> >>>>>
> >>>>> prod:
> >>>>> sudoers:
> >>>>>   -it
> >>>>>   -releng
> >>>>>
> >>>>> --
> >>>>> 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.
> >>>>
> >>>> --
> >>>> 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.
> >>>
> >>> --
> >>> 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.
> >>
> >> --
> >> 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.
>
> --
> 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.
>



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

Reply via email to