puppet 配置 2 模块

概念

模块是 puppet 中最基本的功能单位
模块常常存放在 /etc/puppet/modules 下
每个模块都是独立的, 模块命名不可以重复, 否则会导致重命名错误
模块主要供客户端进行调用
模块常见有下载及自定义两种

获取

可以从网络中获得模板

https://forge.puppet.com/
http://www.example42.com 

命令行管理

Linux 下使用命令行获得模块方法

查询模块

(默认会从 https://forge.puppet.com/ 获取 )

[root@hh-yun-puppet-129021 modules]# puppet module search squid
Warning: Setting modulepath is deprecated in puppet.conf. See http://links.puppetlabs.com/env-settings-deprecations
   (at /usr/lib/ruby/site_ruby/1.8/puppet/settings.rb:1095:in `issue_deprecations')
Notice: Searching https://forgeapi.puppetlabs.com ...
NAME              DESCRIPTION                                                                          AUTHOR        KEYWORDS
puppet-squid      configure squid caching proxy                                                        @puppet       squid cache http web
CERNOps-shoal     Shoal publishes http proxy locations                                                 @CERNOps      shoal cvmfs frontier squid
thias-squid3      Squid 3 http proxy server module                                                     @thias        squid proxy
desalvo-frontier  Puppet module for Frontier configuration                                             @desalvo      frontier squid cvmfs

安装

有时候, 由于具有模块依赖关系, 需要添加参数 --ignore-dependencies 才能够正常进行下载

[root@hh-yun-puppet-129021 modules]# puppet module install --ignore-dependencies elasticsearch-elasticsearch
Warning: Setting modulepath is deprecated in puppet.conf. See http://links.puppetlabs.com/env-settings-deprecations
   (at /usr/lib/ruby/site_ruby/1.8/puppet/settings.rb:1095:in `issue_deprecations')
Notice: Preparing to install into /etc/puppet/modules ...
Notice: Downloading from https://forgeapi.puppetlabs.com ...
Notice: Installing -- do not interrupt ...
/etc/puppet/modules
└── elasticsearch-elasticsearch (v0.12.0)

卸载

[root@hh-yun-puppet-129021 modules]# puppet module uninstall --ignore-dependencies elasticsearch-elasticsearch

指定安装版本

puppet module upgrade puppetlabs-apache --version 0.0.3

模块位置

默认状态下, 从网络下载的模块会自动被放置 /etc/puppet/modules 目录下
同样, 假如手动下载了 tar 包之后, 可以直接解压至少 /etc/puppet/modules 目录下即可

自定义模块

用户可以创建个性化的模块
模块同样需要存放在 /etc/puppet/modules 目录下

模块目录结构

常见的模块目录下, 通常包含下面几个目录
.
├── files 存放共享文件, 常常以 puppet:///modulename/modules/filename 格式进行定义
├── lib 存放 ruby 代码, 定义了 puppet 的一些方法
├── manifests 存放了该模块的 pp 模板, 用于定义该模板的主要功能
├── spec 存放编译方法, 可以通过 puppet modules build 的方法生成新的 puppet modules
└── templates 存放模板, 定义了用户模板, 可以通过模板生成格式化的配置文件

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Terry_Tsang

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值