Announce: A REPL for the puppet language

90 views
Skip to first unread message

Corey Osman

unread,
Feb 19, 2016, 6:04:39 PM2/19/16
to Puppet Users
Hi,

I created a REPL for the puppet language this week. This is something that has been lacking for quite some time.  



Install: gem install puppet-repl
bash$ prepl


It is currently at version 0.0.1 but is still very functional. 


MacBook-Pro-2~ % prepl
Puppet Version: 4.2.2
Puppet Repl Version: 0.0.1
Created by: NWOps <co...@nwops.io>
Type "exit", "functions", "types", "reset", "help" for more information.

>> $hostname = 'node123.company.com'
>> $hostname =~ /node/
 => true
>> split($hostname, 'node')
 => ["", "123.company.com"]
>> ['/tmp/test1', '/tmp/test2'].each |String $file_path| { file{$file_path: ensure => present}}
 => ["/tmp/test1", "/tmp/test2"]
>> ['/tmp/test1', '/tmp/test2'].each |String $file_path| { file{$file_path: ensure => present}}
 => Evaluation Error: Error while evaluating a Resource Statement, Duplicate declaration: File[/tmp/test1] is already declared in file :1; cannot redeclare at line 1 at line 1:57
>>



Corey



Rich Burroughs

unread,
Feb 19, 2016, 6:26:23 PM2/19/16
to Puppet Users
Wow! I can't wait to have a look at this.


Rich
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/5D035294-B3D9-450B-A0E3-4882858B2008%40nwops.io.
For more options, visit https://groups.google.com/d/optout.

Lowe Schmidt

unread,
Feb 20, 2016, 7:02:06 AM2/20/16
to puppet...@googlegroups.com
What version of ruby are you targeting?

Running Ruby 2.3.0 gave me this.

´´´
/Users/lsc/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/puppet-3.8.5/lib/puppet/vendor/safe_yaml/lib/safe_yaml/syck_node_monkeypatch.rb:42:in `<top (required)>': uninitialized constant Syck (NameError)
from /Users/lsc/.rbenv/versions/2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/lsc/.rbenv/versions/2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/lsc/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/puppet-3.8.5/lib/puppet/vendor/safe_yaml/lib/safe_yaml.rb:197:in `<module:YAML>'
from /Users/lsc/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/puppet-3.8.5/lib/puppet/vendor/safe_yaml/lib/safe_yaml.rb:132:in `<top (required)>'
from /Users/lsc/.rbenv/versions/2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/lsc/.rbenv/versions/2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/lsc/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/puppet-3.8.5/lib/puppet/vendor/require_vendored.rb:4:in `<top (required)>'
from /Users/lsc/.rbenv/versions/2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/lsc/.rbenv/versions/2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/lsc/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/puppet-3.8.5/lib/puppet/vendor.rb:40:in `require_libs'
from /Users/lsc/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/puppet-3.8.5/lib/puppet/vendor.rb:53:in `load_vendored'
from /Users/lsc/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/puppet-3.8.5/lib/puppet.rb:174:in `<module:Puppet>'
from /Users/lsc/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/puppet-3.8.5/lib/puppet.rb:29:in `<top (required)>'
from /Users/lsc/.rbenv/versions/2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:127:in `require'
from /Users/lsc/.rbenv/versions/2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:127:in `rescue in require'
from /Users/lsc/.rbenv/versions/2.3.0/lib/ruby/site_ruby/2.3.0/rubygems/core_ext/kernel_require.rb:40:in `require'
from /Users/lsc/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/puppet-repl-0.0.1/lib/puppet-repl/cli.rb:1:in `<top (required)>'
from /Users/lsc/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/puppet-repl-0.0.1/lib/puppet-repl.rb:1:in `require_relative'
from /Users/lsc/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/puppet-repl-0.0.1/lib/puppet-repl.rb:1:in `<top (required)>'
from /Users/lsc/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/puppet-repl-0.0.1/bin/prepl:3:in `require_relative'
from /Users/lsc/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/puppet-repl-0.0.1/bin/prepl:3:in `<top (required)>'
from /Users/lsc/.rbenv/versions/2.3.0/bin/prepl:22:in `load'
from /Users/lsc/.rbenv/versions/2.3.0/bin/prepl:22:in `<main>'
´´´

--
Lowe Schmidt | +46 723 867 157

Gareth Rushgrove

unread,
Feb 20, 2016, 12:12:52 PM2/20/16
to puppet...@googlegroups.com
On 20 February 2016 at 12:01, Lowe Schmidt <m...@loweschmidt.se> wrote:
> What version of ruby are you targeting?
>
> Running Ruby 2.3.0 gave me this.
>

Ruby 2.2.0+ isn't a supported runtime for Puppet 3.x I don't think:

https://docs.puppetlabs.com/guides/platforms.html

For the 3.8 series you might need to stick with Ruby 2.1.x or below,
or update to Puppet 4. Although that may or may not with the issue in
this case.

Gareth

> ´´´
> https://groups.google.com/d/msgid/puppet-users/CAC-wWcROypnxZn%2BHGAdqd_BQxTtzSw0SosYwUC07C1FRgEb1mg%40mail.gmail.com.
>
> For more options, visit https://groups.google.com/d/optout.



--
Gareth Rushgrove
@garethr

devopsweekly.com
morethanseven.net
garethrushgrove.com

Gary L. Greene, Jr.

unread,
Feb 20, 2016, 3:01:44 PM2/20/16
to puppet...@googlegroups.com
On Saturday, February 20, 2016 5:12:36 PM PST Gareth Rushgrove wrote:
> On 20 February 2016 at 12:01, Lowe Schmidt <m...@loweschmidt.se> wrote:
> > What version of ruby are you targeting?
> >
> > Running Ruby 2.3.0 gave me this.
>
> Ruby 2.2.0+ isn't a supported runtime for Puppet 3.x I don't think:
>
> https://docs.puppetlabs.com/guides/platforms.html
>
> For the 3.8 series you might need to stick with Ruby 2.1.x or below,
> or update to Puppet 4. Although that may or may not with the issue in
> this case.
>
> Gareth

In fact, anything up to Ruby 2.1.3 will work for the 3.8 series. Above that,
you’ll get stack traces when running Puppet, that if I recall were in the
puppet fact storage code... Forced me to revert my environment’s version of
Ruby.

--
Gary L. Greene, Jr.

Q. Why is this so clumsy?
A. The trick is to use Perl's strengths rather than its weaknesses.
-- Larry Wall in <82...@jpl-devvax.JPL.NASA.GOV>

Originated from: urd.tolharadys.net
11:55am up 16:15, 3 users, load average: 1.13, 1.68, 1.61

signature.asc

Corey Osman

unread,
Feb 20, 2016, 9:10:10 PM2/20/16
to Puppet Users
The gem requires puppet 3.8+.  So whatever version of ruby puppet runs on is supported by puppet-repl. 

If you want to run ruby 2.3 I would suggest using puppet 4.3+.   But I am not even sure puppet 4.3 runs on ruby 2.3 yet. 

Jo Rhett

unread,
Feb 20, 2016, 10:26:45 PM2/20/16
to puppet...@googlegroups.com
Puppet 4 is only supported with the all-in-one packaged Ruby. You don’t choose your own.

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

-- 
Jo Rhett
Net Consonance : net philanthropy to improve open source and internet projects.

Lowe Schmidt

unread,
Feb 21, 2016, 5:34:34 AM2/21/16
to puppet...@googlegroups.com
I have the AIO package, but I havent pruned my rbenv environments. My bad 

--
Lowe Schmidt | +46 723 867 157

Gareth Rushgrove

unread,
Feb 21, 2016, 6:26:45 AM2/21/16
to puppet...@googlegroups.com
On 21 February 2016 at 03:26, Jo Rhett <jrh...@netconsonance.com> wrote:
> Puppet 4 is only supported with the all-in-one packaged Ruby. You don’t
> choose your own.
>

Just to clarify, Puppet 4 will happily run from a gem on a ruby
outside the AIO package. This is actually very common in the case of
unit testing modules on Travis of Jenkins for instance.

The language from the documentation states "the Ruby version bundled
with puppet-agent is the recommended version. Other versions are not
recommended and we make no guarantees about their performance with
Puppet."

Given that, using the combinations from the puppet-agent package is a
useful guide in cases where you really can't use the AIO for some
reason: https://docs.puppetlabs.com/puppet/4.3/reference/about_agent.html.
ie. if you're using Puppet 4.3.2 then you can have some level of
confidence that Ruby 2.1.8 is a good choice (mainly because that's
what is getting lots of testing as per the table on
https://docs.puppetlabs.com/guides/platforms.html.

Gareth
> https://groups.google.com/d/msgid/puppet-users/FBE71E5F-0EF8-479E-957F-B7845573AE9D%40netconsonance.com.
>
> For more options, visit https://groups.google.com/d/optout.



--

Felix Frank

unread,
Feb 21, 2016, 3:18:39 PM2/21/16
to puppet...@googlegroups.com
Cool, thanks for sharing!

I will mark this and try to check it out "soon".

Cheers,
Felix
Reply all
Reply to author
Forward
0 new messages