puppet puppet 모듈, file 모듈

전송:http://blog.51cto.com/ywzhou/1577356
역할: puppet 모듈 을 통 해 클 라 이언 트 의 puppet 설정 을 자동 으로 제어 합 니 다. 클 라 이언 트 의 puppet 설정 을 수정 해 야 할 때 클 라 이언 트 에서 일일이 설정 하지 않 아 도 됩 니 다.
1. 서버 설정 puppet 모듈
(1) 모듈 리스트
[root@puppet ~]# tree /etc/puppet/modules/puppet/
/etc/puppet/modules/puppet/
├── files
├── manifests
│   ├── config.pp
│   ├── init.pp
│   ├── install.pp
│   ├── params.pp
│   └── service.pp
└── templates
    └── puppet.conf.erb

(2) 매개 변수 클래스 정의
[root@puppet ~]# vi /etc/puppet/modules/puppet/manifests/params.pp
class puppet::params {
  $puppetserver = "puppet.ewin.com"
  case $operatingsystemmajrelease{
    5: {                #  centos5     
      $puppet_release = '3.7.1-1.el5'
      $facter_release = '2.2.0-1.el5'
    }
    6: {                #  centos6     
      $puppet_release = '3.7.1-1.el6'      #      
      $facter_release = '2.2.0-1.el6'      #      
    }
    default: {
      fail("Module puppet is not supported on ${::operatingsystem}")
    }
  }
}

(3) 설치 클래스 정의
[root@puppet ~]# vi /etc/puppet/modules/puppet/manifests/install.pp
class puppet::install {
  package { "puppet":
    ensure => $puppet::params::puppet_release,
  }
  package { "facter":
    ensure => $puppet::params::facter_release,
  }
}
  :      (centos5 centos6)        puppet facter

(4) 설정 클래스 정의
[root@puppet ~]# vi /etc/puppet/modules/puppet/manifests/config.pp
class puppet::config {
  file { "/etc/puppet/puppet.conf":
    ensure  => present,
    content => template("puppet/puppet.conf.erb"), #         
    owner   => "root",
    group   => "root",
    mode    => '0644',
    require => Class["puppet::install"], #     install.pp
    notify  => Class["puppet::service"], #     service.pp
  }
}
  :            puppet.conf,    、 、  

(5) 설정 템 플 릿 정의
[root@puppet ~]# vi /etc/puppet/modules/puppet/template/puppet.conf.erb
### config by  puppet ###
[main]
    logdir = /var/log/puppet
    rundir = /var/run/puppet
    ssldir = $vardir/ssl
[agent]
    classfile = $vardir/classes.txt
    localconfig = $vardir/localconfig
    server =   #      
    report = true
    pluginsync = false
    runinterval = 10 #puppet         puppetmaster     ,  30  ,      10 ,        ,        1800
  :     params.pp    $puppetserver

(6) 서비스 클래스 정의
[root@puppet ~]# vi /etc/puppet/modules/puppet/manifests/service.pp
class puppet::service {
  service { "puppet":
    ensure     => running,    #    puppet      
    hasstatus  => true,       #    service puppet status      
    hasrestart => true,       #    service puppet restart      
    enable     => true,       #        
    require    => Class["puppet::install"],
  }
}

(7) puppet 주 클래스 정의
[root@puppet ~]# vi /etc/puppet/modules/puppet/manifests/init.pp
class puppet {
  include puppet::params,puppet::install,puppet::config,puppet::service
}

(8) 노드 파일 정의, 호출 모듈
[root@puppet ~]# vi /etc/puppet/manifests/centostest.pp
node "centostest.ewin.com" {
include ntp, yum, puppet
}
(9) 응용 노드 파일
[root@puppet ~]# vi /etc/puppet/manifests/site.pp
import "centostest.pp"

2. 테스트: 소프트웨어 설치 버 전, 프로필, 서비스 시작
(1) 설 치 된 버 전 보기
[root@centostest ~]# facter | grep operatingsystemmajrelease
operatingsystemmajrelease => 6
[root@centostest ~]# rpm -aq|grep puppet
puppet-3.7.3-1.el6.noarch
[root@centostest ~]# rpm -aq|grep facter
facter-2.3.0-1.el6.x86_64

(2) 서비스 상태 보기
[root@centostest ~]# /etc/init.d/puppet stop
Stopping puppet agent:                                     [  ]
[root@centostest ~]# /etc/init.d/puppet status
puppet   
[root@centostest ~]# chkconfig --list | grep puppet
puppet          0:    1:    2:    3:    4:    5:    6:  

(3) 프로필 보기
[root@centostest ~]# cat /etc/puppet/puppet.conf 
[main]
    # The Puppet log directory.
    # The default value is '$vardir/log'.
    logdir = /var/log/puppet
    # Where Puppet PID files are kept.
    # The default value is '$vardir/run'.
    rundir = /var/run/puppet
    # Where SSL certificates are kept.
    # The default value is '$confdir/ssl'.
    ssldir = $vardir/ssl
[agent]
    # The file in which puppetd stores a list of the classes
    # associated with the retrieved configuratiion.  Can be loaded in
    # the separate ``puppet`` executable using the ``--loadclasses``
    # option.
    # The default value is '$confdir/classes.txt'.
    classfile = $vardir/classes.txt
    # Where puppetd caches the local configuration.  An
    # extension indicating the cache format is added automatically.
    # The default value is '$confdir/localconfig'.
    localconfig = $vardir/localconfig

(4) 클 라 이언 트 가 테스트 수행
[root@centostest ~]# puppet agent --server puppet.ewin.com --test --noop
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Caching catalog for centostest.ewin.com
Info: Applying configuration version '1415246721'
Notice: /Stage[main]/Puppet::Install/Package[facter]/ensure: current_value 2.3.0-1.el6, should be 2.2.0-1.el6 (noop) #  :     2.2.0-1.el6
Notice: /Stage[main]/Puppet::Install/Package[puppet]/ensure: current_value 3.7.3-1.el6, should be 3.7.1-1.el6 (noop) #  :     3.7.1-1.el6
Notice: Class[Puppet::Install]: Would have triggered 'refresh' from 2 events
Notice: /Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]/content:  #  :  puppet.conf      
--- /etc/puppet/puppet.conf 2014-11-04 06:23:12.000000000 +0800
+++ /tmp/puppet-file20141106-34117-1abwj46-0  2014-11-06 12:04:04.724000002 +0800
@@ -1,25 +1,12 @@
-[main]
-    # The Puppet log directory.
-    # The default value is '$vardir/log'.
-    logdir = /var/log/puppet
-
-    # Where Puppet PID files are kept.
-    # The default value is '$vardir/run'.
-    rundir = /var/run/puppet
-
-    # Where SSL certificates are kept.
-    # The default value is '$confdir/ssl'.
-    ssldir = $vardir/ssl
-
-[agent]
-    # The file in which puppetd stores a list of the classes
-    # associated with the retrieved configuratiion.  Can be loaded in
-    # the separate ``puppet`` executable using the ``--loadclasses``
-    # option.
-    # The default value is '$confdir/classes.txt'.
-    classfile = $vardir/classes.txt
-
-    # Where puppetd caches the local configuration.  An
-    # extension indicating the cache format is added automatically.
-    # The default value is '$confdir/localconfig'.
-    localconfig = $vardir/localconfig
+### config by  puppet ###
+[main]
+    logdir = /var/log/puppet
+    rundir = /var/run/puppet
+    ssldir = $vardir/ssl
+[agent]
+    classfile = $vardir/classes.txt
+    localconfig = $vardir/localconfig
+    server = puppet.ewin.com
+    report = true
+    pluginsync = false
+    runinterval = 10
\ No newline at end of file
#  :    -     ,+     
Notice: /Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]/content: current_value {md5}58e2f9765e2994db8e8ab19a3513356e, should be {md5}fa6ae34360e0b6b7755165fc8e950a76 (noop)
Info: /Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]: Scheduling refresh of Class[Puppet::Service] #  :          service.pp
Notice: Class[Puppet::Service]: Would have triggered 'refresh' from 1 events
Info: Class[Puppet::Service]: Scheduling refresh of Service[puppet]
Notice: Class[Puppet::Config]: Would have triggered 'refresh' from 1 events
Notice: /Stage[main]/Puppet::Service/Service[puppet]/ensure: current_value stopped, should be running (noop) #  :        ,     
Info: /Stage[main]/Puppet::Service/Service[puppet]: Unscheduling refresh on Service[puppet]
Notice: Class[Puppet::Service]: Would have triggered 'refresh' from 1 events
Notice: Stage[main]: Would have triggered 'refresh' from 3 events
Notice: Finished catalog run in 0.70 seconds

(5) 실제 puppet 에이전트 실행 (- noop 인자 없 음)
[root@centostest ~]# puppet agent --server puppet.ewin.com --test
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Caching catalog for centostest.ewin.com
Info: Applying configuration version '1415247249'
Notice: /Stage[main]/Puppet::Install/Package[facter]/ensure: ensure changed '2.3.0-1.el6' to '2.2.0-1.el6'
Error: Could not update: Execution of '/usr/bin/yum -d 0 -e 0 -y downgrade puppet-3.7.1-1.el6' returned 1: Error Downloading Packages:
  puppet-3.7.1-1.el6.noarch: failure: puppet-3.7.1-1.el6.noarch.rpm from puppetlabs-products: [Errno 256] No more mirrors to try.
Wrapped exception:
Execution of '/usr/bin/yum -d 0 -e 0 -y downgrade puppet-3.7.1-1.el6' returned 1: Error Downloading Packages:
  puppet-3.7.1-1.el6.noarch: failure: puppet-3.7.1-1.el6.noarch.rpm from puppetlabs-products: [Errno 256] No more mirrors to try.
Error: /Stage[main]/Puppet::Install/Package[puppet]/ensure: change from 3.7.3-1.el6 to 3.7.1-1.el6 failed: Could not update: Execution of '/usr/bin/yum -d 0 -e 0 -y downgrade puppet-3.7.1-1.el6' returned 1: Error Downloading Packages:
  puppet-3.7.1-1.el6.noarch: failure: puppet-3.7.1-1.el6.noarch.rpm from puppetlabs-products: [Errno 256] No more mirrors to try.
Notice: /Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]: Dependency Package[puppet] has failures: true
Warning: /Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]: Skipping because of failed dependencies
Notice: /Stage[main]/Puppet::Service/Service[puppet]: Dependency Package[puppet] has failures: true
Warning: /Stage[main]/Puppet::Service/Service[puppet]: Skipping because of failed dependencies
Notice: Finished catalog run in 171.49 seconds
  :YUM    ,       ,    yum clean up yum list       
[root@centostest ~]# puppet agent --server=puppet.ewin.com --test
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Caching catalog for centostest.ewin.com
Info: Applying configuration version '1415247249'
Notice: /Stage[main]/Puppet::Install/Package[puppet]/ensure: ensure changed '3.7.3-1.el6' to '3.7.1-1.el6'
Notice: /Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]/content: 
--- /etc/puppet/puppet.conf 2014-09-16 04:33:01.000000000 +0800
+++ /tmp/puppet-file20141106-35765-10dpf4t-0  2014-11-06 15:04:50.422305001 +0800
@@ -1,25 +1,12 @@
-[main]
-    # The Puppet log directory.
-    # The default value is '$vardir/log'.
-    logdir = /var/log/puppet
-
-    # Where Puppet PID files are kept.
-    # The default value is '$vardir/run'.
-    rundir = /var/run/puppet
-
-    # Where SSL certificates are kept.
-    # The default value is '$confdir/ssl'.
-    ssldir = $vardir/ssl
-
-[agent]
-    # The file in which puppetd stores a list of the classes
-    # associated with the retrieved configuratiion.  Can be loaded in
-    # the separate ``puppet`` executable using the ``--loadclasses``
-    # option.
-    # The default value is '$confdir/classes.txt'.
-    classfile = $vardir/classes.txt
-
-    # Where puppetd caches the local configuration.  An
-    # extension indicating the cache format is added automatically.
-    # The default value is '$confdir/localconfig'.
-    localconfig = $vardir/localconfig
+### config by  puppet ###
+[main]
+    logdir = /var/log/puppet
+    rundir = /var/run/puppet
+    ssldir = $vardir/ssl
+[agent]
+    classfile = $vardir/classes.txt
+    localconfig = $vardir/localconfig
+    server = puppet.ewin.com
+    report = true
+    pluginsync = false
+    runinterval = 10
\ No newline at end of file
Info: Computing checksum on file /etc/puppet/puppet.conf
Info: /Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]: Filebucketed /etc/puppet/puppet.conf to puppet with sum 58e2f9765e2994db8e8ab19a3513356e
Notice: /Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]/content: content changed '{md5}58e2f9765e2994db8e8ab19a3513356e' to '{md5}fa6ae34360e0b6b7755165fc8e950a76'
Info: /Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]: Scheduling refresh of Class[Puppet::Service]
Info: Class[Puppet::Service]: Scheduling refresh of Service[puppet]
Notice: /Stage[main]/Puppet::Service/Service[puppet]/ensure: ensure changed 'stopped' to 'running'
Info: /Stage[main]/Puppet::Service/Service[puppet]: Unscheduling refresh on Service[puppet]
Notice: Finished catalog run in 222.24 seconds

(6) 클 라 이언 트 로그 보기
[root@centostest ~]# tailf /var/log/message
Nov  6 12:12:50 centostest puppet-agent[34357]: Retrieving pluginfacts
Nov  6 12:12:50 centostest puppet-agent[34357]: Retrieving plugin
Nov  6 12:12:51 centostest puppet-agent[34357]: Caching catalog for centostest.ewin.com
Nov  6 12:12:52 centostest puppet-agent[34357]: Applying configuration version '1415247249'
Nov  6 12:13:29 centostest yum[34565]: Installed: 1:facter-2.2.0-1.el6.x86_64
Nov  6 12:13:31 centostest puppet-agent[34357]: (/Stage[main]/Puppet::Install/Package[facter]/ensure) ensure changed '2.3.0-1.el6' to '2.2.0-1.el6'
Nov  6 12:15:43 centostest puppet-agent[34357]: Could not update: Execution of '/usr/bin/yum -d 0 -e 0 -y downgrade puppet-3.7.1-1.el6' returned 1: Error Downloading Packages:
Nov  6 12:15:43 centostest puppet-agent[34357]:   puppet-3.7.1-1.el6.noarch: failure: puppet-3.7.1-1.el6.noarch.rpm from puppetlabs-products: [Errno 256] No more mirrors to try.
Nov  6 12:15:43 centostest puppet-agent[34357]: Wrapped exception:
Nov  6 12:15:43 centostest puppet-agent[34357]: Execution of '/usr/bin/yum -d 0 -e 0 -y downgrade puppet-3.7.1-1.el6' returned 1: Error Downloading Packages:
Nov  6 12:15:43 centostest puppet-agent[34357]:   puppet-3.7.1-1.el6.noarch: failure: puppet-3.7.1-1.el6.noarch.rpm from puppetlabs-products: [Errno 256] No more mirrors to try.
Nov  6 12:15:43 centostest puppet-agent[34357]: (/Stage[main]/Puppet::Install/Package[puppet]/ensure) change from 3.7.3-1.el6 to 3.7.1-1.el6 failed: Could not update: Execution of '/usr/bin/yum -d 0 -e 0 -y downgrade puppet-3.7.1-1.el6' returned 1: Error Downloading Packages:
Nov  6 12:15:43 centostest puppet-agent[34357]: (/Stage[main]/Puppet::Install/Package[puppet]/ensure)   puppet-3.7.1-1.el6.noarch: failure: puppet-3.7.1-1.el6.noarch.rpm from puppetlabs-products: [Errno 256] No more mirrors to try.
Nov  6 12:15:43 centostest puppet-agent[34357]: (/Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]) Dependency Package[puppet] has failures: true
Nov  6 12:15:43 centostest puppet-agent[34357]: (/Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]) Skipping because of failed dependencies
Nov  6 12:15:43 centostest puppet-agent[34357]: (/Stage[main]/Puppet::Service/Service[puppet]) Dependency Package[puppet] has failures: true
Nov  6 12:15:43 centostest puppet-agent[34357]: (/Stage[main]/Puppet::Service/Service[puppet]) Skipping because of failed dependencies
Nov  6 12:15:43 centostest puppet-agent[34357]: Finished catalog run in 171.49 seconds

이 로 그 는 처음으로 puppet 에이 전 트 를 실 행 했 습 니 다. facter 를 설치 하 는 데 성 공 했 지만 puppet - 3.7.1 을 다운로드 하 는 데 실 패 했 습 니 다.
Nov  6 15:01:08 centostest puppet-agent[35765]: Retrieving pluginfacts
Nov  6 15:01:08 centostest puppet-agent[35765]: Retrieving plugin
Nov  6 15:01:10 centostest puppet-agent[35765]: Caching catalog for centostest.ewin.com
Nov  6 15:01:10 centostest puppet-agent[35765]: Applying configuration version '1415247249'
Nov  6 15:04:49 centostest yum[35972]: Installed: puppet-3.7.1-1.el6.noarch
Nov  6 15:04:50 centostest puppet-agent[35765]: (/Stage[main]/Puppet::Install/Package[puppet]/ensure) ensure changed '3.7.3-1.el6' to '3.7.1-1.el6'
Nov  6 15:04:50 centostest puppet-agent[35765]: (/Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]/content) 
Nov  6 15:04:50 centostest puppet-agent[35765]: (/Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]/content) --- /etc/puppet/puppet.conf#0112014-09-16 04:33:01.000000000 +0800
Nov  6 15:04:50 centostest puppet-agent[35765]: (/Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]/content) +++ /tmp/puppet-file20141106-35765-10dpf4t-0#0112014-11-06 15:04:50.422305001 +0800
Nov  6 15:04:50 centostest puppet-agent[35765]: (/Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]/content) @@ -1,25 +1,12 @@
Nov  6 15:04:50 centostest puppet-agent[35765]: (/Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]/content) -[main]
Nov  6 15:04:50 centostest puppet-agent[35765]: (/Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]/content) -    # The Puppet log directory.
Nov  6 15:04:50 centostest puppet-agent[35765]: (/Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]/content) -    # The default value is '$vardir/log'.
Nov  6 15:04:50 centostest puppet-agent[35765]: (/Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]/content) -    logdir = /var/log/puppet
Nov  6 15:04:50 centostest puppet-agent[35765]: (/Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]/content) -
Nov  6 15:04:50 centostest puppet-agent[35765]: (/Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]/content) -    # Where Puppet PID files are kept.
Nov  6 15:04:50 centostest puppet-agent[35765]: (/Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]/content) -    # The default value is '$vardir/run'.
Nov  6 15:04:50 centostest puppet-agent[35765]: (/Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]/content) -    rundir = /var/run/puppet
Nov  6 15:04:50 centostest puppet-agent[35765]: (/Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]/content) -
Nov  6 15:04:50 centostest puppet-agent[35765]: (/Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]/content) -    # Where SSL certificates are kept.
Nov  6 15:04:50 centostest puppet-agent[35765]: (/Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]/content) -    # The default value is '$confdir/ssl'.
Nov  6 15:04:50 centostest puppet-agent[35765]: (/Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]/content) -    ssldir = $vardir/ssl
Nov  6 15:04:50 centostest puppet-agent[35765]: (/Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]/content) -
Nov  6 15:04:50 centostest puppet-agent[35765]: (/Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]/content) -[agent]
Nov  6 15:04:50 centostest puppet-agent[35765]: (/Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]/content) -    # The file in which puppetd stores a list of the classes
Nov  6 15:04:50 centostest puppet-agent[35765]: (/Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]/content) -    # associated with the retrieved configuratiion.  Can be loaded in
Nov  6 15:04:50 centostest puppet-agent[35765]: (/Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]/content) -    # the separate ``puppet`` executable using the ``--loadclasses``
Nov  6 15:04:50 centostest puppet-agent[35765]: (/Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]/content) -    # option.
Nov  6 15:04:50 centostest puppet-agent[35765]: (/Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]/content) -    # The default value is '$confdir/classes.txt'.
Nov  6 15:04:50 centostest puppet-agent[35765]: (/Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]/content) -    classfile = $vardir/classes.txt
Nov  6 15:04:50 centostest puppet-agent[35765]: (/Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]/content) -
Nov  6 15:04:50 centostest puppet-agent[35765]: (/Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]/content) -    # Where puppetd caches the local configuration.  An
Nov  6 15:04:50 centostest puppet-agent[35765]: (/Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]/content) -    # extension indicating the cache format is added automatically.
Nov  6 15:04:50 centostest puppet-agent[35765]: (/Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]/content) -    # The default value is '$confdir/localconfig'.
Nov  6 15:04:50 centostest puppet-agent[35765]: (/Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]/content) -    localconfig = $vardir/localconfig
Nov  6 15:04:50 centostest puppet-agent[35765]: (/Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]/content) +### config by  puppet ####015
Nov  6 15:04:50 centostest puppet-agent[35765]: (/Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]/content) +[main]#015
Nov  6 15:04:50 centostest puppet-agent[35765]: (/Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]/content) +    logdir = /var/log/puppet#015
Nov  6 15:04:50 centostest puppet-agent[35765]: (/Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]/content) +    rundir = /var/run/puppet#015
Nov  6 15:04:50 centostest puppet-agent[35765]: (/Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]/content) +    ssldir = $vardir/ssl#015
Nov  6 15:04:50 centostest puppet-agent[35765]: (/Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]/content) +[agent]#015
Nov  6 15:04:50 centostest puppet-agent[35765]: (/Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]/content) +    classfile = $vardir/classes.txt#015
Nov  6 15:04:50 centostest puppet-agent[35765]: (/Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]/content) +    localconfig = $vardir/localconfig#015
Nov  6 15:04:50 centostest puppet-agent[35765]: (/Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]/content) +    server = puppet.ewin.com#015
Nov  6 15:04:50 centostest puppet-agent[35765]: (/Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]/content) +    report = true#015
Nov  6 15:04:50 centostest puppet-agent[35765]: (/Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]/content) +    pluginsync = false#015
Nov  6 15:04:50 centostest puppet-agent[35765]: (/Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]/content) +    runinterval = 10
Nov  6 15:04:50 centostest puppet-agent[35765]: (/Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]/content) \ No newline at end of file
Nov  6 15:04:50 centostest puppet-agent[35765]: Computing checksum on file /etc/puppet/puppet.conf
Nov  6 15:04:50 centostest puppet-agent[35765]: (/Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]) Filebucketed /etc/puppet/puppet.conf to puppet with sum 58e2f9765e2994db8e8ab19a3513356e
Nov  6 15:04:50 centostest puppet-agent[35765]: (/Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]/content) content changed '{md5}58e2f9765e2994db8e8ab19a3513356e' to '{md5}fa6ae34360e0b6b7755165fc8e950a76'
Nov  6 15:04:50 centostest puppet-agent[35765]: (/Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]) Scheduling refresh of Class[Puppet::Service]
Nov  6 15:04:50 centostest puppet-agent[35765]: (Class[Puppet::Service]) Scheduling refresh of Service[puppet]
Nov  6 15:04:52 centostest puppet-agent[36125]: Reopening log files
Nov  6 15:04:52 centostest puppet-agent[35765]: (/Stage[main]/Puppet::Service/Service[puppet]/ensure) ensure changed 'stopped' to 'running'
Nov  6 15:04:52 centostest puppet-agent[35765]: (/Stage[main]/Puppet::Service/Service[puppet]) Unscheduling refresh on Service[puppet]
Nov  6 15:04:52 centostest puppet-agent[35765]: Finished catalog run in 222.24 seconds
Nov  6 15:04:52 centostest puppet-agent[36125]: Starting Puppet client version 3.7.1
Nov  6 15:04:52 centostest puppet-agent[36125]: Run of Puppet configuration client already in progress; skipping  (/var/lib/puppet/state/agent_catalog_run.lock exists)
Nov  6 15:05:06 centostest puppet-agent[36135]: Finished catalog run in 0.46 seconds

YUM 창 고 를 다시 가 져 온 후 두 번 째 로 puppet 에이전트 로 그 를 실 행 했 습 니 다. puppet - 3.7.3 을 3.7.1 버 전 으로 낮 추 는 데 성 공 했 으 므 로 처음부터 puppet 버 전 을 지정 하여 설치 하 는 것 이 좋 습 니 다.
(7) 클 라 이언 트 테스트 결과 보기
설 치 된 버 전 보기:
[root@centostest ~]# rpm -aq|grep facter
facter-2.2.0-1.el6.x86_64
[root@centostest ~]# rpm -aq|grep puppet
puppet-3.7.1-1.el6.noarch

서비스 상태 보기:
[root@centostest ~]# /etc/init.d/puppet status
puppet (pid  36125)     ...
[root@centostest ~]# chkconfig --list | grep puppet
puppet          0:    1:    2:    3:    4:    5:    6:  

프로필 보기:
[root@centostest ~]# cat /etc/puppet/puppet.conf
### config by  puppet ###
[main]
    logdir = /var/log/puppet
    rundir = /var/run/puppet
    ssldir = $vardir/ssl
[agent]
    classfile = $vardir/classes.txt
    localconfig = $vardir/localconfig
    server = puppet.ewin.com
    report = true
    pluginsync = false
    runinterval = 10
  :             ;             ;           ,      。

3. 설정 파일 의 변경 영향 테스트
클 라 이언 트 가 프로필 을 수정 하여 puppet 서 비 스 를 다시 시작 합 니 다.
[root@centostest ~]# echo "#add a line" >> /etc/puppet/puppet.conf
[root@centostest ~]# tailf /var/log/message
Nov  6 15:33:57 centostest puppet-agent[57545]: (/Stage[main]/Puppet::Config/File[/etc/puppet/puppet.conf]/content) content changed '{md5}29acb66e2f297a5cf2ff6cbe731998f5' to '{md5}bb6d66a4b72890ef1bfa048c0cf179d8'
Nov  6 15:33:57 centostest puppet-agent[56826]: Caught HUP; calling restart
Nov  6 15:33:57 centostest puppet-agent[57545]: (/Stage[main]/Puppet::Service/Service[puppet]) Triggered 'refresh' from 1 events
Nov  6 15:33:57 centostest puppet-agent[57545]: Finished catalog run in 1.10 seconds
Nov  6 15:33:58 centostest puppet-agent[56826]: Caught HUP; calling restart
Nov  6 15:33:58 centostest puppet-agent[56826]: Restarting with '/usr/bin/puppet agent'
Nov  6 15:33:59 centostest puppet-agent[57782]: Reopening log files
Nov  6 15:34:00 centostest puppet-agent[57782]: Starting Puppet client version 3.7.1
Nov  6 15:34:02 centostest puppet-agent[57784]: Finished catalog run in 0.63 seconds

결론: 프로필 내용 을 성공 적 으로 변경 하여 puppet 서비스 재 부팅 을 촉발 하 였 으 며, 다음은 에이전트 가 시작 한 정보 입 니 다.
4. 파일 자원
file {'nginx.conf': 
  ensure => file,    #    :  file   directory
  mode   => '0640',  #  
  owner  => root,    #    
  group  => root,    #     
}

기타 매개 변수
{
  ensure       => present|absent|file|directory|link, #present        ,        
  backup       => , #  filebucket    ,        
  checksum     => , #         ,      MD5,   md5lite\mtime\ctime
one ctime => , # , mtime => , # content => , # force => , # 、 , ensure=absent owner => , # ID group => , # ID ignore => , # , link => , # , ln mode => , # path => '/tmp/test',# , , purge => , # manifest , recurse=>true recurse => true|false|inf|remote, # recurselimit => , # , replace => true|false, # , true( ) source => '/home/123.txt'|'http://'|'puppet:///', # , URL sourceselect => firest|all, # source , target => '/tmp/testlink', # , ensure => link type => , # }

좋은 웹페이지 즐겨찾기