码迷,mamicode.com
首页 > 其他好文 > 详细

Puppet详细部署指南

时间:2016-07-06 22:01:05      阅读:303      评论:0      收藏:0      [点我收藏+]

标签:puppet-dashboard puppet

一、安装环境

  需要两台计算机或虚拟机;一台是server,一台是client;具体配置如下:

cat /etc/hosts

127.0.0.1       localhost.localdomain localhost

192.168.*.200 server.example.com  server

192.168.*.180 client.example.com  client

Note:主机名必须是字母和数字组合,不能有特殊符号如 _ ;否则在调试阶段出现莫名其妙问题;

Note:所有主机要求时钟同步

yum install ntp

chkconfig ntp on

ntpdate pool.ntp.org

Note:配置epel源

rpm -ivh https://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

yum-config-manager --enable epel

yum update


二、安装Puppet服务

1、服务端

yum install ruby ruby-libs ruby-rdoc #Puppet需要Ruby支持,查看命令行帮助需安装ruby-rdoc

yum install puppet-server

chkconfig puppet on

/etc/init.d/puppetmaster start

关闭iptables和Selinux

2、客户端

yum install puppet

在/etc/puppet/puppet.conf中[agent]加server = server.example.com指定服务端

3、在服务端配置自动签发证书设置

cat /etc/puppet/autosign.conf 

*.example.com

在/etc/puppet/puppet.conf中[main]加autosign = true使autosign.conf生效

/etc/init.d/puppetmaster restart

4、在客户端进行debug测试生成证书

puppet agent --no-daemonize --onetime --verbose --debug

5、在服务端查看证书信息

puppet cert list -all

  "server.example.com"     (25:11:E6:A6:21:55:A3:4F:30:E4:C7:50:92:4C:63:50) (alt names: "DNS:puppet", "DNS:puppet.example.com", "DNS:server.example.com")

+ "client.example.com" (9C:DA:6F:89:C3:5C:4E:73:5A:9F:A6:35:66:FE:53:8E)

前面带“+”表示证书签发成功

6、例子测试

服务端

cat /etc/puppet/manifests/site.pp 

node default {

    file {

        "/tmp/helloworld.txt": content => "hello, world";

    }

}

Note:

err: Could not retrieve catalog from remote server: Error 400 on SERVER: Could not find default node or by name with ‘client.example.com, client.example, client‘ on node client.example.com

warning: Not using cache on failed catalog

err: Could not retrieve catalog; skipping run

可能是/etc/puppet/manifests/site.pp 这个文件书写格式有问题

客户端

puppet agent --test --server=server.example.com

cat /tmp/helloworld.txt 

hello, world


三、在服务端安装Puppet的dashboard工具

1、安装设置mysql

yum install mysql mysql-devel mysql-server -y

在/etc/my.cnf中[mysqld]下加入max_allowed_packet = 32M

/etc/init.d/mysqld start

chkconfig mysqld on

mysqladmin -u root password ‘123456‘ 

cat create_dashboard.sql #创建数据库

CREATE DATABASE dashboard CHARACTER SET utf8;

CREATE USER ‘dashboard‘@‘localhost‘ IDENTIFIED BY ‘123456‘;

GRANT ALL PRIVILEGES ON dashboard.* TO ‘dashboard‘@‘localhost‘;

FLUSH PRIVILEGES;


2、设置yum源和安装puppet-dashboard

由于puppet-dashboard不在centos官方及epel源里,因此要添加puppetlabs源

rpm -ivh http://yum.puppetlabs.com/el/6.4/products/x86_64/puppetlabs-release-6-12.noarch.rpm

yum install puppet-dashboard


3、配置puppet-dashboard

vi /usr/share/puppet-dashboard/config/database.yml

 46 production:

 47   database: dashboard                                            48   username: dashboard

 49   password: 123456

 50   encoding: utf8

 51   adapter: mysql

vi /usr/share/puppet-dashboard/config/environment.rb

 52   config.time_zone = ‘Beijing‘ 

分别是修改数据库配置,时区;

初始化数据库:

rake RAILS_ENV=production db:migrate

检查是否导入成功:

mysql> show tables;

+------------------------------+

| Tables_in_dashboard          |

+------------------------------+

| delayed_job_failures         |

| delayed_jobs                 |

| metrics                      |

| node_class_memberships       |

| node_classes                 |

| node_group_class_memberships |

| node_group_edges             |

| node_group_memberships       |

| node_groups                  |

| nodes                        |

| old_reports                  |

| parameters                   |

| report_logs                  |

| reports                      |

| resource_events              |

| resource_statuses            |

| schema_migrations            |

| timeline_events              |

+------------------------------+

18 rows in set (0.00 sec)


4、启动并运行dashboard(WEBrick方式)

/etc/init.d/puppetmaster restart

/etc/init.d/puppet-dashboard start


5、访问http://server.example.com:3000/


Puppet详细部署指南

标签:puppet-dashboard puppet

原文地址:http://liuk1303.blog.51cto.com/10449284/1811601

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!