Add role_merged_configs into workflow executions environmentxi
authorGiulio Fidente <gfidente@redhat.com>
Fri, 14 Jul 2017 11:38:47 +0000 (13:38 +0200)
committerGiulio Fidente <gfidente@redhat.com>
Fri, 14 Jul 2017 16:41:32 +0000 (18:41 +0200)
Merges per-role config settings into merged_config_settings which
is wired into the workflow executions environment.

Useful to consume role config settings from within a workflow.

Change-Id: Id37de5864138edd5476c097a8a1f0763faeaf768

docker/docker-steps.j2
overcloud.j2.yaml
puppet/puppet-steps.j2

index 73a3cb7..ab75b7e 100644 (file)
@@ -129,11 +129,19 @@ resources:
           params:
             env:
               service_ips: { get_param: ctlplane_service_ips }
+              role_merged_configs:
+                {% for r in roles %}
+                {{r.name}}: {get_param: [role_data, {{r.name}}, merged_config_settings]}
+                {% endfor %}
         UPDATE:
           workflow: { get_resource: WorkflowTasks_Step{{step}} }
           params:
             env:
               service_ips: { get_param: ctlplane_service_ips }
+              role_merged_configs:
+                {% for r in roles %}
+                {{r.name}}: {get_param: [role_data, {{r.name}}, merged_config_settings]}
+                {% endfor %}
       always_update: true
 # END service_workflow_tasks handling
 {% endfor %}
index 5bd1cec..f18a053 100644 (file)
@@ -55,6 +55,18 @@ parameters:
         Control the IP allocation for the ControlVirtualIP port. E.g.
         [{'ip_address':'1.2.3.4'}]
     type: json
+  ExtraConfig:
+    default: {}
+    description: |
+      Additional hiera configuration to inject into the cluster.
+    type: json
+{% for role in roles %}
+  {{role.name}}ExtraConfig:
+    default: {}
+    description: |
+      Role specific additional hiera configuration to inject into the cluster.
+    type: json
+{% endfor %}
   InternalApiVirtualFixedIPs:
     default: []
     description: >
@@ -323,6 +335,46 @@ resources:
       type: json
       value: {get_attr: [{{role.name}}ServiceChain, role_data]}
 
+  {{role.name}}ServiceConfigSettings:
+    type: OS::Heat::Value
+    properties:
+      type: json
+      value:
+        map_merge:
+          - get_attr: [{{role.name}}ServiceChainRoleData, value, config_settings]
+          {% for r in roles %}
+          - get_attr: [{{r.name}}ServiceChainRoleData, value, global_config_settings]
+          {% endfor %}
+          # This next step combines two yaql passes:
+          # - The inner one does a deep merge on the service_config_settings for all roles
+          # - The outer one filters the map based on the services enabled for the role
+          #   then merges the result into one map.
+          - yaql:
+              expression: let(root => $) -> $.data.map.items().where($[0] in coalesce($root.data.services, [])).select($[1]).reduce($1.mergeWith($2), {})
+              data:
+                map:
+                  yaql:
+                    expression: $.data.where($ != null).reduce($1.mergeWith($2), {})
+                    data:
+                    {% for r in roles %}
+                      - get_attr: [{{r.name}}ServiceChainRoleData, value, service_config_settings]
+                    {% endfor %}
+                services: {get_attr: [{{role.name}}ServiceNames, value]}
+
+  {{role.name}}MergedConfigSettings:
+    type: OS::Heat::Value
+    properties:
+      type: json
+      value:
+        config_settings: {}
+        global_config_settings: {}
+        service_config_settings: {}
+        merged_config_settings:
+          map_merge:
+          - get_attr: [{{role.name}}ServiceConfigSettings, value]
+          - get_param: ExtraConfig
+          - get_param: {{role.name}}ExtraConfig
+
   # Filter any null/None service_names which may be present due to mapping
   # of services to OS::Heat::None
   {{role.name}}ServiceNames:
@@ -437,27 +489,7 @@ resources:
   {% else %}
           NovaComputeSchedulerHints: {get_param: NovaComputeSchedulerHints}
   {% endif %}
-          ServiceConfigSettings:
-            map_merge:
-              -  get_attr: [{{role.name}}ServiceChainRoleData, value, config_settings]
-          {% for r in roles %}
-              - get_attr: [{{r.name}}ServiceChain, role_data, global_config_settings]
-          {% endfor %}
-              # This next step combines two yaql passes:
-              # - The inner one does a deep merge on the service_config_settings for all roles
-              # - The outer one filters the map based on the services enabled for the role
-              #   then merges the result into one map.
-              - yaql:
-                  expression: let(root => $) -> $.data.map.items().where($[0] in coalesce($root.data.services, [])).select($[1]).reduce($1.mergeWith($2), {})
-                  data:
-                    map:
-                      yaql:
-                        expression: $.data.where($ != null).reduce($1.mergeWith($2), {})
-                        data:
-                        {% for r in roles %}
-                          - get_attr: [{{r.name}}ServiceChain, role_data, service_config_settings]
-                        {% endfor %}
-                    services: {get_attr: [{{role.name}}ServiceNames, value]}
+          ServiceConfigSettings: {get_attr: [{{role.name}}ServiceConfigSettings, value]}
           ServiceNames: {get_attr: [{{role.name}}ServiceNames, value]}
           MonitoringSubscriptions: {get_attr: [{{role.name}}ServiceChainRoleData, value, monitoring_subscriptions]}
           ServiceMetadataSettings: {get_attr: [{{role.name}}ServiceChainRoleData, value, service_metadata_settings]}
@@ -784,7 +816,10 @@ resources:
 {% endfor %}
       role_data:
 {% for role in roles %}
-        {{role.name}}: {get_attr: [{{role.name}}ServiceChainRoleData, value]}
+        {{role.name}}:
+          map_merge:
+          - {get_attr: [{{role.name}}ServiceChainRoleData, value]}
+          - {get_attr: [{{role.name}}MergedConfigSettings, value]}
 {% endfor %}
 
   ServerOsCollectConfigData:
@@ -869,7 +904,10 @@ outputs:
     description: The configuration data associated with each role
     value:
 {% for role in roles %}
-      {{role.name}}: {get_attr: [{{role.name}}ServiceChainRoleData, value]}
+      {{role.name}}:
+        map_merge:
+        - {get_attr: [{{role.name}}ServiceChainRoleData, value]}
+        - {get_attr: [{{role.name}}MergedConfigSettings, value]}
 {% endfor %}
   RoleNetIpMap:
     description: Mapping of each network to a list of IPs for each role
index 82c6171..55aa685 100644 (file)
@@ -136,11 +136,19 @@ resources:
           params:
             env:
               service_ips: { get_param: ctlplane_service_ips }
+              role_merged_configs:
+                {% for r in roles %}
+                {{r.name}}: {get_param: [role_data, {{r.name}}, merged_config_settings]}
+                {% endfor %}
         UPDATE:
           workflow: { get_resource: WorkflowTasks_Step{{step}} }
           params:
             env:
               service_ips: { get_param: ctlplane_service_ips }
+              role_merged_configs:
+                {% for r in roles %}
+                {{r.name}}: {get_param: [role_data, {{r.name}}, merged_config_settings]}
+                {% endfor %}
       always_update: true
 {% endfor %}
 # END service_workflow_tasks handling