cloud-config support for append/delete

Bug #1023179 reported by Scott Moser
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
cloud-init
Fix Released
Low
Unassigned

Bug Description

As discussed at UDS-Q (http://pad.ubuntu.com/uds-q-servercloud-q-cloud-init-utils), a simple cloud-config syntax improvement would be nice:

in multi-part input, currently, you can only overwrite entries in cloud-config. Ie, if one part has:
  run-cmd:
    - apt-get install foo
 and another has:
 run-cmd:
   - apt-get install bar

 Then whichever is later will overwrite the 'run-cmd'. I'd like to do something like:
 == part 1 ==
 run-cmd:
   - apt-get install foo
 == part 2 ==
 run-cmd+:
   - apt-get install bar

Ie, the '+' would indicate append to the list or dict. Also intend to add '-' to remove.

Related branches

Scott Moser (smoser)
description: updated
Revision history for this message
Joshua Harlow (harlowja) wrote :

I wonder if there is any pypi package that already does something similar, this seems like such a common problem that surely someone else must of done something like this already, one would hope.... Ever since dictionaries were around someones been merging them...

Revision history for this message
Scott Moser (smoser) wrote : Re: [Bug 1023179] Re: cloud-config support for append/delete

On Wed, 11 Jul 2012, Joshua Harlow wrote:

> I wonder if there is any pypi package that already does something
> similar, this seems like such a common problem that surely someone else
> must of done something like this already, one would hope.... Ever since
> dictionaries were around someones been merging them...

I'm fine using someone else's merging routines. And I admit to being a
bit afraid of creating an ugly syntax here.

I was originally concerned about backwards compat, as some people probably
rely on a subsequent overriding a previous one. But if we do change
behavior, we might be able to make it a config option that could be set and
immediately applied, so that subsequent parts would use it.

Revision history for this message
Joshua Harlow (harlowja) wrote :

Agreed, creating mini-languages is worrisome for me also, it always becomes a major pain point and bugs always happen there (and it confuses people since they have to now figure out what the heck that mini-language means). I wonder if there is anyway to just let people give us code that does the merging, (via a plugin or something), instead of creating a mini-language that does something similar (but is confusing to new comers and maintainers...)

Revision history for this message
Joshua Harlow (harlowja) wrote :

Hopefully though we can reduce the code 'affected' to just this class @ https://bazaar.launchpad.net/~cloud-init-dev/cloud-init/trunk/view/head:/cloudinit/helpers.py#L182 which is now handling that type of merging if we really want to put this in (or we could say let people provide a replacement for that class via a plugin) that would let them merge differently if they wanted???

Revision history for this message
Joshua Harlow (harlowja) wrote :

This might be a good start, it would seem simple to hook this in to the merging algorithm currently being used (or just replace it).

Revision history for this message
Scott Moser (smoser) wrote :

I'm marking this as triaged and low. I've had some conversations with Joshua on this. We'd like to have some way to do it, but aren't really interested in inventing a new language.

Changed in cloud-init:
importance: Undecided → Low
status: New → Triaged
Revision history for this message
Joshua Harlow (harlowja) wrote :

 Another more pythonic way to handle this, let people plugin there own code that does dictionary merging (using a similar plugin mechanism that is already there). Then someone that wants to do this can just write some code.

Scott Moser (smoser)
Changed in cloud-init:
milestone: none → 0.7.2
Revision history for this message
Scott Moser (smoser) wrote :

fixed in trunk at revno 795.

Changed in cloud-init:
status: Triaged → Fix Committed
Revision history for this message
Scott Moser (smoser) wrote :

fixed in 0.7.2

Changed in cloud-init:
milestone: 0.7.2 → none
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Bug attachments