Feature #1858

Add resources based on a Hash

Added by David Escala over 3 years ago. Updated 9 months ago.

Status:Closed Start date:01/09/2009
Priority:Normal Due date:
Assignee:Luke Kanies % Done:

0%

Category:newfeature
Target version:-
Affected Puppet version:0.24.7 Branch:
Keywords:
Votes: 0

Description

Create resources from a Hash, in fact the syntax for a resource looks like a Ruby Hash already. The idea is to use it in conjuntion with external_nodes or with functions which return hashes.

I’ll explain it with an en example.

With this external_nodes yaml

parameters:
  symlinks:
    /tmp/one:
       ensure: target1
    /tmp/two:
       ensure: target2
classes:
- foo_class

and a this manifest:

file {$symlinks:}

Puppet should create two file resources /tmp/one and /tmp/two.

This feature allows the creation of simple resources, like a list of users or cron jobs, outside puppet.

puppet_hash_resources.patch - This does the job (2.6 kB) David Escala, 01/09/2009 01:21 pm

1858.patch (3.3 kB) Lluis Gili, 07/07/2011 05:24 am

History

Updated by James Turnbull over 3 years ago

  • Category set to newfeature
  • Status changed from Unreviewed to Needs Decision
  • Assignee set to Luke Kanies
  • Target version set to 0.25.0

Luke?

Updated by Luke Kanies over 3 years ago

I like the idea, and the implementation is certainly simple.

I’m a bit concerned about reusing the existing ‘file{$hash:}’ syntax, but I can’t really think of a better way to do it.

Is this something you specifically want to attach to External Nodes, or would you be comfortable having a separate connection to this system? I’ve been wanting to find a simple way to generate resources through some kind of query interface, and it would look pretty much like this. Given that we don’t have a plan for this yet, though, denying this patch in favor of a nonexistent plan seems like a bad idea.

Anyone else have an opinion?

Updated by David Escala over 3 years ago

I would be comfortable having a separate connection to an “external resources” subsystem.

Updated by Luke Kanies about 3 years ago

  • Status changed from Needs Decision to Rejected
  • Target version changed from 0.25.0 to 2.6.0

So, I think you’ll get almost exactly what you want when the Resource class is moved to the Indirector, which should happen in 0.26.

Given that I think it’ll get you where you want, I don’t think it makes sense to add this to 0.25.

Updated by Lluis Gili 10 months ago

  • File 1858.patch added
  • Status changed from Rejected to Re-opened
  • Target version changed from 2.6.0 to 2.7.x

Hi, I attach the patch updated for 2.7.x branch. There’s a better way to do this without this patch? If so, sorry to re-open

Updated by Lluis Gili 10 months ago

  • Status changed from Re-opened to Closed

I found create_resources function which adds same functionality than this patch. I close this (although I prefer the patch syntax)

for the first example, what was:

file {$symlinks:}

with create_resources function is:

create_resources(file, $symlinks)

Updated by James Turnbull 9 months ago

  • Target version deleted (2.7.x)

Also available in: Atom PDF