Puppet

2,037 views

Published on

Published in: Technology, Spiritual
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,037
On SlideShare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
Downloads
60
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Puppet

  1. 1. Puppet July 2013 Arnaud Coomans
  2. 2. What puppet is ● manage your nodes: ○ packages ○ configuration ○ services ○ nagios ○ code deployment? ● declarative ○ what not how ● do only what needs to be done ● well documented
  3. 3. What puppet is NOT ● manage instances ○ but integrate somewhat with ec2 ● monitoring tool ○ but integrates with nagios ● logging tool ○ but integrates with others like logstash ● a magical silver-bullet for ops
  4. 4. Learning puppet http://docs.puppetlabs.com/learning/index.html ● easy to learn ● example vm
  5. 5. Learning puppet: Running it ● command line with values ○ puppet resource type name attributes ● command line with file ○ puppet apply filename.pp ● agent/master
  6. 6. Learning puppet: Agent/Master 1. Agent node asks master for catalog ○ node name is certname in agent's puppet.conf 2. Master compiles catalog from manifest, sends it to agent 3. Agent apply catalog Default: every 30 minutes http://docs.puppetlabs.com/learning/agent_master_basic.html
  7. 7. Learning puppet: Resources Resource: ● Package ● File ● Service ● User ● ... http://docs.puppetlabs.com/references/latest/type.html service { 'ntp': ensure => 'running', }
  8. 8. Learning puppet: Ordering ● execution is not sequential ● set relations between resources ○ before ○ require ○ notify ○ subscribe http://docs.puppetlabs.com/learning/ordering.html
  9. 9. Learning puppet: Ordering pattern Package/File/Service pattern package { 'openssh-server': ensure => present, before => File['/etc/ssh/sshd_config'], } file { '/etc/ssh/sshd_config': ensure => file, source => '/root/examples/sshd_config', } service { 'sshd': ensure => running, subscribe => File['/etc/ssh/sshd_config'], }
  10. 10. Learning puppet: Variables, Conditionals and Facts (and Regex) ● variables ○ $var = "value" ● facts ○ facter ● conditionals ○ if ○ case ○ selectors ● Regexes http://docs.puppetlabs.com/facter/1.6/core_facts.html $apache = $operatingsystem ? { centos => 'httpd', redhat => 'httpd', /(?i)(ubuntu|debian)/ => 'apache2', default => undef, }
  11. 11. Learning puppet: Classes and Modules ● class ○ may take parameters ● module ○ reusable ○ structure ■ files ■ manifests ■ templates ○ init.pp class my_class($var) { notify {"this is var $var":} }
  12. 12. Learning puppet: Templates ERB Templating Language http://docs.puppetlabs.com/guides/templating.html $ntp_server = "ntp.instaply.com" file { 'ntp.conf': path => '/etc/ntp.conf', ensure => file, require => Package['ntp'], content => template ("ntp/${conf_file}.erb"), } <% if environment =~ /prod/ %> server 0.ubuntu.pool.ntp.org server 1.ubuntu.pool.ntp.org server 2.ubuntu.pool.ntp.org <% end %> server <%= ntp_server -%>
  13. 13. Puppet and Vagrant Provisioning in Vagrantfile ● apply ● agent http://docs.vagrantup.com/v2/provisioning/puppet_apply.html http://docs.vagrantup.com/v2/provisioning/puppet_agent.html puppet.manifest_file = "site.pp" puppet.manifests_path = "puppet/manifests" puppet.module_path = "puppet/modules" puppet.options = [ "--verbose", "--debug", ]
  14. 14. Puppet and Vagrant: Facter ● Override facter values ○ works only for ■ vagrant up ■ vagrant provision ○ not ■ facter ■ puppet apply puppet.facter = { "environment" => "vagrant", }
  15. 15. Puppet forge ● publicly available modules ● young (not yet mature?) ● promising
  16. 16. Puppet enterprise ● essentially the same as the oss version ● expensive ● support => probably not for a small startup
  17. 17. Thank you

×