> Linux教程 > Linux学习 >

puppet命令与配置

一、命令
puppet 用于执行用户所写独立的mainfests文件
用法:
puppet [-h|--help] [-V|--version] [-d|--debug] [-v|--verbose]
[--detailed-exitcodes] [-l|--logdest ]
# puppet -l /tmp/manifest.log manifest.pp

puppetd 运行在被管理主机上的客户端程序
用法:
puppetd [-D|--daemonize|--no-daemonize] [-d|--debug] [--disable] [--enable]
[-h|--help] [--fqdn ] [-l|--logdest syslog||console]
[-o|--onetime] [--serve ] [-t|--test] [--noop]
[-V|--version] [-v|--verbose] [-w|--waitforcert ]
# puppetd –server puppet.domain.com

puppetmasterd 运行在管理机上的服务器程序
用法:
puppetmasterd [-D|--daemonize|--no-daemonize] [-d|--debug] [-h|--help]
[-l|--logdest |console|syslog] [--nobucket] [--nonodes]
[-v|--verbose] [-V|--version]
# puppetmasterd

puppetca puppet认证程序
用法:
puppetca [-h|--help] [-V|--version] [-d|--debug] [-v|--verbose]
[-g|--generate] [-l|--list] [-s|--sign] [-r|--revoke]
[-p|--print] [-c|--clean] [--verify] [host]
# puppetca -l
culain.madstop.com
# puppetca -s culain.madstop.com

puppetrun 用于连接客户端,强制运行在本地配置文件下
用法:
puppetrun [-a|--all] [-c|--class ] [-d|--debug] [-f|--foreground]
[-h|--help] [--host ] [--no-fqdn] [--ignoreschedules]
[-t|--tag ] [--test] [-p|--ping]
# puppetrun -p 10 –host host1 –host host2 -t remotefile -t webserver

filebucket 客户端用于发送文件到puppet file bucket的工具
用法:
filebucket [-h|--help] [-V|--version] [-d|--debug] [-v|--verbose]
[-l|--local] [-r|--remote]
[-s|--server ] [-b|--bucket ] …
# filebucket -b /tmp/filebucket /my/file

ralsh 转换配置信息到puppet配置代码
用法:
ralsh [-h|--help] [-d|--debug] [-v|--verbose] [-e|--edit] [-H|--host ]
[-p|--param
] [-t|--types] type
# ralsh user luke
user { ‘luke’:
home => ‘/home/luke’,
uid => ‘100′,
ensure => ‘present’,
comment => ‘Luke Kanies,,,’,
gid => ‘1000′,
shell => ‘/bin/bash’,
groups => ['sysadmin','audio','video','puppet']
}

puppetdoc 打印puppet参考文档
用法:
puppetdoc [-a|--all] [-h|--help] [-o|--outputdir ]
[-m|--mode ]
[-r|--reference <[type]|configuration|..>] [manifest-file]
# puppetdoc -r type > /tmp/type_reference.rst
# puppetdoc –outputdir /tmp/rdoc –mode rdoc /path/to/manifests
# puppetdoc /etc/puppet/manifests/site.pp

生成服务器与客户端的配置文件
# puppetmasterd –genconfig > puppet.conf
# puppetd –genconfig > puppet.conf

二、配置文件puppet.conf
默认情况下,配置文件位于/etc/puppet目录下,文件名为puppet.conf

配置文件命名空间
main 通用配置选项
puppetd 客户端配置选项
puppetmasterd 服务端配置选项

main命名空间选项
confdir 配置文件目录,默认在/etc/puppet
vardir 动态数据目录,默认在/var/puppet
logdir 日志目录,默认在$vardir/log
rundir puppet PID目录,默认在$vardir/run
statedir state目录,默认在$vardir/state
statefile state文件,默认在$statedir/state.yaml
ssldir SSL证书目录,默认在$confdir/ssl
trace 发生错误时显示跟踪信息,默认false
filetimeout 检测配置文件状态改变的时间周期,单位秒,默认15秒
syslogfacility 指定syslog功能为user级,默认为daemon级

puppetmasterd命名空间选项
user 后台进程执行的用户
group 后台进程执行的组
mainfestdir mainfests文件存储目录,默认为$confdir/mainfests
mainfest mainfest站点文件的名字,默认为site.pp
bindaddress 后台进程绑定的网卡地址接口
masterport 后台进程执行的端口,默认为8140

puppet命名空间选项
server puppet puppet服务器,默认为puppet
runinterval seconds puppet应用配置的时间间隔,默认1800秒(0.5小时)
puppetdlockfie file puppet lock文件位置,默认$statedir/puppetdlock
puppetport port 后台进程执行的端口,默认8139 (责任编辑:IT)