GithubHelp home page GithubHelp logo

fe80 / pdk Goto Github PK

View Code? Open in Web Editor NEW

This project forked from puppetlabs/pdk

0.0 0.0 0.0 3.13 MB

The shortest path to better modules: Puppet Development Kit; Download:

Home Page: https://puppet.com/download-puppet-development-kit

License: Apache License 2.0

Shell 0.01% Ruby 99.11% PowerShell 0.09% HTML 0.79%

pdk's Introduction

pdk Build Status Appveyor Build Status Coverage Status

The Puppet Development Kit (PDK) includes key Puppet code development and testing tools for Linux, Windows, and OS X workstations, so you can install one package with the tools you need to create and validate new modules.

PDK includes testing tools, a complete module skeleton, and command line tools to help you create, validate, and run tests on Puppet modules. PDK also includes all dependencies needed for its use.

PDK includes the following tools:

Tool Description
metadata-json-lint Validates and lints metadata.json files in modules against Puppet's module metadatastyle guidelines.
pdk Command line tool for generating and testing modules
puppet-lint Checks your Puppet code against the recommendations in the Puppet Language style guide.
puppet-syntax Checks for correct syntax in Puppet manifests, templates, and Hiera YAML.
puppetlabs_spec_helper Provides classes, methods, and Rake tasks to help with spec testing Puppet code.
rspec-puppet Tests the behavior of Puppet when it compiles your manifests into a catalog of Puppet resources.
rspec-puppet-facts Adds support for running rspec-puppet tests against the facts for your supported operating systems.
puppet-debugger Provides a REPL based debugger console.

Installation

Download and install the newest package matching your platform from the download page. If you are using Windows, remember to close any open PowerShell windows.

For complete installation information, see the PDK documentation.

Basic usage

PDK can generate modules and classes, validate module metadata, style, and syntax, and run unit tests. This README contains very basic usage information---for complete usage information, see the PDK documentation.

Generate a module

Generates the basic components of a module and set up an infrastructure for testing it with PDK.

  1. Run the pdk new module command, specifying the name of the new module:
pdk new module my_module

This command asks a series of metadata questions and then generates the basic components of a new module.

Generate a class

To generate a class in your module, use the pdk new class command, specifying the name of your new class. To generate the main class of the module, which is defined in an init.pp file, give the class the same name as the module.

  1. From the command line, in your module's directory, run:
pdk new class class_name

PDK creates the new class manifest and a test file (as class_name_spec.rb) in your module's /spec/classes directory.

Generate a defined type

To generate a defined type in your module, use the pdk new defined_type command, specifying the name of your new defined type.

  1. From the command line, in your module's directory, run:
pdk new defined_type defined_type_name

PDK creates the new defined_type manifest and a test file (as defined_type_name_spec.rb) in your module's /spec/defines directory.

Generate a task

To generate a task in your module, use the pdk new task command, specifying the name of your new task.

  1. From the command line, in your module's directory, run:
pdk new task task_name

PDK creates the new task file and metadata.

Validating a module

PDK can validate the well-formedness of the module and style and syntax of its files.

  1. In the module's directory, run:
pdk validate

This command validates the metadata, Puppet code syntax and style, and Ruby syntax and style for the entire module.

Run unit tests

PDK's default template sets up rspec for Ruby-level unit testing, and rspec-puppet for catalog-level unit testing.

In the module's directory, run unit tests with:

pdk test unit

This command runs all available unit tests.

Experimental features

pdk console command

The pdk console command executes a session of the puppet debugger when inside a module and allows for exploration of puppet code. See the official puppet debugger site for more info and the official docs site here.

To use, execute pdk console from inside your module directory. You can also supply the --puppet-version or --pe-version or --puppet-dev to swap out the puppet version when using the console.

Example (from within a module):

  • pdk console --puppet-version=5
  • pdk console --pe-version=2018.1

The pdk console command will also pass through any puppet debugger arguments you wish to use.

Example:

  • pdk console --no-facterdb
  • pdk console --play https://gist.github.com/logicminds/4f6bcfd723c92aad1f01f6a800319fa4
  • pdk console -e "md5('sdfasdfasdf')" --run-once --quiet

Use pdk console -h for a further explanation of pass through arguments.

If you receive the following error you do not have the puppet-debugger gem installed.

pdk console -h
Error: Unknown Puppet subcommand 'debugger'
See 'puppet help' for help on available puppet subcommands

To fix this you will need to add the following entry to your .sync.yml file and run pdk update:

Gemfile:
  required:
    ":development":
      - gem: puppet-debugger
        version: "~> 0.14"

NOTE: The puppet-debugger gem has been added to the puppet-module-* gems, so once you get the gem update you no longer need the .sync.yml entry.

pdk bundle command

This command executes arbitrary commands in a bundler context within the module you're currently working on. Arguments to this command are passed straight through to bundler. This command is experimental and can lead to errors that can't be resolved by PDK itself.

Module Compatibility

PDK Version Compatibility: Modules created with PDK validate against and run on all Puppet and Ruby version combinations currently under maintenance (see https://docs.puppet.com/puppet/latest/about_agent.html and https://puppet.com/misc/puppet-enterprise-lifecycle)

Contributing

PDK encourages community contributions. See the CONTRIBUTING.md file for development notes.

Contact Information

To contact us with questions: [email protected]

pdk's People

Contributors

austb avatar binford2k avatar bmjen avatar chelnak avatar da-ar avatar daianamezdrea avatar david22swan avatar davidmalloncares avatar davids avatar glennsarti avatar hajee avatar hestonhoffman avatar hunner avatar jpogran avatar kenyon avatar logicminds avatar michaeltlombardi avatar mihaibuzgau avatar nabertrand avatar raphink avatar rickmonro avatar rodjek avatar rtib avatar rwaffen avatar sanfrancrisko avatar scotje avatar seanmil avatar turbodog avatar whopper avatar wmuizelaar avatar

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.