Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2767329
  • 博文数量: 389
  • 博客积分: 4177
  • 博客等级: 上校
  • 技术积分: 4773
  • 用 户 组: 普通用户
  • 注册时间: 2008-11-16 23:29
文章分类

全部博文(389)

分类: LINUX

2014-11-27 21:59:41

                                    使用Puppet部署软件包

     当要在很多服务器上安装软件时,使用puppet做一个module,非常方便,直接下推就可以了。
当客户机接到收软件安装的指令时,会使用本机的yum命令去从yum仓库安装定义好的包。

  如我已经安装了一个puppet的服务端和客户端,现在打算在客户端安装 zsh-html,先在
客户端上看看软件的安装情况

[root@c12 manifests]# yum list | grep zsh-html
This system is not registered with RHN.
RHN support will be disabled.
zsh-html.x86_64                            4.2.6-3.el5            rhel-debuginfo


客户端还没有安装zsh-html包.

在puppet上做一个模块,default的模块目录是/etc/puppet/modules,新建一个zsh目录,这个zsh
也表示是模块名,目录结构如下.

[root@localhost modules]# tree zsh
zsh
|-- files
|-- manifests
|   `-- init.pp
`-- templates

在zsh/manifests目录中,建立init.pp文件,内容如下

class zsh {
      package { "zsh-html":
                ensure => present
               }
           }

在全局site.pp文件加入该class

node 'c12.abc.com'
   {
      include mysqld
      include zsh   --新加行
   }


稍后可以在客户机的/var/log/messages中发现安装的日志信息

Nov 27 13:43:56 c12 puppet-agent[29731]: Starting Puppet client version 2.7.25
Nov 27 13:43:57 c12 puppet-agent[29731]: Caching catalog for c12.abc.com
Nov 27 13:43:57 c12 puppet-agent[29731]: Applying configuration version '1417095836'
Nov 27 13:43:59 c12 yum: Installed: zsh-html-4.2.6-3.el5.x86_64
Nov 27 13:43:59 c12 puppet-agent[29731]: (/Stage[main]/Zsh/Package[zsh-html]/ensure) created
Nov 27 13:43:59 c12 puppet-agent[29731]: Finished catalog run in 2.30 seconds

.....

检查该包已经在客户端自动安装成功


[root@c12 ~]# yum list | grep zsh-html
This system is not registered with RHN.
RHN support will be disabled.
zsh-html.x86_64                            4.2.6-3.el5            installed 

 

 

 

 

阅读(2197) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~