This type of stuff will get easier in the future, not quite for 0.25, but
possibly the next release.
Ralsh is an option if you just want to 'do' stuff without a context.
For example, you can easily use it to add a user, but you have no semantics
about the user and you don't have anything that ensures the user is present
in the future.
Exporting and Collecting gives you more of that right now, as the collected
resource will be applied every time.
I'm not personally a big fan of CSV as a format for restful services, but at
some point it should be fairly trivial to push things like users in some
microformat.
You might be able to use your custom function/template to write a file and
then include that file later. I believe because of the timing of the
parsing/compiling, this might not work. It might be something that you can
get to work on the second pass. I might be wrong, I haven't really worked
on the language much at all yet.
Seems like an interesting experiment, not sure I fully understand the
motives, but let me know if it works :/
Andrew
On Fri, Aug 22, 2008 at 8:59 PM, Blake Barnett <[EMAIL PROTECTED]> wrote:
>
>
> On Aug 22, 2008, at 10:55 AM, Francois Deppierraz wrote:
>
> >
> > Adam Jacob wrote:
> >
> >> If what you are trying to do is eval some puppet code, literally, I'm
> >> totally unclear as to what the purpose of that would be.
> >
> > Yes, I'm trying to eval puppet code.
> >
> > In fact this eval function is only part of another function I'm trying
> > to hack.
> >
> > The goal is to generate ressources in Puppet from a REST webservice
> > returning CSV data.
> >
> > For example, imagine you have a webservice like that listing all
> > your users:
> >
> > uid;gecos;password
> > francois;Francois Deppierraz;1234
> > john;John Doe;5678
> >
> > Based on that, I want to generate the following ressource
> > *dynamically*.
> >
> > user {"francois":
> > ensure => present,
> > gecos => "Francois Deppierraz",
> > password => "1234",
> > }
> >
> > user {"john":
> > ensure => present,
> > gecos => "John Doe",
> > password => "5678",
> > }
> >
> > The current usage of this function is:
> >
> > class blah {
> > csv_template "http://mydb/users" "my-user-template.erb"
> > }
> >
> > From there, a ressource is created for each line (except the header)
> > using the ERB template.
> >
> > The only piece I'm missing is how to feed those ressources back into
> > Puppet. I hope this makes my use case a bit clearer.
>
> This is what ralsh does, though you'd need to run it via SSH or
> something to get resources on specific machines. Check it out at:
> git/puppet/bin/ralsh
>
> For the dynamic REST query behavior... are you using the new
> indirector code interface? Doing this the "old" way would be much
> harder. As far as creating the resource dynamically you'll want to
> look at the parser code to see how it builds resources, for example:
> Puppet::Parser::Resource.new(hash)
>
> -Blake
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Puppet Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/puppet-dev?hl=en
-~----------~----~----~----~------~----~------~--~---