Show Table of Contents
6.15. Overcloud 创建后的自定义配置
在创建完 Overcloud 后,您可能需要在初始创建时,或以后对 Overcloud 进行更新时添加以下额外的配置。在这种情况下,您可以使用
OS::TripleO::NodeExtraConfigPost 资源来应用使用标准的 OS::Heat::SoftwareConfig 类型的配置。这会在主 Overcloud 配置完成后应用额外的配置。
在这个示例中,首先创建一个基本的 heat 模板(
/home/stack/templates/nameserver.yaml),它运行一个脚本来为每个节点的 resolv.conf 添加一个不同的名称解析服务器(nameserver)。
heat_template_version: 2014-10-16
description: >
Extra hostname configuration
parameters:
servers:
type: json
nameserver_ip:
type: string
resources:
ExtraConfig:
type: OS::Heat::SoftwareConfig
properties:
group: script
config:
str_replace:
template: |
#!/bin/sh
echo "nameserver _NAMESERVER_IP_" >> /etc/resolv.conf
params:
_NAMESERVER_IP_: {get_param: nameserver_ip}
ExtraDeployments:
type: OS::Heat::SoftwareDeployments
properties:
servers: {get_param: servers}
config: {get_resource: ExtraConfig}
actions: ['CREATE','UPDATE']
重要
servers 参数是应用配置的服务器列表,它由父模板提供。这个参数在所有 OS::TripleO::NodeExtraConfigPost 模板中都是必需的。
接下来,创建一个环境文件(
/home/stack/templates/post_config.yaml),它把我们的 Heat 模板注册为 OS::TripleO::NodeExtraConfigPost: 资源类型。
resource_registry: OS::TripleO::NodeExtraConfigPost: /home/stack/templates/nameserver.yaml parameter_defaults: nameserver_ip: 192.168.1.1
为了应用配置,在创建或更新 Overcloud 时把环境文件加入到栈。例如:
$ openstack overcloud deploy --templates -e /home/stack/templates/post_config.yaml
这会在初始创建的主配置完成后,或以后的更新过程的主配置完成后,在所有节点中应用配置。
重要
您可以只把
OS::TripleO::NodeExtraConfigPost 注册到一个 heat 模板。随后的使用会覆盖 heat 模板。

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.