[stein and before] Fix service_hostnames output

Check if NetworkHostnameMap is empty before
building service_hostnames. Else map_replace would
populate it with the network names.

From stable/train ansible is used for all_nodes
hieradata.

Related: https://bugzilla.redhat.com/show_bug.cgi?id=1956712
Change-Id: Icfaa6ad999d59bfde1abbbef7e9c9598c3053c8e
This commit is contained in:
ramishra 2021-05-05 11:25:56 +05:30
parent 06f0fcd533
commit 14755a88b0
1 changed files with 31 additions and 28 deletions

View File

@ -23,7 +23,7 @@ parameters:
default: [] default: []
type: comma_delimited_list type: comma_delimited_list
NetworkHostnameMap: NetworkHostnameMap:
default: [] default: {}
type: json type: json
NovaAdditionalCell: NovaAdditionalCell:
default: false default: false
@ -32,6 +32,8 @@ parameters:
conditions: conditions:
is_cell: {equals: [{get_param: NovaAdditionalCell}, true]} is_cell: {equals: [{get_param: NovaAdditionalCell}, true]}
network_hostname_map_set:
not: {equals: [{get_param: NetworkHostnameMap}, {}]}
resources: resources:
# This adds the extra "services" on for keystone # This adds the extra "services" on for keystone
@ -118,33 +120,34 @@ outputs:
description: > description: >
Map of enabled services to a list of hostnames where they're running Map of enabled services to a list of hostnames where they're running
value: value:
map_replace: if:
- yaql: - network_hostname_map_set
# This filters any entries where the value hasn't been substituted for - map_replace:
# a list, e.g it's still $service_network. This happens when there is - yaql:
# no network defined for the service in the ServiceNetMap, which is OK # This filters any entries where the value hasn't been substituted for
# as not all services have to be bound to a network, so we filter them # a list, e.g it's still $service_network. This happens when there is
expression: dict($.data.map.items().where(not $[1].endsWith("_network"))) # no network defined for the service in the ServiceNetMap, which is OK
data: # as not all services have to be bound to a network, so we filter them
map: expression: dict($.data.map.items().where(not $[1].endsWith("_network")))
map_replace: data:
- map_merge: map:
if: map_replace:
- is_cell - map_merge:
- if:
repeat: - is_cell
template: - repeat:
SERVICE_cell_node_names: SERVICE_network template:
for_each: SERVICE_cell_node_names: SERVICE_network
SERVICE: {get_attr: [EnabledServicesValue, value]} for_each:
- SERVICE: {get_attr: [EnabledServicesValue, value]}
repeat: - repeat:
template: template:
SERVICE_node_names: SERVICE_network SERVICE_node_names: SERVICE_network
for_each: for_each:
SERVICE: {get_attr: [EnabledServicesValue, value]} SERVICE: {get_attr: [EnabledServicesValue, value]}
- values: {get_param: ServiceNetMap} - values: {get_param: ServiceNetMap}
- values: {get_param: NetworkHostnameMap} - values: {get_param: NetworkHostnameMap}
- {}
short_service_hostnames: short_service_hostnames:
description: > description: >
Map of enabled services to a list of hostnames where they're running regardless of the network Map of enabled services to a list of hostnames where they're running regardless of the network