puppet 配置 2 模块

    xiaoxiao2026-02-17  15

    概念

    模块是 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)