61581229 发表于 2018-8-1 13:47:38

puppet知识简记

# Class:ntp# # This class installs/configures/manages NTP. It can optionaly disable NTP# on virtual machines. Only supported on Debian-derived and Red Hat-derivedOSes.## Parameters:#   - $servers:  
      An array of NTP servers, with or without +iburst+ and
  
      +dynamic+ statements appended. Defaults to the OS's defaults.#   - $enable
  
      Whether to start the NTP service on boot. Defaults to true. Valid
  
      values: true and false.#   - $ensure
  
      Whether to run the NTP service. Defaults to running. Valid values:
  
      ruuning and stopped.## Requires:#   Nothing.## Sample Usage:#   class {'ntp':#       servers =>['ntp1.puppetlabs.lan dynamic",#                   'ntp2.puppetlabs.lan dynamic",],#   }#   class {'ntp':#       enable=>false,#       ensure=>stopped,#   }class ntp ($servers = undef, $enable = true, $ensure = running) {    case $operatingsystem {
  
      centos, redhat: {            $service_name   =   'ntpd'
  
            $conf_template=   'ntp.conf.e1.erb'
  
            $default_servers= [ "0.centos.pool.ntp.org",                              "1.centos.pool.ntp.org",                              "2.centos.pool.ntp.org",
  
                              ]
  
      }
  
      debian, ubuntu: {            $service_name   =   'ntp'
  
            $conf_template=   'ntp.conf.debian.erb'
  
            $default_servers= [ "0.debian.pool.ntp.org",                              "1.debian.pool.ntp.org",                              "2.debian.pool.ntp.org",
  
                              ]
  
      }
  
    }
  

  
    if $servers ==undef {      $servers_real   =   $default_servers
  
    }
  
    else {      $servers_real   =   $servers
  
    }
  

  
    package { 'ntp':
  
      ensure=>installed,
  
    }
  

  
    service { 'ntp':
  
      name    =>$service_name,      ensure=>$ensure,
  
      enable=>$enable,
  
      subscribe   =>File['ntp.conf'],
  
    }
  

  
    file { 'ntp.conf':
  
      path    =>'/etc/ntp.conf',      ensure=>file,
  
      require =>Package['ntp'],
  
      content =>template("ntp/${conf_template}"),
  
    }
  
}
页: [1]
查看完整版本: puppet知识简记