• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Stanford Hackathon - Puppet Modules
 

Stanford Hackathon - Puppet Modules

on

  • 2,553 views

A quick intro to hacking on Puppet modules from Nan Liu and Dan Bode.

A quick intro to hacking on Puppet modules from Nan Liu and Dan Bode.

Statistics

Views

Total Views
2,553
Views on SlideShare
2,553
Embed Views
0

Actions

Likes
2
Downloads
73
Comments
0

0 Embeds 0

No embeds

Accessibility

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

Stanford Hackathon - Puppet Modules Stanford Hackathon - Puppet Modules Presentation Transcript

  • Stanford Hackathon (D|N)an - Business Development(d|n)an@puppetlabs.com | #puppet PuppetLabs - 2012
  • Overview
  • Overview
  • Puppet vs. Scripts• Abstraction• Idempotent• Declarative
  • Abstraction• Puppet packages: package { ‘sshd’: ensure => ‘present’, }• Packages commands: yum/rpm apt/deb pkgadd/pkgutil gem ...
  • Idempotent• Script: service sshd stop Stopping sshd: [ OK ] service sshd stop Stopping sshd: [FAILED]• Puppet: puppet resource service sshd ensure=stopped ... notice: /Service[sshd]/ensure: ensure changed running to stopped puppet resource service sshd ensure=stopped ...
  • Declarative Puppet internal Puppet user System state (is): Desire state (should):service sshd status service { sshd: ensure => running, } system == desire No noop? No Remedy (sync): Reportservice sshd start
  • Puppet Resource• Puppet manifest building block • file • user • package • service • ...
  • Puppet Resource• puppet resource <type> [title]
  • Puppet Manifests• package { ‘ssh’: ensure => ‘present’, } file { ‘/etc/sshd/sshd_config’: owner => ‘root’, group => ‘root’, mode => ‘0600’, source => ‘puppet:///modules/sshd/sshd_config’, require => Package[‘ssh’], } service { ‘sshd’: ensure => ‘running’, subscribe => File[‘/etc/sshd/ssd_config’], }
  • Puppet Organization manifests package { sshd:node lisa { ensure => latest, class {lisa { { } node "ssh": class ssh { }} class {lisa node "ssh": } class ssh { … } class { "ssh": } } … } } file { sshd_config: source => "puppet:///..." site.pp } files native resource (ruby) # sshd_config,v 1.81 # # sshd_config,v 1.81 This is the sshd server # This is the sshd server system-wide configuration system-wide configuration ssh::root_key { … key => "AAAA…" … } ssh module define resource (puppet)
  • Module Directories• manifests: puppet manifests (*.pp)• files: configuration file• templates: ERB template (*.erb)• lib: ruby (*.rb)• tests: puppet unit testing (*.pp)
  • Organization
  • Module Development• Syntax Check• Unit Test• Acceptance Test• Environment -> Deploy
  • Puppet Syntax• puppet parser validate • git commit hook • vim syntastic • geppetto (eclipse IDE)• puppet best practice • puppet-lint
  • Unit Test• puppet cucumber• rspec-puppet (Tim Sharpe)
  • rspec-puppet• verify resources in catalog• validate different facts• validate different parameters
  • rspec-puppet• rspec-puppet directory structure:• <module_name>/spec /classes /defines /fixtures /manifests/site.pp
  • rspec-puppet• #rspec_test/manifests/init.pp class rspec_test($message = ‘default’) { notify { $message: } }• #rspec_test/spec/rspec_test_spec.rb describe rspec_test do describe with default parameters do it { should contain_notify(default) } end describe when overriding message do let :params do {:message => override} end it { should contain_notify(override) } end end
  • Travis CI• Github integration• Invoke test on git push• Simple test matrix
  • .travis.yml• language: ruby before_script: - git clone git://github.com/puppetlabs/puppetlabs- stdlib.git spec/fixtures/modules/stdlib rvm: - 1.8.7 - 1.9.2 script: "rake spec" env: - PUPPET_VERSION=2.6.12 - PUPPET_VERSION=2.7.12 matrix: exclude: - rvm: 1.9.2 env: PUPPET_VERSION=2.6.12
  • Gemfile• source :rubygems puppetversion = ENV.key?(PUPPET_VERSION) ? "= #{ENV[PUPPET_VERSION]}" : [>= 2.7] gem puppet, puppetversion  group :test do gem rake, >= 0.9.0 gem rspec, >= 2.8.0 gem rspec-puppet, >= 0.1.1 end
  • Travis CI
  • Acceptance Testing• vagrant box • veewee (basebox) • http://vagrantbox.es• vagrant init• vagrant up• vagrant provision
  • Vagrant• config.vm.provision :puppet do |puppet| puppet.manifests_path = "manifests" puppet.manifest_file = "oneiric.pp" end• config.vm.network :hostonly, "10.0.2.15"• config.vm.share_folder("v-root", "/vagrant", ".", :nfs => true)
  • Puppet Modules• forge.puppetlabs.com• www.github.com/puppetlabs• Bring your own module!
  • Module Projects?• Module cleanup • puppet-lint (best practice)• Module test • rspec puppet • travis ci• Module development
  • Puppet Projects?• Puppet issues: projects.puppetlabs.com• Puppettools: geppeto puppet-lint rspec-puppet
  • We are hiring!
  • We are hiring!