Custom Search

SUBSCRIBE

SUBSCRIBE : 300 + Free Video Tutorials Programming (Python, golang, Julia), DevOps

Wednesday, June 3, 2015

How to test puppet code : Test Spec error and Compilation error

1)
#sudo apt-get install ruby
#sudo apt-get install ruby-dev


2)
http://bundler.io/
#sudo gem install bundler

3)
Clone puppet project from github and goto cloned folder and run.


#bundle install
OR
#bundle install --gemfile=Gemfile


* This will install all the dependencies defined in the "Gemfile"
* Use `bundle show [gemname]` to see where a bundled gem is installed.
* https://puppetlabs.com/blog/the-next-generation-of-puppet-module-testing

4)
Run spec tests in a clean fixtures directory

#rake spec
OR
#bundle exec rake spec

* Run "#rake" to get help page

5)
Check that your Puppet manifest conform to the style guide
#bundle exec rake lint
#bundle exec rake lint | grep ERROR

6)
To check for compilation errors and view a log of events.
#puppet apply --noop --debug manifests/init.pp



1 comment:

  1. $ bundle exec rake
    rake beaker # Run beaker acceptance tests
    rake beaker_nodes # List available beaker nodesets
    rake build # Build puppet module package
    rake clean # Clean a built module package
    rake coverage # Generate code coverage information
    rake help # Display the list of available rake tasks
    rake lint # Run puppet-lint
    rake metadata # Validate metadata.json file
    rake module:bump # Bump module version to the next patch
    rake module:bump:major # Bump module version to the next MAJOR version
    rake module:bump:minor # Bump module version to the next MINOR version
    rake module:bump:patch # Bump module version to the next PATCH version
    rake module:bump_commit # Bump version and git commit
    rake module:clean # Runs clean again
    rake module:dependency[module_name,version] # Set specific module dependency version
    rake module:push # Push module to the Puppet Forge
    rake module:release # Release the Puppet module, doing a clean, build, tag, push, bump_commit and git push
    rake module:tag # Git tag with the current module version
    rake spec # Run spec tests in a clean fixtures directory
    rake spec_clean # Clean up the fixtures directory
    rake spec_prep # Create the fixtures directory
    rake spec_standalone # Run spec tests on an existing fixtures directory
    rake syntax # Syntax check Puppet manifests and templates
    rake syntax:hiera # Syntax check Hiera config files
    rake syntax:manifests # Syntax check Puppet manifests
    rake syntax:templates # Syntax check Puppet templates
    rake travis # Travis CI Tests
    rake vagrant_destroy # Vagrant VM shutdown and fixtures cleanup
    rake vagrant_up[manifest,hostname] # Vagrant VM power up and provision
    rake validate # Check syntax of Ruby files and call :syntax and :metadata / Validate puppet manifests, ERB templ...

    ReplyDelete