Show Table of Contents
6.13. 自定义第一次引导的配置
director 提供了一个在初始创建 Overcloud 时在所有节点上进行配置操作的机制。director 使用
cloud-init,您可以使用 OS::TripleO::NodeUserData 资源类型调用它。
在这个示例中,您需要在所有节点上更新域名解析服务器来使用一个自定义的 IP 地址。首先,创建一个基本的 heat 模板(
/home/stack/templates/nameserver.yaml),它运行一个脚本来为每个节点的 resolv.conf 添加一个特定的名称解析服务器(nameserver)。使用 OS::TripleO::MultipartMime 资源类型来发送配置脚本。
heat_template_version: 2014-10-16
description: >
Extra hostname configuration
resources:
userdata:
type: OS::Heat::MultipartMime
properties:
parts:
- config: {get_resource: nameserver_config}
nameserver_config:
type: OS::Heat::SoftwareConfig
properties:
config: |
#!/bin/bash
echo "nameserver 192.168.1.1" >> /etc/resolv.conf
outputs:
OS::stack_id:
value: {get_resource: userdata}
接下来,创建一个环境文件(
/home/stack/templates/firstboot.yaml),它把您的 heat 模板注册为 OS::TripleO::NodeUserData 资源类型。
resource_registry: OS::TripleO::NodeUserData: /home/stack/templates/nameserver.yaml
为了添加首次引导时的配置,在首次创建 Overcloud 时把环境文件添加到栈中。例如:
$ openstack overcloud deploy --templates -e /home/stack/templates/firstboot.yaml
其中的
-e 把环境文件添加到 Overcloud 栈。
在所有节点首次创建并首次引导时,这些配置会被添加到所有节点上。其后包括这些模板的操作(如更新 Overcloud 栈)将不再运行这些脚本。
重要
您可以只把
OS::TripleO::NodeUserData 注册到一个 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.