Red Hat Training

A Red Hat training course is available for Red Hat OpenStack Platform

6.17. 应用自定义 Puppet 配置

在特定情况下,您可能会需要在 Overcloud 节点上安装并配置一些额外的组件。您可以通过在主配置完成后,在节点上应用一个自定义 Puppet manifest 来达到这个目的。作为一个基本的例子,您可以在每个节点上安装 motd。这会首先创建一个 Heat 模板(/home/stack/templates/custom_puppet_config.yaml)来启动 Puppet 配置。
heat_template_version: 2014-10-16

description: >
Run Puppet extra configuration to set new MOTD

parameters:
servers:
  type: json

resources:
ExtraPuppetConfig:
  type: OS::Heat::SoftwareConfig
  properties:
    config: {get_file: motd.pp}
    group: puppet
    options:
      enable_hiera: True
      enable_facter: False

ExtraPuppetDeployments:
  type: OS::Heat::SoftwareDeployments
  properties:
    config: {get_resource: ExtraPuppetConfig}
    servers: {get_param: servers}
这会在模板内包括 /home/stack/templates/motd.pp,并把它传递给节点进行配置。motd.pp 文件本身包括了我们的 Puppet 类来进行安装和配置 motd
接下来,创建一个环境文件(/home/stack/templates/puppet_post_config.yaml),它会把我们的 Heat 模板注册为 OS::TripleO::NodeExtraConfigPost: 资源类型。
resource_registry:
OS::TripleO::NodeExtraConfigPost: /home/stack/templates/custom_puppet_config.yaml
最后,在创建或更新 Overcloud 栈时包括这个环境文件:
$ openstack overcloud deploy --templates -e /home/stack/templates/puppet_post_config.yaml
这会把 motd.pp 中的配置应用到 Overcloud 的所有节点上。