第 8 章 使用自定义角色和服务
Red Hat OpenStack Platform 通常由预定义角色中的节点组成,例如,控制器角色中的节点、计算角色和不同的存储角色类型。这些默认角色各自包含一组您在核心 heat 模板集合中定义的服务。但是,一体化 Red Hat OpenStack Platform 安装在单个节点上运行,其中包含所有 OpenStack 服务。/usr/share/openstack-tripleo-heat-templates/roles
目录中的 Standalone.yaml
角色文件是包含 all-in-one 安装中所有服务的配置文件。您可以复制并修改 Standalone.yaml
角色文件,以便在安装中启用和禁用服务。
Standalone.yaml
文件包含角色 Standalone
中的服务列表。使用以下示例了解此文件的语法:
- name: Standalone description: | A standalone role that includes a minimal set of services. Use this role for testing in a single node configuration with the 'openstack tripleo deploy --standalone' command, or with the 'openstack overcloud deploy' command. CountDefault: 1 tags: - primary - controller disable_constraints: True ServicesDefault: - OS::TripleO::Services::Aide - OS::TripleO::Services::AodhApi - OS::TripleO::Services::AodhEvaluator ... - OS::TripleO::Services::Tuned - OS::TripleO::Services::Vpp - OS::TripleO::Services::Zaqar
在部署命令中包含此角色文件,以使用 Standalone 角色配置堆栈,该角色包含您在角色文件的 ServicesDefault:
部分中包含的服务:
[stack@all-in-one]$ sudo openstack tripleo deploy --templates -r /usr/share/openstack-tripleo-heat-templates/roles/Standalone.yaml
但是,在生产环境、多节点 Red Hat OpenStack Platform 环境中,您可以为每个节点分配一个角色,其中包含一部分 OpenStack 服务,而不是在单个节点上包括所有服务。例如,默认的 Controller 角色包括管理、网络和高可用性服务,默认的 Compute 角色包括计算服务。多节点环境中的默认角色文件是 /usr/share/openstack-tripleo-heat-templates/roles_data.yaml
文件。此文件定义以下角色类型:
- Controller
- Compute
- BlockStorage
- ObjectStorage
- CephStorage
使用以下示例了解多节点环境中的角色语法:
- name: Controller description: | Controller role that contains all of the services for database, messaging and network functions. ServicesDefault: - OS::TripleO::Services::AuditD - OS::TripleO::Services::CACerts - OS::TripleO::Services::CephClient ... - name: Compute description: | Basic Compute Node role ServicesDefault: - OS::TripleO::Services::AuditD - OS::TripleO::Services::CACerts - OS::TripleO::Services::CephClient ...
每次运行部署命令时,都必须包含角色文件。您可以在部署命令中使用 -r
参数来覆盖此文件,并使用自定义角色文件:
[stack@all-in-one]$ sudo openstack tripleo deploy --templates -r ~/templates/roles_data-custom.yaml
8.1. 在一体化 Red Hat OpenStack Platform 环境中启用和禁用服务
/usr/share/openstack-tripleo-heat-templates/roles
目录中的 Standalone.yaml
角色文件是包含 all-in-one 安装中所有服务的配置文件。您可以启用或禁用单个服务。
流程
要禁用服务,请创建一个新的环境文件,并为您要禁用的服务包含
OS::Heat::None
值:- OS::TripleO::Services::<SERVICE>: OS::Heat::None
在部署命令中包括此环境文件。
要启用服务,请创建一个新的环境文件,并从您要启用的服务中删除
OS::Heat::None
值:- OS::TripleO::Services::<SERVICE>:
在部署命令中包括此环境文件。