苏州网站设计制作,网站 侧边栏,网站建设大神级公司,设计素材网站好融资吗转载#xff1a;http://blog.51cto.com/ywzhou/1577356 作用#xff1a;通过puppet模块自动控制客户端的puppet配置#xff0c;当需要修改客户端的puppet配置时不用在客户端一一设置。 1、服务端配置puppet模块 #xff08;1#xff09;模块清单 [rootpuppet ~]# tree /et… 转载http://blog.51cto.com/ywzhou/1577356 作用通过puppet模块自动控制客户端的puppet配置当需要修改客户端的puppet配置时不用在客户端一一设置。 1、服务端配置puppet模块 1模块清单 [rootpuppet ~]# tree /etc/puppet/modules/puppet/
/etc/puppet/modules/puppet/
├── files
├── manifests
│ ├── config.pp
│ ├── init.pp
│ ├── install.pp
│ ├── params.pp
│ └── service.pp
└── templates└── puppet.conf.erb2定义参数类 [rootpuppet ~]# vi /etc/puppet/modules/puppet/manifests/params.pp
class puppet::params {$puppetserver puppet.ewin.comcase $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定义安装类 [rootpuppet ~]# 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和facter4定义配置类 [rootpuppet ~]# 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.ppnotify Class[puppet::service], #通知并触发service.pp}
}说明将配置模板传送到客户端的puppet.conf设置用户、组、权限5定义配置模板 [rootpuppet ~]# vi /etc/puppet/modules/puppet/template/puppet.conf.erb
### config by puppet ###
[main]logdir /var/log/puppetrundir /var/run/puppetssldir $vardir/ssl
[agent]classfile $vardir/classes.txtlocalconfig $vardir/localconfigserver % scope.lookupvar(puppet::params::puppetserver) % #参数调用格式% 参数 %report truepluginsync falseruninterval 10 #puppet 客户端默认连接到puppetmaster的时间间隔默认30分钟这里测试设为10秒将会生成大量报告建议测试完后改回1800说明模板调用了params.pp中的参数$puppetserver6定义服务类 [rootpuppet ~]# 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主类 [rootpuppet ~]# vi /etc/puppet/modules/puppet/manifests/init.pp
class puppet {include puppet::params,puppet::install,puppet::config,puppet::service
}8定义节点文件调用模块 [rootpuppet ~]# vi /etc/puppet/manifests/centostest.pp node centostest.ewin.com { include ntp, yum, puppet } 9应用节点文件 [rootpuppet ~]# vi /etc/puppet/manifests/site.pp
import centostest.pp2、测试软件安装版本、配置文件、服务启动 1查看已安装版本 [rootcentostest ~]# facter | grep operatingsystemmajrelease
operatingsystemmajrelease 6
[rootcentostest ~]# rpm -aq|grep puppet
puppet-3.7.3-1.el6.noarch
[rootcentostest ~]# rpm -aq|grep facter
facter-2.3.0-1.el6.x86_642查看服务状态 [rootcentostest ~]# /etc/init.d/puppet stop
Stopping puppet agent: [确定]
[rootcentostest ~]# /etc/init.d/puppet status
puppet 已停
[rootcentostest ~]# chkconfig --list | grep puppet
puppet 0:关闭 1:关闭 2:关闭 3:关闭 4:关闭 5:关闭 6:关闭3查看配置文件 [rootcentostest ~]# 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/localconfig4客户端执行测试 [rootcentostest ~]# 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/puppetrundir /var/run/puppetssldir $vardir/ssl
[agent]classfile $vardir/classes.txtlocalconfig $vardir/localconfigserver puppet.ewin.comreport truepluginsync falseruninterval 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 seconds5真正执行puppet agent不带--noop参数 [rootcentostest ~]# 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恢复仓库后重试[rootcentostest ~]# puppet agent --serverpuppet.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/puppetrundir /var/run/puppetssldir $vardir/ssl
[agent]classfile $vardir/classes.txtlocalconfig $vardir/localconfigserver puppet.ewin.comreport truepluginsync falseruninterval 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 seconds6查看客户端日志 [rootcentostest ~]# 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 agent安装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 agent的日志, 成功将puppet-3.7.3降为3.7.1版本因此最好一开始指定好puppet版本安装。 7查看客户端测试结果 查看已安装版本 [rootcentostest ~]# rpm -aq|grep facter
facter-2.2.0-1.el6.x86_64
[rootcentostest ~]# rpm -aq|grep puppet
puppet-3.7.1-1.el6.noarch查看服务状态 [rootcentostest ~]# /etc/init.d/puppet status
puppet (pid 36125) 正在运行...
[rootcentostest ~]# chkconfig --list | grep puppet
puppet 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭查看配置文件 [rootcentostest ~]# cat /etc/puppet/puppet.conf
### config by puppet ###
[main]logdir /var/log/puppetrundir /var/run/puppetssldir $vardir/ssl
[agent]classfile $vardir/classes.txtlocalconfig $vardir/localconfigserver puppet.ewin.comreport truepluginsync falseruninterval 10结论软件版本成功转变成指定版本服务启动并添加到开机启动中配备文件成功从模板获取参数应用成功。3、测试配置文件的变更影响 客户端修改配置文件导致puppet服务重启 [rootcentostest ~]# echo #add a line /etc/puppet/puppet.conf
[rootcentostest ~]# 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服务重启接下来是agent启动的信息。 4、file资源 file {nginx.conf: ensure file, #定义类型文件file或目录directorymode 0640, #权限owner root, #属于用户group root, #属于用户组
}其他参数 {ensure present|absent|file|directory|link, #present检查文件是否存在如果存在则不创建backup , #通过filebucket备份文件可备份到其他设备checksum , #检查文件是否被修改默认检测法为MD5其他有md5lite\mtime\ctime\nonectime , #只读属性文件的更新时间mtime , #只读属性content , #文件的内容 force , #强制删除文件、软链接及目录确保ensureabsentowner , #指定文件的用户名或用户IDgroup , #指定文件的用户组名或组IDignore , #忽略指定的匹配文件可以匹配目录结构link , #软链接类似于ln命令mode , #文件权限配置path /tmp/test,#文件路径使用双引号可用标题代替purge , #清空目录中未在manifest中定义的文件或目录必须与recursetrue使用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 , #只读状态检查文件类型
}