fairyguo 发表于 2018-8-3 10:04:58

puppet记录


[*]1、安装
参考:1)http://blog.sina.com.cn/s/blog_505fbe360100y79s.html2)http://hi.baidu.com/nt_fs/blog/item/617e58dfc59cc20b632798bf.html3)http://www.inanu.net/post/584.html server: vm centos6       192.168.1.111client: vm centos6       192.168.1.100 时间同步,在各台机器执行ntpdate time.nist.gov Puppet是基于Ruby写成的,所以安装前要准备好Ruby环境。在中心Server上安装puppet-server包,并运行 puppetmasterd进程;在被管理机上安装puppet包,并运行puppetd进程;在每台主机上配置好自己的hostname,之后每台机器要以hostname区分。
[*]Server端:
安装ruby环境: yum -y install ruby ruby-rdoc 先安装epel-release包,到下面的网站找最新的http://yum.puppetlabs.com/el/6/products/i386/ rpm -Uvh http://yum.puppetlabs.com/el/6/products/i386/puppetlabs-release-6-1.noarch.rpm再安装puppet-server,会自动安装依赖yum -y install puppet-server 设置puppet服务自动启动chkconfig --level 2345 puppetmaster on 修改hosts,添加下面行:vi /etc/hosts192.168.1.111 pptser.chuanliu.com pptser  192.168.1.100 server1.chuanliu.com server1
确认hostnamevi /etc/sysconfig/networkpuppetserver.chuanliu.com增加端口识别:vi /etc/sysconfig/iptables添加8140 端口 客户端安装:
rpm -Uvh http://yum.puppetlabs.com/el/6/products/i386/puppetlabs-release-6-1.noarch.rpm yum -y install puppetchkconfig --level 2345 puppet on修改hosts,添加下面行:Vi /etc/hosts192.168.1.111 pptser.chuanliu.com pptser  192.168.1.100 server1.chuanliu.com server1
启动puppet
Server端首次运行前,编辑/etc/puppet/manifests/site.pp文件,内容可以用最基本的:# Create “/tmp/testfile” if it doesn’t exist.class test_class {file { “/tmp/testfile”:ensure => present,mode => 644,owner => root,group => root}}# tell puppet on which client to run the>node web1.sina.com.cn {include test_class}启动Server端:service puppetmaster start 启动客户端:第一次请求连接puppetd --server pptser.chuanliu.com --test这时客户机会去连server,但是由于连接是在ssl上的,而Server还没有sign过客户端的cert,客户机被断开。 到Server端执行:puppetca --list会显示等待签名的客户端的主机名,执行:puppetca --sign server1.chuanliu.com 在Server端为server1.chuanliu.com授权,这时再到客户机上运行puppetd --server pptser.chuanliu.com --test即可看到客户在正常地连接server,并且应用Server上为客户端定制的配置策略 测试:也可以将日志直接打印到终端上进行测试:Server端:puppetmasterd -d –no-daemonize -v –trace客户端:puppetd –test –trace –debug2. puppet配置文件
主配置文件(puppet.conf):1). 配置文件命名空间:
main 通用配置选项puppetd 客户端配置选项puppetmasterd 服务端配置选项2). main命名空间选项:
confdir 配置文件目录,默认在/etc/puppetvardir 动态数据目录,默认在/var/lib/puppetlogdir 日志目录,默认在/var/log/logrundir puppet PID目录,默认在/var/run/puppetstatedir state目录,默认在$vardir/statestatefile state文件,默认在$statedir/state.yamlssldir SSL证书目录,默认在$vardir/ssltrace 发生错误时显示跟踪信息,默认falsefiletimeout 检测配置文件状态改变的时间周期,单位秒,默认15秒syslogfacility 指定syslog功能为user级,默认为daemon级3). puppetmasterd命名空间选项:
user 后台进程执行的用户group 后台进程执行的组mainfestdir mainfests文件存储目录,默认为$confdir/mainfestsmainfest mainfest站点文件的名字,默认为site.ppbindaddress 后台进程绑定的网卡地址接口masterport 后台进程执行的端口,默认为81404). puppet命名空间选项:
server puppet puppet服务器名,默认为puppetruninterval seconds puppet应用配置的时间间隔,默认1800秒(0.5小时)puppetdlockfie file puppet lock文件位置,默认$statedir/puppetdlockpuppetport port 后台进程执行的端口,默认8139文件服务配置文件(fileserver.conf):path /var/lib/puppet/filesallow 121.14.1.*allow 60.28.228.0/24allow *.house.sina.com.cndeny *.sina.com.cnpath定义文件存放路径,通过allow/deny来控制访问权限。3. puppet命令集
1). puppet 用于执行用户所写独立的mainfests文件# puppet -l /tmp/manifest.log manifest.pp2). puppetd 运行在被管理主机上的客户端程序# puppetd –server puppet.leju.com3). puppetmasterd 运行在管理机上的服务器程序# puppetmasterd4). puppetca puppet认证程序# puppetca -lpclient.leju.com# puppetca -s pclient.leju.com5). puppetrun 用于连接客户端,强制运行本地配置文件# puppetrun -p 10 –host host1 –host host2 -t remotefile -t webserver6). filebucket 客户端用于发送文件到puppet file bucket的工具# filebucket -b /tmp/filebucket /my/file7). ralsh 转换配置信息到puppet配置代码# ralsh user lukeuser { ‘luke’:home => ‘/home/luke’,uid => ‘100′,ensure => ‘present’,comment => ‘Luke Kanies,,,’,gid => ‘1000′,shell => ‘/bin/bash’,groups => ['sysadmin','audio','video','puppet']}8). puppetdoc 打印puppet参考文档# puppetdoc -r type > /tmp/type_reference.rst# puppetdoc –outputdir /tmp/rdoc –mode rdoc /path/to/manifests# puppetdoc /etc/puppet/manifests/site.pp   都说修改hostname是即时生效的我看未必啊,修改了好几次都没有成功还是得重启机器
页: [1]
查看完整版本: puppet记录