Code Monkey home page Code Monkey logo

puppet-repl-module's Introduction

Build Status

Puppet Repl

This module contains a function start_repl and is for use with the puppet-repl gem.

The function is used for starting the puppet repl from inside the puppet code.

The function will inject the scope, node and environment data into the repl and will allow you to poke around to see variables, functions, facts, classes, and resources defined in the current scope.

NOTICE: This module has been deprecated by the nwops/debug module, Please see https://github.com/nwops/puppet-debug

Requirements

Ensure you have installed the puppet-repl gem gem install puppet-repl or place this in your Gemfile gem 'puppet-repl', '>= 0.3' for your puppet module.

This also requires puppet 3.8+ with future parser enabled.

You will also want to include this module in your fixtures file if using for rspec-puppet unit testing.

repl:
   repo: https://github.com/nwops/puppet-repl-module

Usage

DO NOT RUN THIS ON YOUR PUPPET SERVER OR IN PRODUCTION

Planes will fall out of the sky, and kittens will die. Do you really want that? Although there is a safety mechanism to prevent the this function from being called under a daemonized puppet run.

In order to start the puppet-repl from within code just place the start_repl() function inside your manifest code where you want the scope to be injected. This will automatically call the repl whereami command and show where in the code the start_repl() function was called from. This makes it obvious where in the code you are evaulating from. This gives you the ability to step through your codce. To goto the next iteration just use the exit command and the compiler will continue to compile where it previously left of.

Example:

class repl::repl_test(
  $var1 = 'value1',
  $var2 = ['value1', 'value2', 'value3']
)
{
  # dummy resources so we can show list of resources
  file{'/tmp/test.txt': ensure => present, mode => '0755'}
  service{'httpd': ensure => running}

  # how to find values with an empheral scope
  $var2.each | String $item | {
    file{"/tmp/${item}": ensure => present}
    start_repl({'run_once' => true})
  }
  start_repl({'run_once' => true})
  if $var1 == 'value1' {
    start_repl({'run_once' => true})
  }
}

Example Repl session when inside the each block. Notice the item variable.

Ruby Version: 2.3.1
Puppet Version: 4.7.0
Puppet Repl Version: 0.3.3
Created by: NWOps <corey@nwops.io>
Type "exit", "functions", "vars", "krt", "whereami", "facts", "resources", "classes",
     "play", "classification", "reset", or "help" for more information.

          8:   service{'httpd': ensure => running}
          9:
         10:   # how to find values with an empheral scope
         11:   $var2.each | String $item | {
         12:     file{"/tmp/${item}": ensure => present}
      => 13:     start_repl({'run_once' => false})
         14:   }
         15:   start_repl({'run_once' => false})
         16:   if $var1 == 'value1' {
         17:     start_repl({'run_once' => false})
         18:   }
1:>> $item
 => "value1"
>>

If using with rspec-puppet, only the facts you define in your test suite will be present in the repl.

For more information on how to use the puppet repl please refer to the documentation

Troubleshooting

This module and puppet-repl gem are very new, there will be bugs. Please file them at puppet-repl gem.

puppet-repl-module's People

Contributors

logicminds avatar

Watchers

 avatar James Cloos avatar

puppet-repl-module's Issues

does not work with puppet apply -e

Although not entirely useful when using with puppet apply -e the repl function doesn't seem to work.

bundle exec puppet apply -e 'start_repl()'

or

bundle exec puppet apply test.pp

MacBook-Pro-4~/github/repl(tty|✚1…) % bundle exec puppet apply test.pp
Ruby Version: 2.3.1
Puppet Version: 4.6.0
Puppet Repl Version: 0.3.1
Created by: NWOps <[email protected]>
Type "exit", "functions", "vars", "krt", "facts", "resources", "classes",
     "play", "classification", "reset", or "help" for more information.

Error: Evaluation Error: Error while evaluating a Function Call, No such file or directory @ rb_sysopen - apply at /Users/github/repl/test.pp:1:1 on node macbook-pro-4.local

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.