From d00671142620f06c23601be8e5de63df71afdfb4 Mon Sep 17 00:00:00 2001 From: Steven Hardy Date: Wed, 10 Jan 2018 09:20:14 +0000 Subject: [PATCH] Allow defaults for Image/Flavor/RoleParameters in roles_data.yaml This allows specific roles, e.g ComputeRealTime to specify defaults where the services are the same as some existing roles but a different image and/or configuration are needed. Inspired by discussion of this requirement in: https://review.openstack.org/#/c/531739/ RoleParametersDefaults is merged with the user provided parameters with precendence to user parameters, as this is a special parameter, which contains a map of the actual parameters to be applied to a role. Partially Implements: blueprint tripleo-realtime Change-Id: I6497144340d3b9276e6ed141d3bc655bfbbeb53c --- overcloud.j2.yaml | 10 ++++++++-- puppet/role.role.j2.yaml | 6 +++--- roles/README.rst | 10 ++++++++++ 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/overcloud.j2.yaml b/overcloud.j2.yaml index 42679238ea..afeaea0572 100644 --- a/overcloud.j2.yaml +++ b/overcloud.j2.yaml @@ -386,7 +386,10 @@ resources: EndpointMap: {get_attr: [EndpointMapData, value]} DefaultPasswords: {get_attr: [DefaultPasswords, passwords]} RoleName: {{role.name}} - RoleParameters: {get_param: {{role.name}}Parameters} + RoleParameters: + map_merge: + - {{role.RoleParametersDefault|default({})}} + - get_param: {{role.name}}Parameters # Lookup of role_data via heat outputs is slow, so workaround this by caching # the value in an OS::Heat::Value resource @@ -564,7 +567,10 @@ resources: LoggingGroups: {get_attr: [{{role.name}}ServiceChainRoleData, value, logging_groups]} ServiceMetadataSettings: {get_attr: [{{role.name}}ServiceChainRoleData, value, service_metadata_settings]} DeploymentServerBlacklistDict: {get_attr: [DeploymentServerBlacklistDict, value]} - RoleParameters: {get_param: {{role.name}}Parameters} + RoleParameters: + map_merge: + - {{role.RoleParametersDefault|default({})}} + - get_param: {{role.name}}Parameters {% endfor %} {% for role in roles %} diff --git a/puppet/role.role.j2.yaml b/puppet/role.role.j2.yaml index b184e4fac5..84af496a8d 100644 --- a/puppet/role.role.j2.yaml +++ b/puppet/role.role.j2.yaml @@ -5,7 +5,7 @@ heat_template_version: queens description: 'OpenStack {{role.name}} node configured by Puppet' parameters: -{%- set default_flavor_name = 'baremetal' %} +{%- set default_flavor_name = role.FlavorDefault|default('baremetal') %} {%- if role.deprecated_param_flavor is defined %} {{role.deprecated_param_flavor}}: description: DEPRECATED Use Overcloud{{role.name}}Flavor instead. @@ -20,7 +20,7 @@ parameters: constraints: - custom_constraint: nova.flavor {%- endif %} -{%- set default_image_name = 'overcloud-full' %} +{%- set default_image_name = role.ImageDefault|default('overcloud-full') %} {%- if role.deprecated_param_image is defined %} {{role.deprecated_param_image}}: type: string @@ -294,7 +294,7 @@ resources: get_param: {{role.name}}Image {%- endif %} image_update_policy: {get_param: ImageUpdatePolicy} - flavor: + flavor: {%- if role.deprecated_param_flavor is defined %} if: - deprecated_param_flavor_set diff --git a/roles/README.rst b/roles/README.rst index ba3495df8b..d82ca52c01 100644 --- a/roles/README.rst +++ b/roles/README.rst @@ -34,6 +34,16 @@ Role Options defaults to '%stackname%-{{role.name.lower()}}-%index%' sets the default for {{role.name}}HostnameFormat parameter in overcloud.yaml +* ImageDefault: (string) optional default image name or ID, defaults to + overcloud-full + +* FlavorDefault: (string) optional default flavor name or ID, defaults to + baremetal + +* RoleParametersDefault: (map) optional default to the per-role RoleParameters + value, this enables roles to specify specific values appropriate to their + configuration, defaults to an empty map. + * disable_constraints: (boolean) optional, whether to disable Nova and Glance constraints for each role specified in the templates.