Puppet3.5源码包安装和配置

简介:
Puppet采用C/S星状的结构,所有的客户端和一个或几个服务器交互。每个客户端周期的(默认半个小时)向服务器发送请求,获得其最新的配置信息,保证和该配置信息同步。每个puppet客户端每半小时(可以设置)连接一次服务器端, 下载最新的配置文件,并且严格按照配置文件来配置服务器. 配置完成以后,puppet客户端可以反馈给服务器端一个消息. 如果出错,也会给服务器端反馈一个消息。
一、在master和client安装puppet
1、关闭iptables和selinux

2、在hosts添加master和client 主机信息
[root@master ~]# vi /etc/hosts
192.168.1.10    master
192.168.1.11    client

3、在master上安装puppet
1)创建相关目录以及下载所需软件
[root@master ~]# mkdir /tmp/soft/
[root@master ~]# cd /tmp/soft/
[root@master soft]# wget
[root@master soft]# wget https://downloads.puppetlabs.com/facter/facter-2.0.1.tar.gz
[root@master soft]# wget

2)安装ruby
[root@master soft]# tar fzvx ruby-2.1.2.tar.gz
[root@master soft]# cd ruby-2.1.2
[root@master ruby-2.1.2]# ./configure --prefix=/usr/local/ruby
[root@master ruby-2.1.2]# make && make install
#添加环境变量
[root@master ruby-2.1.2]# vi /etc/profile.d/ruby.sh
export PATH=$PATH:/usr/local/ruby/bin
[root@master ruby-2.1.2]# source /etc/profile
#查看ruby版本信息
[root@master ruby-2.1.2]# ruby -v
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]

3)安装facter
1234 [root@master ruby-2.1.2]# cd ..
[root@master soft]# tar zfvx facter-2.0.1.tar.gz
[root@master soft]# cd facter-2.0.1
[root@master facter-2.0.1]# ruby install.rb

4)安装puppet

1234567891011 [root@master facter-2.0.1]# cd ..
[root@master soft]# useradd -M -s /sbin/nologin puppet
[root@master soft]# tar fzvx puppet-3.5.1.tar.gz
[root@master soft]# cd puppet-3.5.1
[root@master puppet-3.5.1]# ruby install.rb
[root@master puppet-3.5.1]# cp ext/RedHat/puppet.conf /etc/puppet/puppet.conf
[root@master puppet-3.5.1]# vi /etc/puppet/puppet.conf
#在[main]中增加:
server = master      #master的主机名
certname = master    #master的主机名
pluginsync = false

5)启动puppet

[root@master puppet-3.5.1]# puppet master
[root@master puppet-3.5.1]# ps -ef |grep master
puppet  11503    1  0 12:24 ?        00:00:01 /usr/local/ruby/bin/ruby /usr/local/ruby/bin/puppet master

4、在client上安装puppet

1)安装ruby
[root@client soft]# tar fzvx ruby-2.1.2.tar.gz
[root@client soft]# cd ruby-2.1.2
[root@client ruby-2.1.2]# ./configure --prefix=/usr/local/ruby
[root@client ruby-2.1.2]# make && make install
#添加环境变量
[root@client ruby-2.1.2]# vi /etc/profile.d/ruby.sh
export PATH=$PATH:/usr/local/ruby/bin
[root@client ruby-2.1.2]# source /etc/profile
#查看ruby版本信息
[root@client ruby-2.1.2]# ruby -v
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]

2)安装facter
[root@client ruby-2.1.2]# cd ..
[root@client soft]# tar zfvx facter-2.0.1.tar.gz
[root@client soft]# cd facter-2.0.1

3)安装puppet

[root@client facter-2.0.1]# cd ..
[root@client soft]# useradd -M -s /sbin/nologin puppet
[root@client soft]# tar fzvx puppet-3.5.1.tar.gz
[root@client soft]# cd puppet-3.5.1
[root@client puppet-3.5.1]# ruby install.rb
[root@client puppet-3.5.1]# cp ext/redhat/puppet.conf /etc/puppet/puppet.conf
[root@client puppet-3.5.1]# vi /etc/puppet/puppet.conf
#在[main]中增加:
server = master      #master的主机名
pluginsync = false

二、puppet证书认证

puppet为了安全,采用ssl隧道通信,因此需要申请证书来验证的。
1)Client agent连接server
[root@client ~]# puppet agent --server=master

2)在master上查看申请证书请求
[root@master ~]# puppet cert --list
  "client" (SHA256) 02:EC:D4:CD:02:29:D2:31:3A:CA:9A:56:BD:4C:85:71:6A:8B:80:EB:E5:96:5D:97:41:C5:89:F5:23:B9:F6:97

3)在master上签发证书
[root@master ~]# puppet cert --sign client
Notice: Signed certificate request for client
Notice: Removing file Puppet::SSL::CertificateRequest client at '/etc/puppet/ssl/ca/requests/client.pem'
#查看证书, " + " ,表示已经签名成功
[root@master ~]# puppet cert -all
+ "client" (SHA256) 1F:41:43:6E:34:0E:69:4D:5C:51:40:92:57:CA:5F:F0:98:58:11:38:D6:2B:46:67:63:55:6E:DC:7E:F2:BC:BA
+ "master" (SHA256) DF:31:4C:9A:89:FF:34:7B:87:81:0D:03:B8:86:66:78:44:BD:02:6D:C1:C9:1F:0A:27:54:8A:31:32:47:1F:07

三、内容同步验证

1)在master上创建一个site.pp文件
[root@master ~]# vi /etc/puppet/manifests/site.pp
node default { file { "/tmp/test.txt": content => "Hello, First puppet test!"} }

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/03df3f2ee24c5cf9dd8e43cee6dbd1b5.html