在master端编辑目录下的site.pp文件(若没有则创建该文件)
编辑内容如下:
# sudo vim /etc/puppet/manifests/site.pp
package {
“vim”:
ensure => installed
}
# Create “/tmp/testfile” if it doesn’t exist.
class test_class {
file {
“/tmp/testfile”:
ensure => present,
mode => 600,
owner => root,
group => root
}
}
# tell puppet on which client to run the class
node puppetclient {
include test_class
}
通过上面的配置将会在agent的/tmp目录下创建testfile文件
server = puppetmaster.example.com
# Make sure all log messages are sent to the right directory
# This directory must be writable by the puppet user
logdir=/var/log/puppet
vardir=/var/lib/puppet
rundir=/var/run
warning: peer certificate won’t be verified in this SSL session
warning: peer certificate won’t be verified in this SSL session
info: Creating a new SSL certificate request for puppetclient.example.com
info: Certificate Request fingerprint (md5): 9E:3A:CB:C4:50:6D:42:CD:4E:EE:57:07:FB:AA:98:1B
warning: peer certificate won’t be verified in this SSL session
warning: peer certificate won’t be verified in this SSL session
warning: peer certificate won’t be verified in this SSL session
back to The Server and check who is waiting
回到master端,使用root权限运行如下命令:
# sudo puppetca –list
运行结果如下:
you see that the client puppetclient.example.com is waiting
Now Sign the certificaat from the Master with:
运行结果如下:
notice: Signed certificate request for puppetclient.example.com
notice: Removing file Puppet::SSL::CertificateRequest puppetclient.example.com at ‘/var/lib/puppet/ssl/ca/requests/puppetclient.example.com.pem’
回到agent端再用以下命令进行测试:
# sudo puppet agent -–test
运行结果为:
notice: /Stage[main]/Test_class/File[/tmp/testfile]/ensure: created
notice: Finished catalog run in 0.79 seconds