设为首页 收藏本站
查看: 1884|回复: 0

[经验分享] CentOS 6.3安装Puppet3.x

[复制链接]

尚未签到

发表于 2015-9-16 12:22:34 | 显示全部楼层 |阅读模式
  一、系统环境:
  主机名                 IP(Static)                        系统                                           配置                                        备注
  puppetserver    192.168.100.241      CentOS-6.3-x86_64-minimal       1CPU,1G RAM,10G DISK,1网卡           Puppet Server
  client01             192.168.100.242      CentOS-6.3-x86_64-minimal       1CPU,1G RAM,10G DISK,1网卡           Puppet Client
  ***************************************************************************************************
  二、Puppet Server安装:
  1.安装前的准备:
  [iyunv@puppetserver ~]# sed -i "7s/enforcing/disabled/" /etc/selinux/config            /*关闭SELinux*/
  [iyunv@puppetserver ~]# vi /etc/sysconfig/iptables                  /*编辑防火墙打开8140和3000端口*/



  -A INPUT -m state --state NEW -p tcp --dport 8140 -j ACCEPT
  -A INPUT -m state --state NEW -p tcp --dport 3000 -j ACCEPT
  [iyunv@puppetserver ~]# reboot
  

  2.配置NTP服务:
  请参考:《CentOS 6.3下NTP服务安装和配置》
  

  3.配置hosts文件:
  [iyunv@puppetserver ~]# vi /etc/hosts
  192.168.100.241   puppetserver
  192.168.100.242   client01
  192.168.100.243   client02
  

  4.安装Puppet Server:
  [iyunv@puppetserver ~]# rpm -Uvh http://yum.puppetlabs.com/el/6/products/x86_64/puppetlabs-release-6-6.noarch.rpm
  [iyunv@puppetserver ~]# yum -y install puppet-server
  [iyunv@puppetserver ~]# chkconfig --level 3 puppetmaster on
  [iyunv@puppetserver ~]# service puppetmaster start
  

  5.安装配置Mysql数据库:
  [iyunv@puppetserver ~]# yum -y install mysql mysql-devel mysql-server
  [iyunv@puppetserver ~]# service mysqld start
  [iyunv@puppetserver ~]# mysqladmin -u root password 'chensh'        /*设置Mysql的root密码为chensh*/
  

  6.安装Dashboard:
  [iyunv@puppetserver ~]# yum -y install puppet-dashboard
  

  7.配置dashboard的database.yml文件:
  [iyunv@puppetserver ~]# vi /usr/share/puppet-dashboard/config/database.yml
  修改部分内容如下:



  production:
  database: dashboard

  username: root
password: chensh
encoding: utf8
adapter: mysql
  8.创建dashboard数据库,数据库名为dashboard:
  [iyunv@puppetserver ~]# mysql -uroot -pchensh -e 'create database dashboard character set utf8'
  

  9.配置dashboard的environment.rb文件:
  [iyunv@puppetserver ~]# vi /usr/share/puppet-dashboard/config/environment.rb
  将config.time_zone = 'UTC'改为config.time_zone = 'Beijing'
  

  10.修改/etc/sysconfig/puppet文件:
  [iyunv@puppetserver ~]# vi /etc/sysconfig/puppet


# The puppetmaster server    PUPPET_SERVER=puppetserver
  

  # If you wish to specify the port to connect to do so here
    PUPPET_PORT=8140
  

  # Where to log to. Specify syslog to send log messages to the system log.
    PUPPET_LOG=/var/log/puppet/puppet.log
  

  # You may specify other parameters to the puppet client here
  # PUPPET_EXTRA_OPTS=--waitforcert=500
  

  11.修改/etc/puppet/puppet.conf文件:

  [iyunv@puppetserver ~]# vi /etc/puppet/puppet.conf

  

  [main]
      # The Puppet log directory.
      # The default value is '$vardir/log'.
      logdir = /var/log/puppet
  

      # Where Puppet PID files are kept.
      # The default value is '$vardir/run'.
      rundir = /var/run/puppet
  

      # Where SSL certificates are kept.
      # The default value is '$confdir/ssl'.
      ssldir = $vardir/ssl
      reports = store,http,log           /*设置Dashbroad report*/
      server = puppetserver
  [agent]
      # The file in which puppetd stores a list of the classes
      # associated with the retrieved configuratiion.  Can be loaded in
      # the separate ``puppet`` executable using the ``--loadclasses``
      # option.
      # The default value is '$confdir/classes.txt'.
      classfile = $vardir/classes.txt
  

      # Where puppetd caches the local configuration.  An
      # extension indicating the cache format is added automatically.
      # The default value is '$confdir/localconfig'.
      localconfig = $vardir/localconfig
      runinterval = 3600                       /*设置检测时间间隔3600s*/
  

  

  12.初始化Dashboard数据库:

  [iyunv@puppetserver ~]# cd /usr/share/puppet-dashboard
  [iyunv@puppetserver puppet-dashboard]# rake RAILS_ENV=production db:migrate
  

  13.启动服务:
  [iyunv@puppetserver ~]# /etc/init.d/puppetmaster start                          /*puppet服务端进程,监听8140端口*/
  [iyunv@puppetserver ~]# /etc/init.d/puppet-dashboard start                   /*puppet WEB,默认3000端口*/
  [iyunv@puppetserver ~]# /etc/init.d/puppet-dashboard-workers start      /*新版本新增的进程,不启动dashboard上面看不到数据*/
  

  14.访问Dashboard WEB:http://192.168.100.241:3000
http://d.hiphotos.baidu.com/album/pic/item/b2de9c82d158ccbf0f35c54a18d8bc3eb1354130.jpg
  

  三、Puppet Client安装:

  1.安装前的准备:
  [iyunv@client01 ~]# sed -i "7s/enforcing/disabled/" /etc/selinux/config            /*关闭SELinux*/
  [iyunv@client01 ~]# vi /etc/sysconfig/iptables                  /*编辑防火墙打开8140端口*/



-A INPUT -m state --state NEW -p tcp --dport 8140 -j ACCEPT  [iyunv@client01 ~]# reboot
  

  2.配置NTP客户端服务:
  请参考:《CentOS 6.3下NTP服务安装和配置》
  

  3.配置hosts文件:
  [iyunv@client01 ~]# vi /etc/hosts
  192.168.100.241   puppetserver
  192.168.100.242   client01
  192.168.100.243   client02
  

  4.安装Puppet Client:
  [iyunv@client01 ~]# rpm -Uvh http://yum.puppetlabs.com/el/6/products/x86_64/puppetlabs-release-6-6.noarch.rpm
  [iyunv@client01 ~]# yum -y install puppet
  

  5.指定Puppet master名称:
  [iyunv@client01 ~]# echo ‘server = puppetserver’  >> /etc/puppet/puppet.conf

  [iyunv@client01 ~]# echo ‘reports = true’  >> /etc/puppet/puppet.conf             /*向服务端发送report信息*/

  

  6.启动Puppet Client:
  [iyunv@client01 ~]# chkconfig --level 3 puppet on
  [iyunv@client01 ~]# service puppet start
  

  四、客户端证书申请与服务端认证:
  
  1.客户端证书申请:
  [iyunv@client01 ~]# puppet agent --test --server puppetserver                            /*执行 puppet agent --test也可以*/
  Info: Creating a new SSL key for client01
  Info: Caching certificate for ca
  Info: Creating a new SSL certificate request for client01
  Info: Certificate Request fingerprint (SHA256): 69:45:4C:45:17:A9:7C:6F:24:04:8F:0B:F7:44:4D:4D:59:BA:4F:9D:71:35:04:3F:8F:29:0E:63:50:55:16:F3
  Exiting; no certificate found and waitforcert is disabled
  [iyunv@client01 ~]#
  

  2.服务器端查看请求签发的证书:
  [iyunv@puppetserver ~]# puppet cert --list
    "client01"               (SHA256) 69:45:4C:45:17:A9:7C:6F:24:04:8F:0B:F7:44:4D:4D:59:BA:4F:9D:71:35:04:3F:8F:29:0E:63:50:55:16:F3
  [iyunv@puppetserver ~]#
  

  3.服务器端签发证书:
  [iyunv@puppetserver ~]# puppet cert --sign client01                                                   /*多证书可执行puppet cert --sign --all批量签发*/
  Notice: Signed certificate request for client01
  Notice: Removing file Puppet::SSL::CertificateRequest client01 at '/var/lib/puppet/ssl/ca/requests/client01.pem'
  [iyunv@puppetserver ~]#
  

  4.查看已签发的证书:
  [iyunv@puppetserver~]# puppet cert --list --all
  + "client01"              (SHA256) 37:5D:E3:E4:09:07:BA:41:16:D5:16:0A:B0:1F:67:5A:20:BB:65:CB:21:EE:A6:C3:30:DB:C6:77:01:9F:EF:18
  [iyunv@puppetserver~]#
  ******************************************************************************
  五、证书注销:
  1.注销证书:
  [iyunv@puppetserver~]# puppet cert revoke client01
  Notice: Revoked certificate with serial 5
  [iyunv@puppetserver~]#
  

  2.查看证书当前状态:
  [iyunv@puppetserver~]# puppet cert list --all
  - "client01"              (SHA256) 37:5D:E3:E4:09:07:BA:41:16:D5:16:0A:B0:1F:67:5A:20:BB:65:CB:21:EE:A6:C3:30:DB:C6:77:01:9F:EF:18 (certificate revoked)
  [iyunv@puppetserver~]#
  

  3.重启puppetmaster:
  [iyunv@puppetserver ~]# /etc/init.d/puppetmaster restart

  

  六、证书删除:
  

  1.删除证书:
  [iyunv@puppetserver~]# puppet cert clean client01
  Notice: Revoked certificate with serial 5
  Notice: Removing file Puppet::SSL::Certificate client01 at '/var/lib/puppet/ssl/ca/signed/client01.pem'
  Notice: Removing file Puppet::SSL::Certificate client01 at '/var/lib/puppet/ssl/certs/client01.pem'
  [iyunv@puppetserver~]#
  

  2.重启puppetmaster:
  [iyunv@puppetserver ~]# /etc/init.d/puppetmaster restart
  

  3.删除客户单client01.pem文件 或者 SSL目录:
  [iyunv@client01 ~]# rm -rf /var/lib/puppet/ssl/certs/client01.pem                          /*删除client01.pem文件*/

  [iyunv@client01 ~]# rm -rf /var/lib/puppet/ssl/*                                                    /*删除ssl目录下的所有文件*/

  

  七、自动签发证书:
  [iyunv@puppetserver ~]# echo “*”   >>  /etc/puppet/autosign.conf
  ******************************************************************************
  

  问题总结:
  问题1:
  执行数据库初始化时报错如下:
  [iyunv@puppetmaster puppet-dashboard]#  rake RAILS_ENV=production db:migrate
  rake aborted!
  syntax error on line 49, col 2: `  encoding: utf8'
  (See full trace by running task with --trace)
  

  解决办法:
  [iyunv@puppetmaster puppet-dashboard]# vi /usr/share/puppet-dashboard/config/database.yml




  production:
  database: dashboard

  username: root
password:chensh
encoding: utf8
adapter: mysql
  将"password:chensh"改为"password: chensh"(即加一个“空格”符),再次执行"rake RAILS_ENV=production db:migrate"即可。
  

  问题2:
  [iyunv@client01 ~]# puppet agent --test
  Error: Could not request certificate: Connection timed out - connect(2)
  Exiting; failed to retrieve certificate and waitforcert is disabled
  [iyunv@client01 ~]#
  解决办法:
  请查看网络、SElinux、iptables以及hosts文件中的IP和主机名是否配置正确。
  

  问题3:
  [iyunv@puppetserver puppet]# /etc/init.d/puppet-dashboard-workers restart
  Rails Error: Unable to access log file. Please ensure that /usr/share/puppet-dashboard/log/production.log exists and is chmod 0666. The log level has been raised to WARN and the output directed to STDERR until the problem is fixed.
  

  解决办法:
  [iyunv@puppetserver puppet]#  chmod -R 666 /usr/share/puppet-dashboard/log/production.log
  

  

  

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-114463-1-1.html 上篇帖子: puppet_002 下篇帖子: tungsten
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表