puppet服务端/客户端安装步骤:
CentOS6 yum源文件:CentOS6-Base-163.repo
puppet yum 源文件:puppetlabs.repo
保持各主机时间同步
使用CentOS yum源安装ntpdate
[root@mongo01 yum.repos.d]# yum install ntpdate
时间同步,并写入crontab
15 1 * * * /usr/sbin/ntpdate pool.ntp.org; hwclock -w >/dev/null 2>&1
服务端安装
1、
使用CentOS yum源安装系统所需的依赖包
yum -y install gcc* glib* glibc* setarch-2* make-3* glibc-2* libaio-0* libaio-devel* compat-libstdc++-33-3* compat-libstdc++-33-3* compat-gcc-34-3* compat-gcc-34-c++-3* libXp* openmotif* compat-db-4* libdb* lib*
2、
配置rhel6 puppet官方yum源
rpm -Uvh
使用puppet yum源安装ruby依赖包
yum install mysql* ruby-mysql ruby ruby-devel ruby-irb ruby-rdoc ruby-ri
yum install ruby*
yum -y install lib* --skip-broken
yum install ruby ruby-libs ruby-rdoc -y
安装ruby-1.8.7
[root@szlnmp01 yum.repos.d]# yum install ruby ruby-libs ruby-rdoc -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package ruby.x86_64 0:1.8.7.352-13.el6 will be installed
---> Package ruby-libs.x86_64 0:1.8.7.352-13.el6 will be installed
--> Processing Dependency: libreadline.so.5()(64bit) for package: ruby-libs-1.8.7.352-13.el6.x86_64
---> Package ruby-rdoc.x86_64 0:1.8.7.352-13.el6 will be installed
--> Processing Dependency: ruby-irb = 1.8.7.352-13.el6 for package: ruby-rdoc-1.8.7.352-13.el6.x86_64
--> Running transaction check
---> Package compat-readline5.x86_64 0:5.2-17.1.el6 will be installed
---> Package ruby-irb.x86_64 0:1.8.7.352-13.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=================================================================================================================================================================================
Package Arch Version Repository Size
=================================================================================================================================================================================
Installing:
ruby x86_64 1.8.7.352-13.el6 updates 534 k
ruby-libs x86_64 1.8.7.352-13.el6 updates 1.6 M
ruby-rdoc x86_64 1.8.7.352-13.el6 updates 377 k
Installing for dependencies:
compat-readline5 x86_64 5.2-17.1.el6 base 130 k
ruby-irb x86_64 1.8.7.352-13.el6 updates 314 k
Transaction Summary
=================================================================================================================================================================================
Install 5 Package(s)
Total size: 3.0 M
Installed size: 10 M
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : compat-readline5-5.2-17.1.el6.x86_64 1/5
Installing : ruby-libs-1.8.7.352-13.el6.x86_64 2/5
Installing : ruby-1.8.7.352-13.el6.x86_64 3/5
Installing : ruby-irb-1.8.7.352-13.el6.x86_64 4/5
Installing : ruby-rdoc-1.8.7.352-13.el6.x86_64 5/5
Verifying : ruby-1.8.7.352-13.el6.x86_64 1/5
Verifying : ruby-irb-1.8.7.352-13.el6.x86_64 2/5
Verifying : compat-readline5-5.2-17.1.el6.x86_64 3/5
Verifying : ruby-rdoc-1.8.7.352-13.el6.x86_64 4/5
Verifying : ruby-libs-1.8.7.352-13.el6.x86_64 5/5
Installed:
ruby.x86_64 0:1.8.7.352-13.el6 ruby-libs.x86_64 0:1.8.7.352-13.el6 ruby-rdoc.x86_64 0:1.8.7.352-13.el6
Dependency Installed:
compat-readline5.x86_64 0:5.2-17.1.el6 ruby-irb.x86_64 0:1.8.7.352-13.el6
Complete!
[root@szlnmp01 yum.repos.d]# ruby --version
ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
3、
修改hosts文件
[root@szlnmp01 scripts]# more /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
127.0.0.1 szips.tradeglobals.com
#192.168.11.55 salt-master
#192.168.11.51 salt-slave1
192.168.11.52 salt-slave2
192.168.11.53 iis01-op
192.168.11.55 szlnmp01.corp.dx
192.168.11.51 mongo01
4、
安装facter-2.2.0
安装puppet之前必须先安装facter,facter是一个系统盘点工具,收集主的一些资料,比如CPU,主机IP等,它收集到值发送给puppet服务器端,服务器端就可以根据不同的条件来对不同的节点机器生成不同的puppet配置文件
facter资源下载点
wget facter-2.2.0.tar.gz
tar xzvf facter-1.6.8.tar.gz
cd facter-2.2.0
ruby install.rb
5、
安装puppet-3.6.2服务端
wget
tar xzvf puppet-3.6.2.tar.gz
cd puppet-3.6.2
ruby install.rb
复制配置文件
cp /tmp/puppet-3.6.2/ext/redhat/fileserver.conf /etc/puppet/
cp /tmp/puppet-3.6.2/ext/redhat/puppet.conf /etc/puppet/
cp /tmp/puppet-3.6.2/ext/redhat/server.init /etc/init.d/puppetmaster
设置puppetmaster 服务开机启动
[root@puppetmaster puppet-3.6.2]# ls -l /etc/init.d/puppetmaster
-rwxr-xr-x 1 root root 3936 Sep 3 12:13 /etc/init.d/puppetmaster
[root@puppetmaster puppet-3.6.2]# chkconfig --add puppetmaster
[root@puppetmaster puppet-3.6.2]# chkconfig --level 35 puppetmaster on
创建puppet帐号
[root@puppetmaster puppet-3.6.2]# puppetmasterd --mkusers
6、
确认是否生成清单文件夹
[root@puppetmaster puppet-3.6.2]# ls -l /etc/puppet/
total 16
-rw-r--r-- 1 root root 2552 Sep 3 12:11 auth.conf
-rwxr-xr-x 1 root root 381 Sep 3 12:13 fileserver.conf
drwxr-xr-x 2 root root 4096 Sep 3 12:17 manifests
-rwxr-xr-x 1 root root 853 Sep 3 12:13 puppet.conf
7、
确认系统生成puppet用户
[root@puppetmaster puppet-3.6.2]# id puppet
uid=502(puppet) gid=502(puppet) groups=502(puppet)
[root@puppetmaster puppet]# cat /etc/passwd |grep puppet
puppet:x:502:502::/home/puppet:/bin/bash
8、
保证/var/lib/puppet/rrd目录存在且属主是puppet
[root@szlnmp01 puppet]# ls -l /var/lib/puppet/
total 44
drwxr-x--- 2 puppet puppet 4096 Sep 16 09:48 bucket
drwxr-xr-x 2 root root 4096 Sep 16 09:48 facts.d
drwxr-xr-x 2 root root 4096 Sep 16 09:48 lib
drwxr-x--- 2 puppet puppet 4096 Sep 16 09:48 log
drwxr-x--- 4 puppet puppet 4096 Sep 16 16:32 reports
drwxr-x--- 2 puppet puppet 4096 Sep 16 09:48 rrd
drwxr-xr-x 2 puppet puppet 4096 Sep 16 09:48 run
drwxr-x--- 2 puppet puppet 4096 Sep 16 09:48 server_data
drwxrwx--x 8 puppet puppet 4096 Sep 16 10:38 ssl
drwxr-xr-t 2 root root 4096 Sep 16 09:48 state
drwxr-x--- 4 puppet puppet 4096 Sep 16 11:31 yaml
9、
查看端口
[root@szlnmp01 ~]# netstat -Tanlp | grep 8140
tcp 0 0 0.0.0.0:8140 0.0.0.0:* LISTEN 7113/ruby
[root@szlnmp01 ~]# lsof -i:8140
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
puppet 7113 puppet 5u IPv4 32729 0t0 TCP *:8140 (LISTEN)
客户端安装
1、
windows客户端安装包puppet-3.6.2.msi
puppet agent for windows :
puppet agent -t 第一次连接,双方会进行ssl证书的验证,这是一个新的客户端,在服务器端那里还没有被认证,因此需要在服务器端进行证书认证
在服务端执行
puppet cert --list 列出待签名的证书
puppet cert -s iis01_op.contoso.test 批准当前证书
查看验证签名
[root@szlnmp01 puppet]# puppet cert --list -a
+ "iis01_op.contoso.test" (SHA256) C4:5F:B5:B4:BF:4C:C8:46:6D:CF:5A:8F:A7:E8:F2:13:F0:DC:A4:E8:69:7B:3A:00:1E:68:C0:0C:00:B4:9D:D2
+ "mongo01" (SHA256) F3:0F:7F:C5:16:3F:AF:FA:AC:7E:0D:02:31:86:1C:5E:47:9B:01:E6:6C:46:7F:8D:A5:7B:74:39:66:2B:1B:A4
+ "szlnmp01.corp.dx" (SHA256) A8:D2:71:11:25:C7:97:A8:12:DE:47:9F:E7:9F:0D:9C:75:76:73:F2:97:54:7B:EA:84:5F:56:DC:2D:A1:DB:65 (alt names: "DNS:puppet", "DNS:puppet.corp.dx", "DNS:szlnmp01.corp.dx")
回到客户端操作,从服务端取回已批准的证书
puppet agent --server szlnmp01.corp.dx --test
puppet agent --tags release -t 拉取服务端的文件
linux客户端安装
1、
使用CentOS yum源安装系统所需的依赖包
puppet agent for linux :
yum -y install gcc* glib* glibc* setarch-2* make-3* glibc-2* libaio-0* libaio-devel* compat-libstdc++-33-3* compat-libstdc++-33-3* compat-gcc-34-3* compat-gcc-34-c++-3* libXp* openmotif* compat-db-4* libdb* lib*
2、
配置rhel6 puppet官方yum源
rpm -Uvh
使用puppet yum源安装ruby依赖包
yum install mysql* ruby-mysql ruby ruby-devel ruby-irb ruby-rdoc ruby-ri
yum install ruby*
yum -y install lib* --skip-broken
yum install ruby ruby-libs ruby-rdoc -y
yum安装ruby-1.8.7
[root@mongo01 yum.repos.d]# yum install ruby ruby-libs ruby-rdoc -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package ruby.x86_64 0:1.8.7.352-13.el6 will be installed
---> Package ruby-libs.x86_64 0:1.8.7.352-13.el6 will be installed
--> Processing Dependency: libreadline.so.5()(64bit) for package: ruby-libs-1.8.7.352-13.el6.x86_64
---> Package ruby-rdoc.x86_64 0:1.8.7.352-13.el6 will be installed
--> Processing Dependency: ruby-irb = 1.8.7.352-13.el6 for package: ruby-rdoc-1.8.7.352-13.el6.x86_64
--> Running transaction check
---> Package compat-readline5.x86_64 0:5.2-17.1.el6 will be installed
---> Package ruby-irb.x86_64 0:1.8.7.352-13.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=================================================================================================================================================================================
Package Arch Version Repository Size
=================================================================================================================================================================================
Installing:
ruby x86_64 1.8.7.352-13.el6 updates 534 k
ruby-libs x86_64 1.8.7.352-13.el6 updates 1.6 M
ruby-rdoc x86_64 1.8.7.352-13.el6 updates 377 k
Installing for dependencies:
compat-readline5 x86_64 5.2-17.1.el6 base 130 k
ruby-irb x86_64 1.8.7.352-13.el6 updates 314 k
Transaction Summary
=================================================================================================================================================================================
Install 5 Package(s)
Total size: 3.0 M
Installed size: 10 M
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : compat-readline5-5.2-17.1.el6.x86_64 1/5
Installing : ruby-libs-1.8.7.352-13.el6.x86_64 2/5
Installing : ruby-1.8.7.352-13.el6.x86_64 3/5
Installing : ruby-irb-1.8.7.352-13.el6.x86_64 4/5
Installing : ruby-rdoc-1.8.7.352-13.el6.x86_64 5/5
Verifying : ruby-1.8.7.352-13.el6.x86_64 1/5
Verifying : ruby-irb-1.8.7.352-13.el6.x86_64 2/5
Verifying : compat-readline5-5.2-17.1.el6.x86_64 3/5
Verifying : ruby-rdoc-1.8.7.352-13.el6.x86_64 4/5
Verifying : ruby-libs-1.8.7.352-13.el6.x86_64 5/5
Installed:
ruby.x86_64 0:1.8.7.352-13.el6 ruby-libs.x86_64 0:1.8.7.352-13.el6 ruby-rdoc.x86_64 0:1.8.7.352-13.el6
Dependency Installed:
compat-readline5.x86_64 0:5.2-17.1.el6 ruby-irb.x86_64 0:1.8.7.352-13.el6
Complete!
[root@mongo01 yum.repos.d]# ruby --version
ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
3、
修改hosts文件
[root@mongo01 puppet]# more /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.11.52 mongo02
#127.0.0.1 szips.tradeglobals.com
192.168.11.61 pubip1
192.168.11.62 pubip1
192.168.11.55 szlnmp01.corp.dx
192.168.11.51 mongo01
4、
安装facter-2.2.0
安装puppet之前必须先安装facter,facter是一个系统盘点工具,收集主的一些资料,比如CPU,主机IP等,它收集到值发送给puppet服务器端,服务器端就可以根据不同的条件来对不同的节点机器生成不同的puppet配置文件
facter资源下载点
wget facter-2.2.0.tar.gz
tar xzvf facter-1.6.8.tar.gz
cd facter-2.2.0
ruby install.rb
5、
使用CentOS yum源安装lib依赖包
[root@mongo01 yum.repos.d]# mv CentOS6-Base-163.repo.bak CentOS6-Base-163.repo
You have mail in /var/spool/mail/root
[root@mongo01 yum.repos.d]# ls
bak CentOS6-Base-163.repo CentOS-Base.repo.bak CentOS-Debuginfo.repo.bak CentOS-Media.repo.bak CentOS-Vault.repo.bak puppetlabs.repo.bak
[root@mongo01 yum.repos.d]# yum install libselinux-ruby
Loaded plugins: fastestmirror, refresh-packagekit
Loading mirror speeds from cached hostfile
base | 3.7 kB 00:00
extras | 3.3 kB 00:00
updates | 3.4 kB 00:00
updates/primary_db | 5.3 MB 00:09
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package libselinux-ruby.x86_64 0:2.0.94-5.3.el6_4.1 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=================================================================================================================================================================================
Package Arch Version Repository Size
=================================================================================================================================================================================
Installing:
libselinux-ruby x86_64 2.0.94-5.3.el6_4.1 base 99 k
Transaction Summary
=================================================================================================================================================================================
Install 1 Package(s)
Total download size: 99 k
Installed size: 203 k
Is this ok [y/N]: y
Downloading Packages:
libselinux-ruby-2.0.94-5.3.el6_4.1.x86_64.rpm | 99 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : libselinux-ruby-2.0.94-5.3.el6_4.1.x86_64 1/1
Verifying : libselinux-ruby-2.0.94-5.3.el6_4.1.x86_64 1/1
Installed:
libselinux-ruby.x86_64 0:2.0.94-5.3.el6_4.1
Complete!
6、
使用puppet yum源安装puppet-3.6.2 linux客户端
[root@mongo01 yum.repos.d]# mv puppetlabs.repo.bak puppetlabs.repo
[root@mongo01 yum.repos.d]# ls
bak CentOS6-Base-163.repo.bak CentOS-Base.repo.bak CentOS-Debuginfo.repo.bak CentOS-Media.repo.bak CentOS-Vault.repo.bak puppetlabs.repo
[root@mongo01 yum.repos.d]# yum install puppet-3.6.2
Loaded plugins: fastestmirror, refresh-packagekit
Loading mirror speeds from cached hostfile
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package puppet.noarch 0:3.6.2-1.el5 will be installed
--> Processing Dependency: ruby-rgen >= 0.6.5 for package: puppet-3.6.2-1.el5.noarch
--> Processing Dependency: ruby-augeas for package: puppet-3.6.2-1.el5.noarch
--> Processing Dependency: ruby-shadow for package: puppet-3.6.2-1.el5.noarch
--> Running transaction check
---> Package ruby-augeas.x86_64 0:0.4.1-3.el5 will be installed
--> Processing Dependency: augeas-libs >= 0.8.0 for package: ruby-augeas-0.4.1-3.el5.x86_64
--> Processing Dependency: libaugeas.so.0(AUGEAS_0.8.0)(64bit) for package: ruby-augeas-0.4.1-3.el5.x86_64
--> Processing Dependency: libaugeas.so.0(AUGEAS_0.10.0)(64bit) for package: ruby-augeas-0.4.1-3.el5.x86_64
--> Processing Dependency: libaugeas.so.0(AUGEAS_0.11.0)(64bit) for package: ruby-augeas-0.4.1-3.el5.x86_64
--> Processing Dependency: libaugeas.so.0(AUGEAS_0.1.0)(64bit) for package: ruby-augeas-0.4.1-3.el5.x86_64
--> Processing Dependency: libaugeas.so.0(AUGEAS_0.12.0)(64bit) for package: ruby-augeas-0.4.1-3.el5.x86_64
--> Processing Dependency: libaugeas.so.0()(64bit) for package: ruby-augeas-0.4.1-3.el5.x86_64
---> Package ruby-rgen.noarch 0:0.6.5-2.el5 will be installed
---> Package ruby-shadow.x86_64 1:2.2.0-2.el5 will be installed
--> Running transaction check
---> Package augeas-libs.x86_64 0:1.1.0-2.el5 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=================================================================================================================================================================================
Package Arch Version Repository Size
=================================================================================================================================================================================
Installing:
puppet noarch 3.6.2-1.el5 puppetlabs-products 1.3 M
Installing for dependencies:
augeas-libs x86_64 1.1.0-2.el5 puppetlabs-deps 356 k
ruby-augeas x86_64 0.4.1-3.el5 puppetlabs-deps 22 k
ruby-rgen noarch 0.6.5-2.el5 puppetlabs-deps 349 k
ruby-shadow x86_64 1:2.2.0-2.el5 puppetlabs-deps 13 k
Transaction Summary
=================================================================================================================================================================================
Install 5 Package(s)
Total download size: 2.1 M
Installed size: 2.1 M
Is this ok [y/N]: y
Downloading Packages:
(1/5): augeas-libs-1.1.0-2.el5.x86_64.rpm | 356 kB 00:05
(2/5): puppet-3.6.2-1.el5.noarch.rpm | 1.3 MB 00:08
(3/5): ruby-augeas-0.4.1-3.el5.x86_64.rpm | 22 kB 00:00
(4/5): ruby-rgen-0.6.5-2.el5.noarch.rpm | 349 kB 00:02
(5/5): ruby-shadow-2.2.0-2.el5.x86_64.rpm | 13 kB 00:00
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 116 kB/s | 2.1 MB 00:18
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : 1:ruby-shadow-2.2.0-2.el5.x86_64 1/5
Installing : augeas-libs-1.1.0-2.el5.x86_64 2/5
Installing : ruby-augeas-0.4.1-3.el5.x86_64 3/5
Installing : ruby-rgen-0.6.5-2.el5.noarch 4/5
Installing : puppet-3.6.2-1.el5.noarch 5/5
Verifying : ruby-rgen-0.6.5-2.el5.noarch 1/5
Verifying : augeas-libs-1.1.0-2.el5.x86_64 2/5
Verifying : ruby-augeas-0.4.1-3.el5.x86_64 3/5
Verifying : 1:ruby-shadow-2.2.0-2.el5.x86_64 4/5
Verifying : puppet-3.6.2-1.el5.noarch 5/5
Installed:
puppet.noarch 0:3.6.2-1.el5
Dependency Installed:
augeas-libs.x86_64 0:1.1.0-2.el5 ruby-augeas.x86_64 0:0.4.1-3.el5 ruby-rgen.noarch 0:0.6.5-2.el5 ruby-shadow.x86_64 1:2.2.0-2.el5
Complete!
[root@mongo01 puppet]# service puppet restart
Stopping puppet agent: [ OK ]
Starting puppet agent: [ OK ]
证书的颁发和认证
puppet agent -t 第一次连接,双方会进行ssl证书的验证,这是一个新的客户端,在服务器端那里还没有被认证,因此需要在服务器端进行证书认证
在服务端执行
puppet cert --list 列出待签名的证书
puppet cert -s iis01_op.contoso.test 批准当前证书
查看验证签名
[root@szlnmp01 puppet]# puppet cert --list -a
+ "iis01_op.contoso.test" (SHA256) C4:5F:B5:B4:BF:4C:C8:46:6D:CF:5A:8F:A7:E8:F2:13:F0:DC:A4:E8:69:7B:3A:00:1E:68:C0:0C:00:B4:9D:D2
+ "mongo01" (SHA256) F3:0F:7F:C5:16:3F:AF:FA:AC:7E:0D:02:31:86:1C:5E:47:9B:01:E6:6C:46:7F:8D:A5:7B:74:39:66:2B:1B:A4
+ "szlnmp01.corp.dx" (SHA256) A8:D2:71:11:25:C7:97:A8:12:DE:47:9F:E7:9F:0D:9C:75:76:73:F2:97:54:7B:EA:84:5F:56:DC:2D:A1:DB:65 (alt names: "DNS:puppet", "DNS:puppet.corp.dx", "DNS:szlnmp01.corp.dx")
回到客户端操作,从服务端取回已批准的证书
puppet agent --server szlnmp01.corp.dx --test
puppet agent --tags release -t 拉取服务端的文件
以上服务端和客户端均安装完成后,若SSL有问题,则需要重启各个主机
阅读(2131) | 评论(0) | 转发(0) |