Composable per-service VIP hieradata
authorSteven Hardy <shardy@redhat.com>
Sun, 28 Aug 2016 22:39:32 +0000 (23:39 +0100)
committerEmilien Macchi <emilien@redhat.com>
Sat, 3 Sep 2016 19:46:30 +0000 (19:46 +0000)
Change-Id: Iaf78a5eac223aeb50133fcc6fab043ee746d73fd
Partially-Implements: blueprint custom-roles

overcloud.yaml
puppet/vip-config.yaml

index 6b62fd0..68ee23c 100644 (file)
@@ -808,6 +808,17 @@ resources:
 
   VipConfig:
     type: OS::TripleO::VipConfig
+    properties:
+      NetIpMap: {get_attr: [VipMap, net_ip_map]}
+      ServiceNetMap: {get_attr: [ServiceNetMap, service_net_map_lower]}
+      EnabledServices:
+        list_join:
+          - ','
+          - {get_attr: [ControllerServiceChain, role_data, service_names]}
+          - {get_attr: [ComputeServiceChain, role_data, service_names]}
+          - {get_attr: [BlockStorageServiceChain, role_data, service_names]}
+          - {get_attr: [ObjectStorageServiceChain, role_data, service_names]}
+          - {get_attr: [CephStorageServiceChain, role_data, service_names]}
 
   VipDeployment:
     type: OS::Heat::StructuredDeployments
@@ -816,32 +827,12 @@ resources:
       config: {get_resource: VipConfig}
       servers: {get_attr: [Controller, attributes, nova_server_resource]}
       input_values:
-        # service VIP mappings
         keystone_admin_api_vip: {get_attr: [VipMap, net_ip_map, {get_attr: [ServiceNetMap, service_net_map, KeystoneAdminApiNetwork]}]}
         keystone_public_api_vip: {get_attr: [VipMap, net_ip_map, {get_attr: [ServiceNetMap, service_net_map, KeystonePublicApiNetwork]}]}
-        neutron_api_vip: {get_attr: [VipMap, net_ip_map, {get_attr: [ServiceNetMap, service_net_map, NeutronApiNetwork]}]}
-        cinder_api_vip: {get_attr: [VipMap, net_ip_map, {get_attr: [ServiceNetMap, service_net_map, CinderApiNetwork]}]}
-        glance_api_vip: {get_attr: [VipMap, net_ip_map, {get_attr: [ServiceNetMap, service_net_map, GlanceApiNetwork]}]}
-        glance_registry_vip: {get_attr: [VipMap, net_ip_map, {get_attr: [ServiceNetMap, service_net_map, GlanceRegistryNetwork]}]}
-        swift_proxy_vip: {get_attr: [VipMap, net_ip_map, {get_attr: [ServiceNetMap, service_net_map, SwiftProxyNetwork]}]}
-        nova_api_vip: {get_attr: [VipMap, net_ip_map, {get_attr: [ServiceNetMap, service_net_map, NovaApiNetwork]}]}
-        nova_metadata_vip: {get_attr: [VipMap, net_ip_map, {get_attr: [ServiceNetMap, service_net_map, NovaMetadataNetwork]}]}
-        ceilometer_api_vip: {get_attr: [VipMap, net_ip_map, {get_attr: [ServiceNetMap, service_net_map, CeilometerApiNetwork]}]}
-        aodh_api_vip: {get_attr: [VipMap, net_ip_map, {get_attr: [ServiceNetMap, service_net_map, AodhApiNetwork]}]}
-        gnocchi_api_vip: {get_attr: [VipMap, net_ip_map, {get_attr: [ServiceNetMap, service_net_map, GnocchiApiNetwork]}]}
-        heat_api_vip: {get_attr: [VipMap, net_ip_map, {get_attr: [ServiceNetMap, service_net_map, HeatApiNetwork]}]}
-        horizon_vip: {get_attr: [VipMap, net_ip_map, {get_attr: [ServiceNetMap, service_net_map, HorizonNetwork]}]}
-        redis_vip: {get_attr: [RedisVirtualIP, ip_address]}
-        manila_api_vip: {get_attr: [VipMap, net_ip_map, {get_attr: [ServiceNetMap, service_net_map, ManilaApiNetwork]}]}
-        mysql_vip: {get_attr: [VipMap, net_ip_map, {get_attr: [ServiceNetMap, service_net_map, MysqlNetwork]}]}
-        rabbit_vip: {get_attr: [VipMap, net_ip_map, {get_attr: [ServiceNetMap, service_net_map, RabbitMqNetwork]}]}
         # direct configuration of Virtual IPs for each network
         control_virtual_ip: {get_attr: [VipMap, net_ip_map, ctlplane]}
         public_virtual_ip: {get_attr: [VipMap, net_ip_map, external]}
         internal_api_virtual_ip: {get_attr: [VipMap, net_ip_map, internal_api]}
-        sahara_api_vip: {get_attr: [VipMap, net_ip_map, {get_attr: [ServiceNetMap, service_net_map, SaharaApiNetwork]}]}
-        ironic_api_vip: {get_attr: [VipMap, net_ip_map, {get_attr: [ServiceNetMap, service_net_map, IronicApiNetwork]}]}
-        opendaylight_api_vip: {get_attr: [VipMap, net_ip_map, {get_attr: [ServiceNetMap, service_net_map, OpenDaylightApiNetwork]}]}
         storage_virtual_ip: {get_attr: [VipMap, net_ip_map, storage]}
         storage_mgmt_virtual_ip: {get_attr: [VipMap, net_ip_map, storage_mgmt]}
 
index cbd7ea0..010a941 100644 (file)
@@ -1,8 +1,18 @@
-heat_template_version: 2015-04-30
+heat_template_version: 2016-10-14
 
 description: >
   Configure hieradata for service -> virtual IP mappings.
 
+parameters:
+  NetIpMap:
+    type: json
+  # FIXME(shardy) this can be comma_delimited_list when
+  # https://bugs.launchpad.net/heat/+bug/1617019 is fixed
+  EnabledServices:
+    type: string
+  ServiceNetMap:
+    type: json
+
 resources:
   VipConfigImpl:
     type: OS::Heat::StructuredConfig
@@ -13,44 +23,49 @@ resources:
           datafiles:
             vip_data:
               mapped_data:
-                keystone_admin_api_vip: {get_input: keystone_admin_api_vip}
-                keystone_public_api_vip: {get_input: keystone_public_api_vip}
-                neutron_api_vip: {get_input: neutron_api_vip}
-                # TODO: pass a `midonet_api_vip` var
-                midonet_api_vip: {get_input: neutron_api_vip}
-                cinder_api_vip: {get_input: cinder_api_vip}
-                glance_api_vip: {get_input: glance_api_vip}
-                glance_registry_vip: {get_input: glance_registry_vip}
-                sahara_api_vip: {get_input: sahara_api_vip}
-                swift_proxy_vip: {get_input: swift_proxy_vip}
-                manila_api_vip: {get_input: manila_api_vip}
-                nova_api_vip: {get_input: nova_api_vip}
-                nova_metadata_vip: {get_input: nova_metadata_vip}
-                ceilometer_api_vip: {get_input: ceilometer_api_vip}
-                aodh_api_vip: {get_input: aodh_api_vip}
-                gnocchi_api_vip: {get_input: gnocchi_api_vip}
-                heat_api_vip: {get_input: heat_api_vip}
-                horizon_vip: {get_input: horizon_vip}
-                redis_vip: {get_input: redis_vip}
-                mysql_vip: {get_input: mysql_vip}
-                public_virtual_ip: {get_input: public_virtual_ip}
-                controller_virtual_ip: {get_input: control_virtual_ip}
-                internal_api_virtual_ip: {get_input: internal_api_virtual_ip}
-                storage_virtual_ip: {get_input: storage_virtual_ip}
-                storage_mgmt_virtual_ip: {get_input: storage_mgmt_virtual_ip}
-                ironic_api_vip: {get_input: ironic_api_vip}
-                opendaylight_api_vip: {get_input: opendaylight_api_vip}
-                # public_virtual_ip and controller_virtual_ip are needed in
-                # both HAproxy & keepalived.
-                tripleo::haproxy::public_virtual_ip: {get_input: public_virtual_ip}
-                tripleo::haproxy::controller_virtual_ip: {get_input: control_virtual_ip}
-                tripleo::keepalived::public_virtual_ip: {get_input: public_virtual_ip}
-                tripleo::keepalived::controller_virtual_ip: {get_input: control_virtual_ip}
-                tripleo::keepalived::internal_api_virtual_ip: {get_input: internal_api_virtual_ip}
-                tripleo::keepalived::storage_virtual_ip: {get_input: storage_virtual_ip}
-                tripleo::keepalived::storage_mgmt_virtual_ip: {get_input: storage_mgmt_virtual_ip}
-                tripleo::redis_notification::haproxy_monitor_ip: {get_input: control_virtual_ip}
-
+                map_merge:
+                  # Dynamically generate per-service VIP data based on EnabledServices
+                  # This works as follows (outer->inner functions)
+                  # yaql - filters services where no mapping exists in ServiceNetMap
+                  #   map_replace: substitute e.g internal_api with the IP from NetIpMap
+                  #     map_replace: substitute e.g heat_api_network with network name from ServiceNetMap
+                  #       map_merge/repeat: generate a per-service mapping
+                  - yaql:
+                      # This filters any entries where the value hasn't been substituted for
+                      # a list, e.g it's still $service_network.  This happens when there is
+                      # no network defined for the service in the ServiceNetMap, which is OK
+                      # as not all services have to be bound to a network, so we filter them
+                      expression: dict($.data.map.items().where(isString($[1]) and not $[1].endsWith("_network")))
+                      data:
+                        map:
+                          map_replace:
+                            - map_replace:
+                                - map_merge:
+                                    repeat:
+                                      template:
+                                        SERVICE_vip: SERVICE_network
+                                      for_each:
+                                        SERVICE:
+                                          str_split: [',', {get_param: EnabledServices}]
+                                - values: {get_param: ServiceNetMap}
+                            - values: {get_param: NetIpMap}
+                  - keystone_admin_api_vip: {get_input: keystone_admin_api_vip}
+                    keystone_public_api_vip: {get_input: keystone_public_api_vip}
+                    public_virtual_ip: {get_input: public_virtual_ip}
+                    controller_virtual_ip: {get_input: control_virtual_ip}
+                    internal_api_virtual_ip: {get_input: internal_api_virtual_ip}
+                    storage_virtual_ip: {get_input: storage_virtual_ip}
+                    storage_mgmt_virtual_ip: {get_input: storage_mgmt_virtual_ip}
+                    # public_virtual_ip and controller_virtual_ip are needed in
+                    # both HAproxy & keepalived.
+                    tripleo::haproxy::public_virtual_ip: {get_input: public_virtual_ip}
+                    tripleo::haproxy::controller_virtual_ip: {get_input: control_virtual_ip}
+                    tripleo::keepalived::public_virtual_ip: {get_input: public_virtual_ip}
+                    tripleo::keepalived::controller_virtual_ip: {get_input: control_virtual_ip}
+                    tripleo::keepalived::internal_api_virtual_ip: {get_input: internal_api_virtual_ip}
+                    tripleo::keepalived::storage_virtual_ip: {get_input: storage_virtual_ip}
+                    tripleo::keepalived::storage_mgmt_virtual_ip: {get_input: storage_mgmt_virtual_ip}
+                    tripleo::redis_notification::haproxy_monitor_ip: {get_input: control_virtual_ip}
 
 outputs:
   OS::stack_id: