Re: [Puppet Users] Embedding Puppet / using it as a library / api

2012-09-14 Thread robert.gstoehl

>
>
>
> I don't know how you can use defined types from pure ruby there might be 
> a way but for native ones you can use them: 
>
>   pkg = Puppet::Type.type(:package).new(:name => "bash").provider 
>   pkg.update 
>
> updates bash. 
>

Fiddled with something like that - it even worked with a custom type "repo" 
in ruby as in the book "pro puppet":

  Puppet::Type.newtype(:repo) do
@doc = "Manage repos"  
ensurable  

newparam(:source) do
...

  Puppet::Type.type(:repo).provide(:git) do
desc "Provides Git support for the repo provider"
commands :gitcmd => "git"
def create
...
  repo = Puppet::Resource.new( 
:repo, "puppet",
:parameters => {
  :source => "git://github.com/puppetlabs/puppet.git",
  :path => "/tmp/puppet",
...

  catalog = Puppet::Resource::Catalog.new("localhost")
  catalog.add_resource(repo)
  transaction = catalog.apply
  transaction.report

I'm doing something wrong with the catalog (it doesn't apply anything) but 
I'll get that sorted out probably, need to look at 
lib/puppet/application/resource.rb.
Still having the impression that I'm using internal apis -> probably just 
have to live with the fact, that they might break some day.

Thanks,

Robert

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/puppet-users/-/MWdfKsAfJQ8J.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.



Re: [Puppet Users] Embedding Puppet / using it as a library / api

2012-09-14 Thread Robert Gstoehl
On Fri, Sep 14, 2012 at 12:21 PM, R.I.Pienaar  wrote:
>
>
> - Original Message -
>> From: "Robert Gstoehl" 
>> To: puppet-users@googlegroups.com
>> Sent: Friday, September 14, 2012 11:12:14 AM
>> Subject: Re: [Puppet Users] Embedding Puppet / using it as a library / api
>>
>> On Fri, Sep 14, 2012 at 11:59 AM, Robert Gstoehl
>>  wrote:
>> > On Fri, Sep 14, 2012 at 11:52 AM, R.I.Pienaar 
>> > wrote:
>> >>
>> >>
>> >> - Original Message -
>> >>> From: "robert.gstoehl" 
>> >>> To: puppet-users@googlegroups.com
>> >>> Sent: Friday, September 14, 2012 10:25:51 AM
>> >>> Subject: [Puppet Users] Embedding Puppet / using it as a library
>> >>> / api
>> >>>
>> >>> Hey there,
>> >>>
>> >>> I'm thinking about reusing custom types from existing puppet
>> >>> infrastructure in standalone (ruby)
>> >>> applications.
>> >>>
>> >>> Example -> Custom Type for a "storage pool" consisting of volume
>> >>> groups,
>> >>> logical volumes, drbd resources, filesystems, nfs export... you
>> >>> get
>> >>> the idea.
>> >>>
>> >>> Suppose that we have already defined this type in the form of a
>> >>> puppet module / custom type.
>> >>
>> >> do you mean a type written in ruby or a defined type like 'define
>> >> foo' in
>> >> a .pp file?
>> >
>> > Thinking about a custom .pp type currently. Although does it make
>> > that
>> > much of a difference?
>> >
>> > I mean code wise, both are Puppet::Resource - thingys at the end of
>> > the day, aren't they?
>>
>> Fingers faster then brainz -> .rb types of course. Need to have some
>> coffee, sorry ;)
>
> I don't know how you can use defined types from pure ruby there might be
> a way but for native ones you can use them:
>
>   pkg = Puppet::Type.type(:package).new(:name => "bash").provider
>   pkg.update
>
> updates bash.

Fiddled with something like that but got the impression that I was
using internal apis (which might break some day).
Than I read about the new "faces" and tried that one:



Currently I'm a bit confused about

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.



Re: [Puppet Users] Embedding Puppet / using it as a library / api

2012-09-14 Thread R.I.Pienaar


- Original Message -
> From: "Robert Gstoehl" 
> To: puppet-users@googlegroups.com
> Sent: Friday, September 14, 2012 11:12:14 AM
> Subject: Re: [Puppet Users] Embedding Puppet / using it as a library / api
> 
> On Fri, Sep 14, 2012 at 11:59 AM, Robert Gstoehl
>  wrote:
> > On Fri, Sep 14, 2012 at 11:52 AM, R.I.Pienaar 
> > wrote:
> >>
> >>
> >> - Original Message -
> >>> From: "robert.gstoehl" 
> >>> To: puppet-users@googlegroups.com
> >>> Sent: Friday, September 14, 2012 10:25:51 AM
> >>> Subject: [Puppet Users] Embedding Puppet / using it as a library
> >>> / api
> >>>
> >>> Hey there,
> >>>
> >>> I'm thinking about reusing custom types from existing puppet
> >>> infrastructure in standalone (ruby)
> >>> applications.
> >>>
> >>> Example -> Custom Type for a "storage pool" consisting of volume
> >>> groups,
> >>> logical volumes, drbd resources, filesystems, nfs export... you
> >>> get
> >>> the idea.
> >>>
> >>> Suppose that we have already defined this type in the form of a
> >>> puppet module / custom type.
> >>
> >> do you mean a type written in ruby or a defined type like 'define
> >> foo' in
> >> a .pp file?
> >
> > Thinking about a custom .pp type currently. Although does it make
> > that
> > much of a difference?
> >
> > I mean code wise, both are Puppet::Resource - thingys at the end of
> > the day, aren't they?
> 
> Fingers faster then brainz -> .rb types of course. Need to have some
> coffee, sorry ;)

I don't know how you can use defined types from pure ruby there might be
a way but for native ones you can use them:

  pkg = Puppet::Type.type(:package).new(:name => "bash").provider 
  pkg.update

updates bash.

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.



Re: [Puppet Users] Embedding Puppet / using it as a library / api

2012-09-14 Thread Robert Gstoehl
On Fri, Sep 14, 2012 at 11:59 AM, Robert Gstoehl
 wrote:
> On Fri, Sep 14, 2012 at 11:52 AM, R.I.Pienaar  wrote:
>>
>>
>> - Original Message -
>>> From: "robert.gstoehl" 
>>> To: puppet-users@googlegroups.com
>>> Sent: Friday, September 14, 2012 10:25:51 AM
>>> Subject: [Puppet Users] Embedding Puppet / using it as a library / api
>>>
>>> Hey there,
>>>
>>> I'm thinking about reusing custom types from existing puppet
>>> infrastructure in standalone (ruby)
>>> applications.
>>>
>>> Example -> Custom Type for a "storage pool" consisting of volume groups,
>>> logical volumes, drbd resources, filesystems, nfs export... you get
>>> the idea.
>>>
>>> Suppose that we have already defined this type in the form of a
>>> puppet module / custom type.
>>
>> do you mean a type written in ruby or a defined type like 'define foo' in
>> a .pp file?
>
> Thinking about a custom .pp type currently. Although does it make that
> much of a difference?
>
> I mean code wise, both are Puppet::Resource - thingys at the end of
> the day, aren't they?

Fingers faster then brainz -> .rb types of course. Need to have some
coffee, sorry ;)

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.



Re: [Puppet Users] Embedding Puppet / using it as a library / api

2012-09-14 Thread Robert Gstoehl
On Fri, Sep 14, 2012 at 11:52 AM, R.I.Pienaar  wrote:
>
>
> - Original Message -
>> From: "robert.gstoehl" 
>> To: puppet-users@googlegroups.com
>> Sent: Friday, September 14, 2012 10:25:51 AM
>> Subject: [Puppet Users] Embedding Puppet / using it as a library / api
>>
>> Hey there,
>>
>> I'm thinking about reusing custom types from existing puppet
>> infrastructure in standalone (ruby)
>> applications.
>>
>> Example -> Custom Type for a "storage pool" consisting of volume groups,
>> logical volumes, drbd resources, filesystems, nfs export... you get
>> the idea.
>>
>> Suppose that we have already defined this type in the form of a
>> puppet module / custom type.
>
> do you mean a type written in ruby or a defined type like 'define foo' in
> a .pp file?

Thinking about a custom .pp type currently. Although does it make that
much of a difference?

I mean code wise, both are Puppet::Resource - thingys at the end of
the day, aren't they?

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.



Re: [Puppet Users] Embedding Puppet / using it as a library / api

2012-09-14 Thread R.I.Pienaar


- Original Message -
> From: "robert.gstoehl" 
> To: puppet-users@googlegroups.com
> Sent: Friday, September 14, 2012 10:25:51 AM
> Subject: [Puppet Users] Embedding Puppet / using it as a library / api
> 
> Hey there,
> 
> I'm thinking about reusing custom types from existing puppet
> infrastructure in standalone (ruby)
> applications.
> 
> Example -> Custom Type for a "storage pool" consisting of volume groups,
> logical volumes, drbd resources, filesystems, nfs export... you get
> the idea.
> 
> Suppose that we have already defined this type in the form of a
> puppet module / custom type.

do you mean a type written in ruby or a defined type like 'define foo' in
a .pp file?

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.



[Puppet Users] Embedding Puppet / using it as a library / api

2012-09-14 Thread robert.gstoehl


Hey there,

I'm thinking about reusing custom types from existing puppet infrastructure in 
standalone (ruby)
applications.

Example -> Custom Type for a "storage pool" consisting of volume groups,
logical volumes, drbd resources, filesystems, nfs export... you get the idea.

Suppose that we have already defined this type in the form of a puppet module / 
custom type.

Instead of reimplementing this stuff in an external library / script I'd
rather reuse the puppet module, and as an additional goody, use some of the
puppet datatypes / features (reporting differences in system state, noop, 
transaction, ...)

So far I stumbled upon some different concepts in puppet land which might make
this possible:

puppet internal dsl

puppet faces

rest api

One requirement would be the "standalone" aspect. While interacting with this
hypthetical storage pool, I'd rather not do network roundtrips to the puppet
master, as I prefer robustness over freshness in this case.

I looked somewhat into the faces variant but coldn't find a way to construct a
catalog without talking to the master.

And by using just the Faces[:resource, ..] - stuff I'm missing some
other nice features of the catalog.

Any ideas / snippets / tips / tutorials to get me started?

Thanks alot in advance

Cheers

Robert


-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/puppet-users/-/CaaCOxX_UK4J.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.