From 679ecaada05768e96a1fcddb7aeb78fc6735809f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Harald=20Jens=C3=A5s?= Date: Sat, 28 Mar 2020 03:47:06 +0100 Subject: [PATCH] Set dns_name propery on ports and networks Neutron's dns_assignments field includes a nice pice of structured data. This is a prerequirement for Designate usage. (No plan's to use that, but being a bit ready does'nt hurt.) {"hostname": "my-vm", "ip_address": "192.0.2.16", "fqdn": "my-vm.example.org."} Enable for the undercloud: - dns_domain_ports ml2 extension driver Change-Id: I46eb9a24dd66821b27524fe4d1fdab617b6fa948 --- deployed-server/ctlplane-port.yaml | 3 ++ deployed-server/deployed-neutron-port.yaml | 3 ++ environments/undercloud.yaml | 2 +- .../undercloud_ctlplane_network.py | 9 ++++- extraconfig/post_deploy/undercloud_post.yaml | 7 ++++ network/network.j2 | 12 ++++++ network/ports/ctlplane_vip.yaml | 5 +++ network/ports/from_service.yaml | 4 ++ network/ports/from_service_v6.yaml | 4 ++ network/ports/noop.yaml | 4 ++ network/ports/port.j2 | 5 +++ network/ports/port_from_pool.j2 | 4 ++ network/ports/vip.yaml | 4 ++ network/ports/vip_v6.yaml | 4 ++ overcloud.j2.yaml | 38 ++++++++++--------- puppet/role.role.j2.yaml | 1 + 16 files changed, 89 insertions(+), 20 deletions(-) diff --git a/deployed-server/ctlplane-port.yaml b/deployed-server/ctlplane-port.yaml index 92ac4042dc..a351248fca 100644 --- a/deployed-server/ctlplane-port.yaml +++ b/deployed-server/ctlplane-port.yaml @@ -9,6 +9,9 @@ parameters: type: json name: type: string + dns_name: + default: '' + type: string replacement_policy: type: string default: AUTO diff --git a/deployed-server/deployed-neutron-port.yaml b/deployed-server/deployed-neutron-port.yaml index f490985e34..662bc4e4ec 100644 --- a/deployed-server/deployed-neutron-port.yaml +++ b/deployed-server/deployed-neutron-port.yaml @@ -21,6 +21,9 @@ parameters: name: default: '' type: string + dns_name: + default: '' + type: string network: default: '' type: string diff --git a/environments/undercloud.yaml b/environments/undercloud.yaml index ae94e61822..fb7bc2bb30 100644 --- a/environments/undercloud.yaml +++ b/environments/undercloud.yaml @@ -153,7 +153,7 @@ parameter_defaults: NeutronServicePlugins: router,segments NeutronMechanismDrivers: ['openvswitch', 'baremetal'] NeutronNetworkVLANRanges: 'physnet1:1000:2999' - NeutronPluginExtensions: 'port_security' + NeutronPluginExtensions: port_security,dns_domain_ports NeutronFirewallDriver: '' NeutronNetworkType: ['local','flat','vlan','gre','vxlan'] NeutronTunnelIdRanges: '20:100' diff --git a/extraconfig/post_deploy/undercloud_ctlplane_network.py b/extraconfig/post_deploy/undercloud_ctlplane_network.py index eec72c8b58..afa7da8eea 100755 --- a/extraconfig/post_deploy/undercloud_ctlplane_network.py +++ b/extraconfig/post_deploy/undercloud_ctlplane_network.py @@ -18,6 +18,9 @@ import subprocess CTLPLANE_NETWORK_NAME = 'ctlplane' CONF = json.loads(os.environ['config']) +CLOUD_DOMAIN = 'ctlplane.' + (CONF['cloud_domain'] + '.' + if not CONF['cloud_domain'].endswith('.') + else CONF['cloud_domain']) def _run_command(args, env=None, name=None): @@ -57,13 +60,15 @@ def _ensure_neutron_network(sdk): name=CTLPLANE_NETWORK_NAME, provider_network_type='flat', provider_physical_network=CONF['physical_network'], - mtu=CONF['mtu']) + mtu=CONF['mtu'], + dns_domain=CLOUD_DOMAIN) print('INFO: Network created %s' % network) else: network = sdk.network.update_network( network[0].id, name=CTLPLANE_NETWORK_NAME, - mtu=CONF['mtu']) + mtu=CONF['mtu'], + dns_domain=CLOUD_DOMAIN) print('INFO: Network updated %s' % network) except Exception: print('ERROR: Network create/update failed.') diff --git a/extraconfig/post_deploy/undercloud_post.yaml b/extraconfig/post_deploy/undercloud_post.yaml index 20cee38fae..f4ba3d598c 100644 --- a/extraconfig/post_deploy/undercloud_post.yaml +++ b/extraconfig/post_deploy/undercloud_post.yaml @@ -87,6 +87,12 @@ parameters: description: Mapping of service endpoint -> protocol. Typically set via parameter_defaults in the resource registry. type: json + CloudDomain: + default: 'localdomain' + type: string + description: > + The DNS domain used for the hosts. This must match the + overcloud_domain_name configured on the undercloud. conditions: @@ -190,6 +196,7 @@ resources: params: JSON: cloud_name: {get_param: UndercloudCloudName} + cloud_domain: {get_param: CloudDomain} local_ip: {get_param: [DeployedServerPortMap, 'control_virtual_ip', fixed_ips, 0, ip_address]} local_subnet: {get_param: UndercloudCtlplaneLocalSubnet} physical_network: {get_param: CtlplaneLocalPhysicalNetwork} diff --git a/network/network.j2 b/network/network.j2 index f2fc759fe8..4a3409e662 100644 --- a/network/network.j2 +++ b/network/network.j2 @@ -137,6 +137,12 @@ parameters: needed. Defaults to true. For multi-stack use cases where the network related resources have already been managed by a separate stack, this parameter can be set to false. + CloudDomain: + default: 'localdomain' + type: string + description: > + The DNS domain used for the hosts. This must match the + overcloud_domain_name configured on the undercloud. conditions: manage_networks: {get_param: ManageNetworks} @@ -151,6 +157,12 @@ resources: properties: admin_state_up: {get_param: {{network.name}}NetAdminStateUp} name: {get_param: {{network.name}}NetName} + dns_domain: + list_join: + - '.' + - - {{network.name.lower()}} + - {get_param: CloudDomain} + - '' shared: {get_param: {{network.name}}NetShared} value_specs: map_merge: diff --git a/network/ports/ctlplane_vip.yaml b/network/ports/ctlplane_vip.yaml index 93cb15b355..1f6a3b8b31 100644 --- a/network/ports/ctlplane_vip.yaml +++ b/network/ports/ctlplane_vip.yaml @@ -17,6 +17,10 @@ parameters: description: Name of the port default: '' type: string + DnsName: + description: DNS name of the port + default: '' + type: string ControlPlaneIP: # Here for compatibility with noop.yaml description: IP address on the control plane default: '' @@ -56,6 +60,7 @@ resources: properties: network: {get_param: ControlPlaneNetwork} name: {get_param: PortName} + dns_name: {get_param: DnsName} fixed_ips: if: - fixed_ip_not_set diff --git a/network/ports/from_service.yaml b/network/ports/from_service.yaml index d9140c716d..2e257a4118 100644 --- a/network/ports/from_service.yaml +++ b/network/ports/from_service.yaml @@ -16,6 +16,10 @@ parameters: description: Name of the port default: '' type: string + DnsName: + description: DNS name of the port + default: '' + type: string ControlPlaneIP: # Here for compatibility with ctlplane_vip.yaml description: IP address on the control plane default: '' diff --git a/network/ports/from_service_v6.yaml b/network/ports/from_service_v6.yaml index 2047ef9576..7b9a29a044 100644 --- a/network/ports/from_service_v6.yaml +++ b/network/ports/from_service_v6.yaml @@ -16,6 +16,10 @@ parameters: description: Name of the port default: '' type: string + DnsName: + description: DNS name of the port + default: '' + type: string ControlPlaneIP: # Here for compatability with ctlplane_vip.yaml description: IP address on the control plane default: '' diff --git a/network/ports/noop.yaml b/network/ports/noop.yaml index ec92a567b9..5ad47dd414 100644 --- a/network/ports/noop.yaml +++ b/network/ports/noop.yaml @@ -29,6 +29,10 @@ parameters: description: Name of the port default: '' type: string + DnsName: + description: DNS name of the port + default: '' + type: string NetworkName: # Here for compatibility with vip.yaml description: Name of the network where the VIP will be created default: ctlplane diff --git a/network/ports/port.j2 b/network/ports/port.j2 index 9151f8430e..7e7adcccb6 100644 --- a/network/ports/port.j2 +++ b/network/ports/port.j2 @@ -13,6 +13,10 @@ parameters: description: Name of the port default: '' type: string + DnsName: + description: DNS name of the port + default: '' + type: string ControlPlaneIP: # Here for compatibility with noop.yaml description: IP address on the control plane default: '' @@ -70,6 +74,7 @@ resources: properties: network: {get_param: {{network.name}}NetName} name: {get_param: PortName} + dns_name: {get_param: DnsName} fixed_ips: if: - net_is_ctlplane_and_fixed_ip_not_set diff --git a/network/ports/port_from_pool.j2 b/network/ports/port_from_pool.j2 index 16f019bb33..0421e192e3 100644 --- a/network/ports/port_from_pool.j2 +++ b/network/ports/port_from_pool.j2 @@ -18,6 +18,10 @@ parameters: description: Name of the port default: '' type: string + DnsName: + description: DNS name of the port + default: '' + type: string FixedIPs: description: > Control the IP allocation for the VIP port. E.g. diff --git a/network/ports/vip.yaml b/network/ports/vip.yaml index 8d0400dd91..97c8e6fc70 100644 --- a/network/ports/vip.yaml +++ b/network/ports/vip.yaml @@ -17,6 +17,10 @@ parameters: description: Name of the port default: '' type: string + DnsName: + description: DNS name of the port + default: '' + type: string ControlPlaneIP: # Here for compatibility with noop.yaml description: IP address on the control plane default: '' diff --git a/network/ports/vip_v6.yaml b/network/ports/vip_v6.yaml index 0902e92a87..c5c071f46d 100644 --- a/network/ports/vip_v6.yaml +++ b/network/ports/vip_v6.yaml @@ -17,6 +17,10 @@ parameters: description: Name of the port default: '' type: string + DnsName: + description: DNS name of the port + default: '' + type: string ControlPlaneIP: # Here for compatability with noop.yaml description: IP address on the control plane default: '' diff --git a/overcloud.j2.yaml b/overcloud.j2.yaml index 401c01b110..089639c947 100644 --- a/overcloud.j2.yaml +++ b/overcloud.j2.yaml @@ -917,6 +917,7 @@ resources: type: OS::TripleO::Network::Ports::ControlPlaneVipPort properties: name: control_virtual_ip + dns_name: {str_split: ['.', {get_param: CloudNameCtlplane}, 0]} network: {get_param: NeutronControlPlaneID} fixed_ips: if: @@ -937,6 +938,7 @@ resources: - {str_split: ['/', {get_attr: [ControlVirtualIP, subnets, 0, cidr]}, 1]} ControlPlaneNetwork: {get_param: NeutronControlPlaneID} PortName: redis_virtual_ip + DnsName: null NetworkName: {get_attr: [ServiceNetMap, service_net_map, RedisNetwork]} ServiceName: redis FixedIPs: @@ -957,6 +959,7 @@ resources: - {str_split: ['/', {get_attr: [ControlVirtualIP, subnets, 0, cidr]}, 1]} ControlPlaneNetwork: {get_param: NeutronControlPlaneID} PortName: ovn_dbs_virtual_ip + DnsName: null NetworkName: {get_attr: [ServiceNetMap, service_net_map, OvnDbsNetwork]} ServiceName: ovn_dbs FixedIPs: @@ -969,24 +972,9 @@ resources: {%- if network.name == 'External' %} # The public VIP is on the External net, falls back to ctlplane PublicVirtualIP: - depends_on: [Networks, ServiceNetMap] - type: OS::TripleO::Network::Ports::ExternalVipPort - properties: - ControlPlaneIP: {get_attr: [ControlVirtualIP, fixed_ips, 0, ip_address]} - ControlPlaneSubnetCidr: - if: - - ctlplane_subnet_cidr_set - - {get_param: ControlPlaneSubnetCidr} - - {str_split: ['/', {get_attr: [ControlVirtualIP, subnets, 0, cidr]}, 1]} - ControlPlaneNetwork: {get_param: NeutronControlPlaneID} - PortName: public_virtual_ip - FixedIPs: - if: - - public_virtual_fixed_ip_set - - {get_param: PublicVirtualFixedIPs} - - [{subnet: {get_attr: [ServiceNetMap, vip_subnet_map, {{network.name}}]}}] {%- else %} {{network.name}}VirtualIP: + {%- endif %} depends_on: [Networks, ServiceNetMap] type: OS::TripleO::Network::Ports::{{network.name}}VipPort properties: @@ -996,13 +984,29 @@ resources: - ctlplane_subnet_cidr_set - {get_param: ControlPlaneSubnetCidr} - {str_split: ['/', {get_attr: [ControlVirtualIP, subnets, 0, cidr]}, 1]} + {%- if network.name == 'External' %} + PortName: public_virtual_ip + DnsName: {str_split: ['.', {get_param: CloudName}, 0]} + {%- else %} PortName: {{network.name_lower}}_virtual_ip + {%- endif %} + {%- if network.name == 'InternalApi' %} + DnsName: {str_split: ['.', {get_param: CloudNameInternal}, 0]} + {%- elif network.name == 'StorageMgmt' %} + DnsName: {str_split: ['.', {get_param: CloudNameStorageManagement}, 0]} + {%- elif network.name not in ['External', 'InternalApi', 'StorageMgmt'] %} + DnsName: {str_split: ['.', {get_param: CloudName{{network.name}}}, 0]} + {%- endif %} FixedIPs: if: + {%- if network.name == 'External' %} + - public_virtual_fixed_ip_set + - {get_param: PublicVirtualFixedIPs} + {%- else %} - {{network.name_lower}}_virtual_fixed_ip_set - {get_param: {{network.name}}VirtualFixedIPs} + {%- endif %} - [{subnet: {get_attr: [ServiceNetMap, vip_subnet_map, {{network.name}}]}}] - {% endif %} {%- endfor %} VipMap: diff --git a/puppet/role.role.j2.yaml b/puppet/role.role.j2.yaml index 64fa4300c5..d1c120c19f 100644 --- a/puppet/role.role.j2.yaml +++ b/puppet/role.role.j2.yaml @@ -374,6 +374,7 @@ resources: - '_' - - {get_attr: [{{server_resource_name}}, name]} - {{network.name}} + DnsName: {get_attr: [{{server_resource_name}}, name]} ControlPlaneIP: {get_attr: [{{server_resource_name}}, networks, ctlplane, 0]} FixedIPs: if: