Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I speed up my puppet module development-testing cycle?

Tags:

vagrant

puppet

I'm looking for some best practices on how to increase my productivity when writing new puppet modules. My workflow looks like this right now:

  1. vagrant up
  2. Make changes/fixes
  3. vagrant provision
  4. Find mistakes/errors, GOTO 2

After I get through all the mistakes/errors I do:

  1. vagrant destroy
  2. vagrant up
  3. Make sure everything is working
  4. commit my changes

This is too slow... how can i make this workflow faster?
I am in denial about writing tests for puppet. What are my other options?

like image 896
olore Avatar asked Feb 07 '14 01:02

olore


2 Answers

  • cache your apt/yum repository on your host with the vagrant-cachier plugin
  • use profile –evaltrace to find where you loose time on full provisioning
  • use package base distribution :
    • eg: rvm install ruby-2.0.0 vs a pre-compiled ruby package created with fpm
    • avoid a "wget the internet and compile" approach
    • this will probably make your provisioning more reproducible and speedier.
  • don't code modules
    • try reusing some from the forge/github/...
    • note that it can be against my previous advice
  • if this is an option, upgrade your puppet/ruby version
  • iterate and prevent full provisioning
    • vagrant up
    • vagrant provision
    • modify manifest/modules
    • vagrant provision
    • modify manifest/modules
    • vagrant provision
    • vagrant destroy
    • vagrant up
    • launch server-spec
  • minimize typed command
    • launch command as you modify your files
    • you can perhaps setup guard to launch lint/test/spec/provision as you save
    • you can also send notifications from guest to host machine with vagrant-notify
  • test without actually provisioning in vagrant
    • rspec puppet (ideal when refactoring modules)
  • test your provisioning instead of manual checking
    • stop vagrant ssh-ing checking if service is running or a config has a given value
    • launch server-spec
    • take a look at Beaker
  • delegate running the test to your preferred ci server (jenkins, travis-ci,...)
  • if you are a bit fustrated by puppet... take a look at ansible
    • easy to setup (no ruby to install/compile)
    • you can select portion of stuff you want to run with tags
    • you can share the playbooks via synched folders and run ansible in the vagrant box locally (no librairian-puppet to launch)

update : after discussion with @garethr, take a look at his last presentation about guard.

like image 198
mestachs Avatar answered Nov 16 '22 04:11

mestachs


I recommand using language-puppet. It comes with a command line tool (puppetresources) that can compute catalogs on your computer and let you examine them. It has a few useful features that can't be found in Puppet :

  • It is really fast (6 times faster on a single catalog, something like 50 times on many catalogs)
  • It tracks where each resource was defined, and what was the "class stack" at that point, which is really handy when you have duplicate resources
  • It automatically checks that the files you refer to exist
  • It is stricter than Puppet (breaks on undefined variables for example)
  • It let you print to standard output the content of any file, which is useful for developing complex templates

The only caveat is that it only works with "modern" Puppet practices. For example, require is not implemented. It also only works on Linux.

like image 32
bartavelle Avatar answered Nov 16 '22 05:11

bartavelle