puppet最新源码详细安装:node
在网上找了不少相关puppet的,有不少用yum安装,安装虽然成功了。可是有客户端相关过来请求,仍是会有问题。最佳的仍是源码安装。c++
1、下载地址:vim
puppet下载地址:
http://downloads.puppetlabs.com/puppet/puppet-2.7.13.tar.gzruby
facter下载地址:
http://downloads.puppetlabs.com/facter/facter-1.6.7.tar.gz
ruby下载地址:
http://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7.tar.gz
2、环境准备:bash
一、时间必须一致:服务器
crontab -edom
- */2 * * * * /usr/sbin/ntpdate clock.nc.fukuoka-u.ac.jp >/dev/null 2>&1
二、首先gcc相关可用yum安装ide
yum install gcc-c++ 测试
yum install openssl*ui
三、服务器及客户端名字:
- [root@server bin]# more /etc/hosts
- # Do not remove the following line, or various programs
- # that require network functionality will fail.
- #127.0.0.1 localhost.localdomain localhost
- ::1 localhost6.localdomain6 localhost6
- 192.168.1.231 server.cbcv.net server
- 192.168.1.232 client.cbcv.net client
- [root@server bin]# more /etc/sysconfig/network
- NETWORKING=yes
- NETWORKING_IPV6=no
- HOSTNAME=server.cbcv.net
<客户端也是相似同样,略......>
3、安装应用软件
一、首先安装ruby
tar -zxvf ruby-1.8.7.tar.gz
cd ruby-1.8.7
./configure --prefix=/usr/local/ruby
make
make install
操做系统PATH路径:
vi /etc/profile
export PATH=/usr/local/ruby/bin:$PATH
查看ruby --version版本
二、安装facter
tar -zxvf facter-1.6.7.tar.gz
cd facter-1.6.7
ruby install.rb
三、安装puppet
- tar -zxvf puppet-2.7.9.tar.gz
- cd puppet-2.7.9/
- ruby install.rb
- [root@server puppet-2.7.9]# cp conf/auth.conf /etc/puppet/
- [root@server puppet-2.7.9]# cp conf/namespaceauth.conf /etc/puppet/
- [root@server puppet-2.7.9]# cp conf/redhat/puppet.conf /etc/puppet/
- [root@server puppet-2.7.9]# cp conf/redhat/server.init /etc/init.d/puppetmaster
- [root@server puppet-2.7.9]# chmod +x /etc/init.d/puppetmaster
- [root@server puppet-2.7.9]# /etc/init.d/puppetmaster start
- Starting puppetmaster: /bin/bash: /usr/sbin/puppetmasterd: No such file or directory
- [FAILED]
- [root@server puppet-2.7.9]# cp sbin/puppetmasterd /usr/sbin/
- [root@server puppet-2.7.9]# chmod -R 777 /usr/sbin/puppetmasterd
- [root@server puppet-2.7.9]# cp sbin/puppetmasterd /bin/puppetmasterd
- [root@server puppet-2.7.9]# chmod -R 777 /bin/puppetmasterd
- [root@server puppet-2.7.9]# /etc/init.d/puppetmaster start
- Starting puppetmaster: /usr/bin/env: ruby: No such file or directory
- [FAILED]
- [root@server puppet-2.7.9]# ln -s /usr/local/ruby/bin/
- erb filebucket pi puppetdoc rdoc ruby
- facter irb puppet ralsh ri testrb
- [root@server puppet-2.7.9]# ln -s /usr/local/ruby/bin/ruby /usr/bin/
- [root@server puppet-2.7.9]# /etc/init.d/puppetmaster start
- Starting puppetmaster: Could not prepare for execution: Got 6 failure(s) while initializing: change from absent to directory failed: Could not set 'directory on ensure: Could not find group puppet; change from absent to directory failed: Could not set 'directory on ensure: Could not find group puppet; change from absent to directory failed: Could not set 'directory on ensure: Could not find group puppet; change from absent to directory failed: Could not set 'directory on ensure: Could not find group puppet; change from absent to directory failed: Could not set 'directory on ensure: Could not find group puppet; change from absent to directory failed: Could not set 'directory on ensure: Could not find group puppet
- [FAILED]
- [root@server puppet-2.7.9]# useradd puppet
- [root@server puppet-2.7.9]# /etc/init.d/puppetmaster start
- Starting puppetmaster: [ OK ]
- [root@server sbin]# pwd
- /usr/local/src/puppet-2.7.9/sbin
- cp -r * /usr/sbin/
- [root@server manifests]# chkconfig --add puppetmaster
- [root@server manifests]# chkconfig puppetmaster on
客户端其它安装和服务器安装相同,除了用cp conf/redhat/client.init /etc/init.d/puppet
- [root@localhost puppet-2.7.9]# cp conf/auth.conf /etc/puppet/
- [root@localhost puppet-2.7.9]# cp conf/namespaceauth.conf /etc/puppet/
- [root@localhost puppet-2.7.9]# cp conf/redhat/puppet.conf /etc/puppet/
- [root@localhost puppet-2.7.9]# cp conf/redhat/client.init /etc/init.d/puppet
- [root@localhost puppet-2.7.9]# chmod +x /etc/init.d/puppet
- [root@localhost puppet-2.7.9]# service puppet start
- Starting puppet: /bin/bash: /usr/sbin/puppetd: No such file or directory
- [FAILED]
- [root@localhost puppet-2.7.9]# cp sbin/puppetd /usr/sbin/puppetd
- [root@localhost puppet-2.7.9]# service puppet start
- Starting puppet: /usr/bin/env: ruby: No such file or directory
- [FAILED]
- [root@localhost puppet-2.7.9]# chmod +x /usr/sbin/puppetd
- [root@localhost puppet-2.7.9]# service puppet start
- Starting puppet: /usr/bin/env: ruby: No such file or directory
- [FAILED]
- [root@localhost puppet-2.7.9]# ln -s /usr/local/ruby/bin/ruby /usr/bin/
- [root@localhost puppet-2.7.9]# /etc/init.d/puppet start
- Starting puppet: [ OK ]
安装完毕后进行测试:
在服务器端执行:
puppetca --list
应该是无
在客户端执行 puppetd --server server.cbcv.net --test
再到服务器端执行:
puppetca –s client.cbcv.net
clinet.cbcv.net (BF:5D:58:D0:F2:06:8C:FB:5C:AA:08:80:87:DC:92:20)
若是看到了客户端的证书请求,
针对客户端请求为
puppetca –s client.cbcv.net
用下面的命令对全部证书请求签名:
puppetca -s –a
在主服务器上/etc/puppet/manifests
vi /etc/puppet/manifests/site.pp
node default{
file { "/tmp/test.txt":
content=> "hello, Test";
}
}
再重启一下服务器service puppetmaster restart 和客户端service puppet restart
再执行puppetd --server server.cbcv.net --test
看/tmp下面是否是有test.txt文件了
增长多个site.pp
能够先在site.pp中增长
import "test.pp"
而后再在里面执行须要操做的内容。
可用puppetd --server server.cbcv.net --test进行测试。
若是有报错:notice: Ignoring --listen on onetime run
notice: Skipping run of Puppet configuration client; administratively disabled; use 'puppet Puppet configuration client --enable' to re-enable.
那么须要在客户端执行puppet agent --enable便可。
puppet agent --disable为关闭。
记得重启puppetmaster和puppet
如下为参考内容,感受很是不错:
默认时间vim /etc/puppet/puppet.con
runinterval =1800 ###默认是30分钟,能够修改此处的值,单位为秒
有的时间修改了这个没有用,是什么缘由呢:
我也曾修改过屡次,没效果,后在客户端的配置文件再加了一句server = server.cbcv.net
而后重启
在客户端修改便可!最好重启一下server puppet restart
puppet 如何全客户端自动签名
a.vim /etc/puppet/puppet.conf
[puppetmaster]
autosign=true #增长这两行
autosing=/etc/puppet/autosign.conf
#增长这两行添加
* 表示全部,或者添加域名,IP或者网段。举例:
b.再编辑 /etc/puppet/autosign.conf**.test.com192.168.0.1/24
错误总结<此错误是由于用了yum去安装。看到别人写的OK......>:
第一次认证的时候报下边的错误:
[root@client ~]# puppetd --server server.cbcv.net --test
err: Could not retrieve catalog from remote server: certificate verify failed
我作测试发现的缘由有三种:
第一:是hostname没有设置好,在安装前必定要把hostname设置好,设置好以后尽可能重启机器。实在不行就删了从新安装。
第二:时间不一样步,时间不一样步也会报认证失败的错误,能够用date设置时间,只要不是差得太多就没事。
第三:是ssl的问题,在你用的这个客户端puppet已经作过其余的机器的客户端的状况下,由于已经生成的有证书,可能会和如今的冲突,把/var/lib/puppet/ssl这个文件夹删掉以后就好了。
1.3配置c/s模式的puppet的实验环境
Puppet的的客户端和服务端是靠ssl连接的,在服务端有一个自签名的根证书,在安装软件的时候自动生成。每一个客户端的证书要通过根证书签名才能和服务器链接。因此首先要在客户端执行下面的命令来请求服务器签名证书。
puppetd --server server.cbcv.net --test