免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2240 | 回复: 0
打印 上一主题 下一主题

在Ubuntu上配置自动集中管理工具Puppet [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-01-26 18:53 |只看该作者 |倒序浏览
作者: Kent Brede
最后修改: 02/25/07
本文基于: http://reductivelabs.com/trac/puppet/wiki/InstallationGuide
译者: Ken Zhao, cn.zhaoke.com
译文网址: http://blog.zhaoke.com/90.html
介绍
本文将通过循序渐进的指南, 介绍如何在一台机器上安装Puppet的服务器端程序和在另一台机器上安装Puppet客户端程序. 然后我们使用一个简单的测试来确认Puppet是否正常工作.
如果你不熟悉Puppet, 它是一个配置自动化工具, 你可以集中管理多个存在于您网络当中的*nix操作系统. Puppet支持集中管理系统的重要资源, 比如: 文件, 软件包, 用户, 服务, cron作业, 挂载文件系统, 等. 更多完整的描述请访问Reductive Labs网站.
背景
本文的安装系统使用Ubuntu 6.06 LTS Server, 但是对于其它主要的Debian/Ubuntu版本只需做少量修改.
在本文撰写其间, 当前Puppet软件包的Ubuntu版本可以在Feisty中找到. 不推荐使用当前Debian软件库中的Puppet软件包(不稳定).
在本文当中, 我们使用example.com作为域名. 服务器的主机名为”puppet”, 服务器的IP地址为192.168.10.1. 客户端的主机名为”pclient”, 客户端的IP地址为192.168.10.2.
1. 网络需求
如果你的网络没有建立DNS服务, 请在你的服务器和客户机端确认hosts文件包含了各自的主机名及对应的IP地址. 在这一环节, 请把下面的数据添加到/etc/hosts文件, 使用您熟悉的文本编辑器, 根据你的网络设置添加下面两行.
192.168.10.1 puppet.example.com puppet
192.168.10.2 pclient.example.com pclient
服务器程序运行在8140端口上. 请确认两台机器之间没有任何防火墙阻止端口8140的通信.
2. Apt安装
我们需要的大多软件包都可以在软件仓库中找到. 如果下面的几行在”sources.list”文件中没有被注释, 请使用您熟悉的文本编辑器, 在服务器端找到并注释掉.
puppet:# vim /etc/apt/sources.list
# deb http://us.archive.ubuntu.com/ubuntu/ dapper universe
# deb http://security.ubuntu.com/ubuntu dapper-security universe
我们使用了稍旧的Ubuntu版本, 从而可以通过配置apt方便从Feisty中获得Puppet软件包. 请根据您的操作系统版本修改源文件. 如果你不熟悉接下来的步骤, 请查阅Apt-Howto的3.10章节.
打开”sources.list”文件, 然后添加下面两行.
puppet:# vim /etc/apt/sources.list
deb http://us.archive.ubuntu.com/ubuntu/ feisty universe
deb http://security.ubuntu.com/ubuntu feisty-security universe
更新您的源代码列表.
puppet:# apt-get update
**在”pclient”端执行同样的步骤.**
接下来, 我们对Puppet安装相关的apt进行配置, 不要限制从Dapper软件仓库获得其它的软件包. 添加下面几行到”preferences”文件.
puppet:# vim /etc/apt/preferences
Package: *
Pin: release a=dapper
Pin-Priority: 700
Package: facter
Pin: release a=feisty
Pin-Priority: 500
Package: puppet
Pin: release a=feisty
Pin-Priority: 500
Package: puppetmaster
Pin: release a=feisty
Pin-Priority: 500
客户端:
pclient:# vim /etc/apt/preferences
Package: *
Pin: release a=dapper
Pin-Priority: 700
Package: facter
Pin: release a=feisty
Pin-Priority: 500
Package: puppet
Pin: release a=feisty
Pin-Priority: 500
3. 软件需求
在准备安装Puppet当中, 我们需要在服务器和客户机上安装几个库文件和软件包. 另外, 如果这一步在后面执行, 请确认软件包的依赖性问题.
puppet:# apt-get install libopenssl-ruby rdoc irb1.8 libopenssl-ruby1.8 libreadline-ruby1.8 libruby1.8 rdoc1.8 ruby1.8
pclient:# apt-get install libopenssl-ruby rdoc irb1.8 libopenssl-ruby1.8 libreadline-ruby1.8 libruby1.8 rdoc1.8 ruby1.8
4. 客户机端安装
从Feisty安装Puppet和Facter.
pclient:# apt-get -t feisty install facter puppet
5. 服务器端安装
安装Puppet, Facter和Puppetmaster. 后续安装脚本将尝试启动服务器, 如果发生错误, 屏幕将来打印出来. 请不要担心, 我们将会在第六步骤创建一个清单.
puppet:# apt-get -t feisty install facter puppet puppetmaster
…..
Starting puppet configuration management tool master server
Manifest /etc/puppet/manifests/site.pp must exist [fail]
6. 服务器端准备
在运行puppetmasterd之前, 服务器端(运行puppetmasterd守护进程)需要一个清单(manifest). 下面我写了一个清单告诉puppet程序在客户端上创建一个”/tmp/testfile”文件.
puppet:# vim /etc/puppet/manifests/site.pp
# Create “/tmp/testfile” if it doesn’t exist.
class test_class {
file { “/tmp/testfile”:
ensure => present,
mode => 644,
owner => root,
group => root
}
}
# tell puppet on which client to run the class
node pclient {
include test_class
}
现在启动puppet服务程序.
puppet:# /etc/init.d/puppetmaster start
7. 客户端准备
默认情况, 客户机将通过你的网络连接主机名叫做”puppet”的服务器. 如果您服务器的主机名不是”puppet”, 这样你需要添加一个指令到puppetd的配置文件”puppetd.conf”. 为了更好的演示, 我们配置了该选项.
请使用你熟悉的文本编辑器打开”/etc/puppet/puppetd.conf”文件, 然后按下面提示添加”server=puppet.example.com”.
pclient:# vim /etc/puppet/puppetd.conf
[puppetd]
server = puppet.example.com
# Make sure all log messages are sent to the right directory
# This directory must be writable by the puppet user
logdir=/var/log/puppet
vardir=/var/lib/puppet
rundir=/var/run
8. 签名秘钥
为了使两个系统安全的通信, 我们需要创建签名的SSL证书. 你将需要登陆到客户和服务器端执行下面的步骤.
在客户端上运行.
pclient:# puppetd –server puppet.example.com –waitforcert 60 –test
你将看到下面的消息.
err: No certificate; running with reduced functionality.
info: Creating a new certificate request for pclient.example.con
info: Requesting certificate
warning: peer certificate won’t be verified in this SSL session
notice: Did not receive certificate
(注:
err: 无证书; 简化运行. [错误]
info: 为pclient.example.com创建新的证书请求 [信息]
info: 正在请求证书 [信息]
warning: 点证书将不会在此SSL会话中被验证 [警告]
notice: 不接受证书 [注意])
接下来, 在服务器端运行下面的命令来确认客户端正在得等待证书被签名.
puppet:# puppetca –list
pclient.example.con
然后签名证书
puppet:# puppetca –sign pclient.example.com
Signed pclient.example.com
如果一切, 你将在pclient客户端看到如下消息.
info: Requesting certificate
warning: peer certificate won’t be verified in this SSL session
notice: Ignoring –listen on onetime run
info: Caching configuration at /etc/puppet/localconfig.yaml
notice: Starting configuration run
notice: //pclient/test_class/File[/tmp/testfile]/ensure: created
info: Creating state file /var/lib/puppet/state/state.yaml
notice: Finished configuration run in 0.11 seconds
(注:
info: 正在请求证书 [信息]
warning: 点证书将不会在此SSL会话中被验证 [警告]
notice: 忽略 — 运行时监听 [注意]
info: 缓存配置到/etc/puppet/localconfi.yaml [信息]
notice: 开始运行配置 [注意]
notice: //pclient/test_class/File[/tmp/testfile]/ensure: 改文件被创建 [注意]
info: 创建状态文件/var/lib/puppet/state/state.yaml [信息]
notice: 完成运行配置, 耗时0.11秒 [注意] )
9. 测试
检查和确认文件是否已创建.
pclient:# ls -l /tmp/testfile
-rw-r–r– 1 root root 0 2007-02-18 18:28 /tmp/testfile
修改清单(manifest)和Puppset的文件权限模式. 修改行, “mode=>644,”为”mode=>600,”
# Create “/tmp/testfile” if it doesn’t exist.
class test_class {
file { “/tmp/testfile”:
ensure => present,
mode => 600,
owner => root,
group => root
}
}
# tell puppet on which client to run the class
node pclient {
include test_class
在客户端上以详细模式(verbose)和仅一次模式运行puppetd服务程序.
pclient:# puppetd -v -o
你将看到下面的消息, /tmp/testfile的文件权限将从644改为600.
notice: Ignoring –listen on onetime run
info: Config is up to date
notice: Starting configuration run
notice: //pclient/test_class/File[/tmp/testfile]/mode: mode changed ‘644′ to ‘600′
notice: Finished configuration run in 0.26 seconds
(注:
notice: 忽略 — 运行时监听 [注意]
info: Config配置已更新 [信息]
notice: 开始运行配置 [注意]
notice: //pclient/test_class/File[/tmp/testfile]/mode: 模式从’644′修改为’600′ [注意]
notice: 完成运行配置, 耗时0.26秒 [注意] )
然后确认工作是否正确完成.
pclient:# ls -l /tmp/testfile
-rw——- 1 root root 0 2007-02-18 18:28 /tmp/testfile
10. 结论
配置, 测试已经完成, 你已经成功安装了Puppet. 下面的步骤是创建一个功能清单, 测试更多的选项, 然后在客户端启动puppetd守护程序. 默认情况, Puppetd将会每隔30分钟自动重新启动它的配置.
pclient:# /etc/init.d/puppet start
更多信息请访问Reductive Labs网站. 如果你需要即时的帮助, 请加入Puppet Users邮件列表或者irc.freenode.net的#puppet.
原文
Configuration Automation & Centralized Management With Puppet on Ubuntu
备注
转载请保持文章完整性, 欢迎到blog.zhaoke.com网站与赵珂交流.
               
               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/99907/showart_2161530.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP