{"id":22313308,"url":"https://github.com/nwops/puppet-debug","last_synced_at":"2025-07-29T10:32:32.161Z","repository":{"id":57664940,"uuid":"73010188","full_name":"nwops/puppet-debug","owner":"nwops","description":"Puppet functions to invoke the puppet-debugger during development and testing of puppet code","archived":false,"fork":false,"pushed_at":"2020-08-04T15:59:09.000Z","size":40,"stargazers_count":7,"open_issues_count":2,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-16T17:40:50.760Z","etag":null,"topics":["debugger","puppet"],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nwops.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-11-06T18:25:29.000Z","updated_at":"2022-05-08T16:43:22.000Z","dependencies_parsed_at":"2022-09-14T21:41:06.697Z","dependency_job_id":null,"html_url":"https://github.com/nwops/puppet-debug","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nwops%2Fpuppet-debug","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nwops%2Fpuppet-debug/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nwops%2Fpuppet-debug/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nwops%2Fpuppet-debug/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nwops","download_url":"https://codeload.github.com/nwops/puppet-debug/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228006334,"owners_count":17854995,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["debugger","puppet"],"created_at":"2024-12-03T22:06:56.058Z","updated_at":"2024-12-03T22:06:56.841Z","avatar_url":"https://github.com/nwops.png","language":"Ruby","readme":"[![Build Status](https://travis-ci.org/nwops/puppet-debugger-module.svg?branch=master)](https://travis-ci.org/nwops/puppet-debugger-module)\n\n# Puppet Debug\nThis module contains a function called `debug::break()` and is for use with the\n[puppet-debugger gem](https://github.com/nwops/puppet-debugger).\n\nThe function is used for starting the puppet debugger from inside the puppet code.\n\nWhy is this important?  Puppet code is getting more complex and in order to understand\nthe code you need to get inside the compiler look around at the variables, scope and\navailable functions.  \n\nThe debugger is extremely helpful in understanding the puppet language and your puppet code.\nThink ruby pry but for puppet code.  \n\nThe function will inject the scope, node and environment data into the debugger\nallowing you to poke around to see variables, functions, facts, classes, and resources defined in the current scope.\n\n## Requirements\nEnsure you have installed the puppet-debugger gem `gem install puppet-debugger`\nor place this in your Gemfile `gem 'puppet-debugger', '\u003e= 0.4'` for your puppet module.\n\nThis also requires puppet 3.8+ with future parser enabled.\n\nYou will also want to include this module in your fixtures file if using for rspec-puppet\nunit testing.\n\n```\ndebug:\n   repo: https://github.com/nwops/puppet-debug\n```\n\n## Usage\n**DO NOT RUN THIS ON YOUR PUPPET SERVER OR IN PRODUCTION**\n\nPlanes will fall out of the sky, and kittens will die.  Do you really want that?\nAlthough there is a safety mechanism to prevent the this function from being called\nunder a daemonized puppet run so it is not all that bad.  \n\nIn order to start the puppet-debugger from within code just place the `debug::break()`\nfunction inside your manifest code where you want the scope to be injected.\nThis will automatically call the debugger `whereami` command and show where in the code\nthe `debug::break()` function was called from.  This makes it obvious where in the code\nyou are evaluating from.  This gives you the ability to step through your code.  To goto\nthe next iteration just use the `exit` command and the compiler will continue to compile where it previously left of.\n\nYou can access variables just as you would when writing puppet code.  So once inside\nthe debugger session type `$some_var_name`\n\nExample:\n\n```puppet\nclass debugger::debugger_test(\n  $var1 = 'value1',\n  $var2 = ['value1', 'value2', 'value3']\n)\n{\n  # dummy resources so we can show list of resources\n  file{'/tmp/test.txt': ensure =\u003e present, mode =\u003e '0755'}\n  service{'httpd': ensure =\u003e running}\n\n  # how to find values with an empheral scope\n  $var2.each | String $item | {\n    file{\"/tmp/${item}\": ensure =\u003e present}\n    debug::break({'run_once' =\u003e true})\n  }\n  debug::break({'run_once' =\u003e true})\n  if $var1 == 'value1' {\n    debug::break({'run_once' =\u003e true})\n  }\n}\n```\n\nExample Debugger session when inside the each block.  Notice the item variable.\n\n```ruby\nRuby Version: 2.3.1\nPuppet Version: 4.7.0\nPuppet Debugger Version: 0.4.0\nCreated by: NWOps \u003ccorey@nwops.io\u003e\nType \"exit\", \"functions\", \"vars\", \"krt\", \"whereami\", \"facts\", \"resources\", \"classes\",\n     \"play\", \"classification\", \"reset\", or \"help\" for more information.\n\n          8:   service{'httpd': ensure =\u003e running}\n          9:\n         10:   # how to find values with an empheral scope\n         11:   $var2.each | String $item | {\n         12:     file{\"/tmp/${item}\": ensure =\u003e present}\n      =\u003e 13:     debug::break({'run_once' =\u003e false})\n         14:   }\n         15:   debug::break({'run_once' =\u003e false})\n         16:   if $var1 == 'value1' {\n         17:     debug::break({'run_once' =\u003e false})\n         18:   }\n1:\u003e\u003e $item\n =\u003e \"value1\"\n\u003e\u003e\n```\n\nIf using with rspec-puppet, only the facts you define in your test suite will be present in the debugger.\n\nFor more information on how to use the puppet debugger please refer to the [documentation](https://github.com/nwops/puppet-debugger)\n\n## Troubleshooting\nThis module and puppet-debugger gem are very new, there will be bugs.  Please\nfile them at [puppet-debugger gem](https://github.com/nwops/puppet-debugger/issues).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnwops%2Fpuppet-debug","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnwops%2Fpuppet-debug","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnwops%2Fpuppet-debug/lists"}