buhao 发表于 2018-8-2 08:17:07

安装Puppet

  安装Puppet
  2.1 安装需求
  注:本文都是在Centos5下进行安装与配置。其它系统请参考官网。
  Ruby 1.8.2+ facter
  其它的库:
  base64
  cgi
  digest/md5
  etc
  fileutils
  ipaddr
  openssl
  strscan
  syslog
  uri
  webrick
  webrick/https
  xmlrpc
  
  2.2 Puppet 版本
  2.6.4
  0.25.5
  2.6.4和0.25.5 有功能和基本命令上有一些变化区别如下:
  puppetmasterd → puppet master
  puppetd → puppet agent
  puppet → puppet apply
  puppetca → puppet cert
  ralsh → puppet resource
  puppetrun → puppet kick
  puppetqd → puppet queue
  filebucket → puppet filebucket
  puppetdoc → puppet doc
  pi → puppet describe
  
  通常我们使用epel安装的puppet 都是0.25.5 。在安装前做注意版本的区别。本文采用2.6.4版本,以下配置都是在2.6.4版本上完成。
  其它系统相关的情况详见:(遗憾的是没有看到对windows的支持)http://projects.puppetlabs.com/projects/puppet/wiki/Downloading_Puppet
  2.3源码包安装
  源码包安装时,版本没有太多的区别。
  2.3.1 安装ruby 最好使用RPM包安装。可以采用epel 然后yum
  http://mirrors.sohu.com/fedora-epel/5Server/ 下载相应版本的epel
  yum install ruby ruby-devel ruby-doc*
  2.3.2 安装facter
  下载最新的版本:
  $ wget http://puppetlabs.com/downloads/facter/facter-latest.tgz
  $ gzip -d -c facter-latest.tgz | tar xf -
  $ cd facter-*
  $ sudo ruby install.rb #使用root 账号执行
  2.3.3# 下载最新版
  $ wget http://puppetlabs.com/downloads/puppet/puppet-latest.tgz
  # untar and install it
  $ gzip -d -c puppet-latest.tgz | tar xf -
  $ cd puppet-*
  $ sudo ruby install.rb # 使用rot安装
  2.4 yum安装
  1. Epel 安装0.25.5
  2. 采用如下方式安装2.6.4
  2.4.1配置yum源
  cd /etc/yum.repos.d/
  vim puppet.repo
  
  name=Puppet Labs Packages
  baseurl=http://yum.puppetlabs.com/base/
  enabled=0
  gpgcheck=0</code></pre>
  vim epel.repo
  name=Extra Packages for Enterprise Linux 5 -$basearch
  #baseurl=http://download.fedoraproject.org/pub/epel/5/$basearch
  mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-5&amp;arch=$basearch
  failovermethod=priority
  enabled=0
  gpgcheck=0
  
  name=epel puppet
  baseurl=http://tmz.fedorapeople.org/repo/puppet/epel/5/$basearch/
  enabled=0
  gpgcheck=0
  vim ruby.repo
  
  name=ruby
  baseurl=http://repo.premiumhelp.eu/ruby/
  gpgcheck=0
  enabled=0
  2.4.2 升级ruby
  puppet 2.6 需要 ruby 1.8.6 去运行 puppet-dashboard
  升级ruby
  # yum --enablerepo="ruby" update ruby
  如果你没有安装ruby 请使用:
  #yum -y install ruby
  2.4.3 安装puppet
  安装 Puppet Server
  Server端:On your puppetmaster server:
  # yum --enablerepo=epel,epel-puppet install puppet-server>
  Client 端:On your puppet client
  # yum --enablerepo="epel,epel-puppet" install puppet
  2.5 gem 安装
  $ wget http://puppetlabs.com/downloads/gems/facter-1.5.7.gem
  $ sudo gem install facter-1.5.7.gem
  $ wget http://puppetlabs.com/downloads/gems/puppet-0.25.1.gem
  $ sudo gem install puppet-0.25.1.gem
  三、配置Puppet
  3.1 配置服务器端
  3.1.1设置hostname
  #echo “puppetmaster.linuxtone.org” > /etc/hostname
  #hostname –F /etc/hostname
  3.1.2 配置site.pp
  vim /etc/puppet/site.pp
  node default {
  file { “/tmp/temp1.txt”: content => “hello,first puppet manifest”; }
  }
  3.2 配置客户端
  3.2.1设置hostname
  #echo “puppetclient.linuxtone.org” > /etc/hostname
  #hostname –F /etc/hostname
  3.1.2 指定hosts 或使用dns解析
  echo “192.168.1.100 puppetmaster.linuxtone.org” >> /etc/hosts
  3.3 验证
  3.3.1 客户端运行:
  puppetd --server master.example.com(puppetmaster.linuxtone.org) --test
  上面的命令让puppetd 从 master.example.com(puppetmaster.linuxtone.org) 去读取puppet配置文件. 第一次连接,双方会进行ssl证书的验证,这是一个新的客户端,在服务器端那里还没有被认证,因此需要在服务器端进行证书认证.
  在服务器端的机器上执行下面的命令来认证客户端的证书
  3.3.2 服务器端运行: puppetca -s client.example.com
  3.3.3 客户端再次运行puppetd –server puppetmaster.linuxtone.org --test
  这样验证就算是做完了。客户端会在/tmp目录生成内容为“hello,first puppet manifest”的temp1.txt 文件。
  3.4 自动验证
  在/etc/puppet 创建autosign.conf
  内容 *.linuxtone.org
页: [1]
查看完整版本: 安装Puppet