aboutsummaryrefslogtreecommitdiffstats
path: root/extraconfig/nova_metadata/krb-service-principals.j2.yaml
blob: b18dba66030f9c8fd796ce270df6921748e1fa2a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
heat_template_version: pike
description: 'Generates the relevant service principals for a server'

parameters:
  RoleData:
     type: json
     description: the list containing the 'role_data' output for the ServiceChain
{%- for network in networks if network.vip|default(false) %}
{%- if network.name == 'External' %}
  # Special case the External hostname param, which is CloudName
  CloudName:
    default: overcloud.localdomain
    description: The DNS name of this cloud. E.g. ci-overcloud.tripleo.org
    type: string
{%- elif network.name == 'InternalApi' %}
  # Special case the Internal API hostname param, which is CloudNameInternal
  CloudNameInternal:
    default: overcloud.{{network.name.lower()}}.localdomain
    description: >
      The DNS name of this cloud's {{network.name_lower}} endpoint. E.g.
      'ci-overcloud.{{network.name.lower()}}.tripleo.org'.
    type: string
{%- elif network.name == 'StorageMgmt' %}
  # Special case StorageMgmt hostname param, which is CloudNameStorageManagement
  CloudNameStorageManagement:
    default: overcloud.{{network.name.lower()}}.localdomain
    description: >
      The DNS name of this cloud's {{network.name_lower}} endpoint. E.g.
      'ci-overcloud.{{network.name.lower()}}.tripleo.org'.
    type: string
{%- else %}
  CloudName{{network.name}}:
    default: overcloud.{{network.name.lower()}}.localdomain
    description: >
      The DNS name of this cloud's {{network.name_lower}} endpoint. E.g.
      'ci-overcloud.{{network.name.lower()}}.tripleo.org'.
    type: string
{%- endif %}
{%- endfor %}
  CloudNameCtlplane:
    default: overcloud.ctlplane.localdomain
    description: >
      The DNS name of this cloud's provisioning network endpoint. E.g.
      'ci-overcloud.ctlplane.tripleo.org'.
    type: string

resources:

  IncomingMetadataSettings:
    type: OS::Heat::Value
    properties:
      value:
        yaql:
          # Filter null values and values that contain don't contain
          # 'metadata_settings', get the values from that key and get the
          # unique ones.
          expression: list(coalesce($.data, []).where($ != null).where($.containsKey('metadata_settings')).metadata_settings.flatten().distinct())
          data: {get_param: RoleData}

  # Generates entries for nova metadata with the following format:
  #   'managed_service_<id>' : <service>/<fqdn>
  # Depending on the requested network
  IndividualServices:
    type: OS::Heat::Value
    properties:
      value:
        yaql:
          expression: let(fqdns => $.data.fqdns) -> dict(coalesce($.data.metadata, []).where($ != null and $.type = 'vip').select([concat('managed_service_', $.service, $.network), concat($.service, '/', $fqdns.get($.network))]))
          data:
            metadata: {get_attr: [IncomingMetadataSettings, value]}
            fqdns:
{%- for network in networks if network.vip|default(false) %}
{%- if network.name == 'External' %}
              external: {get_param: CloudName}
{%- elif network.name == 'InternalApi' %}
              internal_api: {get_param: CloudNameInternal}
{%- elif network.name == 'StorageMgmt' %}
              storage_mgmt: {get_param: CloudNameStorageManagement}
{%- else %}
              {{network.name_lower}}: {get_param: CloudName{{network.name}}}
{%- endif %}
{%- endfor %}
              ctlplane: {get_param: CloudNameCtlplane}

  CompactServices:
    type: OS::Heat::Value
    properties:
      value:
        yaql:
          expression: dict(coalesce($.data, []).where($ != null and $.type = 'node').select([$.service, $.network.replace('_', '')]).groupBy($[0], $[1]))
          data: {get_attr: [IncomingMetadataSettings, value]}

outputs:
  metadata:
    description: actual metadata entries that will be passed to the server.
    value:
      map_merge:
        - {get_attr: [IndividualServices, value]}
        - compact_services: {get_attr: [CompactServices, value]}