Hatena::Groupdann

puppet

puppet

Convention

    *  Name of application = name of module
    * Module name should be lowercase without space, :: and /
    * Module name "site" is reserved for local use

    * include postfix - Installs and runs the Postfix service
    * include postfix::disable - Installs Postfix but doesn't run the service

    * include samba::server - Installs Samba server
    * include samba::client - Installs Samba client

    * import autofs - Loads $modulepath/autofs/manifests/init.pp
    * include autofs::server - Loads $modulepath/autofs/manifests/server.pp

 

A class where to place all the internal variables of a module::params

internalなvariableは、module::paramsに書いておいて、OSを隠蔽しておくのがいい。

class apache::params  {

    $packagename = $operatingsystem ? {
        freebsd => "apache20",
        debian  => "apache2",
        ubuntu  => "apache2",
        default => "httpd",
    }
    
    $servicename = $operatingsystem ? {
        debian  => "apache2",
        ubuntu  => "apache2",
        default => "httpd",
    }
    
    $username = $operatingsystem ? {
        debian  => "www-data",
        ubuntu  => "www-data",
        default => "apache",
    }
    
    $configfile = $operatingsystem ?{
        freebsd => "/usr/local/etc/apache20/httpd.conf",
        ubuntu  => "/etc/apache2/apache2.conf",
        debian  => "/etc/apache2/apache2.conf",
        default => "/etc/httpd/conf/httpd.conf",
    }
    
    $configdir = $operatingsystem ?{
        freebsd => "/usr/local/etc/apache20",
        ubuntu  => "/etc/apache2",
        debian  => "/etc/apache2",
        default => "/etc/httpd/conf",
    }
    
    $documentroot = $operatingsystem ?{
        debian  => "/var/www",
        ubuntu  => "/var/www",
        suse    => "/srv/www",
        default => "/var/www/html",
    }

}


Extending naming conventions...

Proposed extensions:

    * include samba::absent
      Completely remove package (and Puppet managed files?)
    * include samba::disableboot
      Disable service at boot time and don't check status runtime
    * samba::monitor
      A standard way to define what to monitor
    * samba::backup
      A standard way to define what to backup
    * samba::conf ( or samba::settings )
      General purpose inline modification define for main configuration file

(This is a call for standardization: first we should agree on needs, then on naming)

monitorクラスでは、何を監視するかを見る。どのようにではなく。

    *  On the module you define what you want to monitor, not how
    * Needs naming convention to allow integration between modules' sets
    * A syntax example:

          class postfix::monitor {

          	include postfix::params

          	monitor::port { "port_tcp_25":
          		proto   => "tcp",
          		port 	=> 25,
          		enable	=> true,
          	}
              
          	monitor::port { "port_tcp_465":
          		proto   => "tcp",
          		port 	=> 465,
          		enable	=> false,
          	}
              
          	monitor::process { "postfix_process":
          		name 	=> "${postfix::params::processname}",
          		enable	=> true,
          	}

          	monitor::plugin { "postfix_plugin":
          		name 	=> "${postfix::params::plugin}",
          		enable	=> false,
          	}

          }
                    


    *  Wrapper to define what to backup
    * Needs naming convention... (am I obsessive?)
    * An example:

      class apache::backup {

      	include apache::params

      	backup { "apache_data": 
      		frequency => daily,
      		path      => "${apache::params::documentroot}",
      		enabled   => true,
      		host      => $fqdn,
      	}
      	
      	backup { "apache_logs": 
      		frequency => daily,
      		path      => "${apache::params::logs}",
      		enabled	  => false,
      		host      => $fqdn,
      	}
      	
      }

puppetの設定の設計ガイドライン

http://www.example42.com/puppet/guidelines.php

  • 各nodeはbasenodeをinherit
  • 各nodeは、roleを
  • 各roleは、generalなclassをimport
    • 各roleは、lvsなどのclass定義をimport

* はてなダイアリーキーワード:puppet