From c649cf05453538eda783021e3604d4754dc5a3de Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Harald=20Jens=C3=A5s?= <hjensas@redhat.com>
Date: Sat, 30 Jun 2018 17:48:25 +0200
Subject: [PATCH] ControlPlaneDefaultRoute using get_attr

Use get_attr on the server resource to resolve attribute
value from the subnet(s) and pass it to the parameter
'ControlPlaneDefaultRoute' used in the THT/network/config/*
templates.

Changes the default for 'ControlPlaneDefaultRoute' to ''
as well as the comment that the value should be overriden
in parameters_defaults. It also removes the parameter from
network-environment templates.

A conditinal is used in  puppet/role.role.j2.yaml so that
the parameter value is used whenever it is not '' (the
default) to provide backwards compatibility in case the
user set a different value (different from the one used in
undercloud.conf) for this parameter in
network-environment.yaml.

When deploying a routed control plane the network config
templates would previously need to be updated to carry
'ControlPlaneXDefaultRoute' parameters for each leaf. With
8 Leafs in addition to the network local to the undercloud
that is 8 parameters less to place in the configuration.
By getting the value to pass from the server resource this
change reduces the required nic-config template
customisation (reduces the risk of user error).

Partial: blueprint tripleo-routed-networks-templates
Change-Id: I5139249d55e9ac01761c270b8c0f31ef35595940
---
 .../net-config-multinode-os-net-config.yaml   |  5 ++++
 ci/common/net-config-multinode.yaml           |  5 ++++
 ci/common/net-config-simple-bridge.yaml       |  5 ++++
 .../network-environment.yaml                  |  1 -
 .../nic-configs/ceph-storage.yaml             |  6 +++--
 .../nic-configs/cinder-storage.yaml           |  6 +++--
 .../nic-configs/compute.yaml                  |  6 +++--
 .../nic-configs/controller.yaml               |  6 +++--
 .../nic-configs/swift-storage.yaml            |  6 +++--
 .../multiple-nics/network-environment.yaml    |  1 -
 .../nic-configs/ceph-storage.yaml             |  6 +++--
 .../nic-configs/cinder-storage.yaml           |  6 +++--
 .../multiple-nics/nic-configs/compute.yaml    |  6 +++--
 .../multiple-nics/nic-configs/controller.yaml |  6 +++--
 .../nic-configs/swift-storage.yaml            |  6 +++--
 .../public-bond/network-environment.yaml      |  1 -
 .../public-bond/nic-configs/ceph-storage.yaml |  6 +++--
 .../nic-configs/cinder-storage.yaml           |  6 +++--
 .../public-bond/nic-configs/compute.yaml      |  6 +++--
 .../public-bond/nic-configs/controller.yaml   |  6 +++--
 .../nic-configs/swift-storage.yaml            |  6 +++--
 environments/network-environment-v6.j2.yaml   |  5 ++--
 environments/network-environment.j2.yaml      |  5 ++--
 net-config-bond.j2.yaml                       |  5 ++++
 net-config-bridge.j2.yaml                     |  5 ++++
 net-config-linux-bridge.j2.yaml               |  5 ++--
 net-config-noop.j2.yaml                       |  5 ++++
 net-config-standalone.j2.yaml                 |  5 ++++
 ...g-static-bridge-with-external-dhcp.j2.yaml |  6 +++--
 net-config-static-bridge.j2.yaml              |  6 +++--
 net-config-static.j2.yaml                     |  6 +++--
 net-config-undercloud.j2.yaml                 |  5 ++++
 .../controller-no-external.j2.yaml            |  6 +++--
 .../bond-with-vlans/controller-v6.j2.yaml     |  6 +++--
 .../config/bond-with-vlans/role.role.j2.yaml  |  6 +++--
 .../config/multiple-nics/compute-dvr.j2.yaml  |  6 +++--
 .../multiple-nics/controller-v6.j2.yaml       |  6 +++--
 .../config/multiple-nics/role.role.j2.yaml    |  6 +++--
 .../controller-v6.j2.yaml                     |  6 +++--
 .../role.role.j2.yaml                         |  6 +++--
 .../controller-no-external.j2.yaml            |  6 +++--
 .../single-nic-vlans/controller-v6.j2.yaml    |  6 +++--
 .../config/single-nic-vlans/role.role.j2.yaml |  6 +++--
 puppet/role.role.j2.yaml                      | 13 ++++++++++
 ...lplane-default-route-625ef5e414a65f2e.yaml | 25 +++++++++++++++++++
 45 files changed, 203 insertions(+), 67 deletions(-)
 create mode 100644 releasenotes/notes/use-subnet-attrs-ctlplane-default-route-625ef5e414a65f2e.yaml

diff --git a/ci/common/net-config-multinode-os-net-config.yaml b/ci/common/net-config-multinode-os-net-config.yaml
index 5b600c6910..6c5cfbeb2a 100644
--- a/ci/common/net-config-multinode-os-net-config.yaml
+++ b/ci/common/net-config-multinode-os-net-config.yaml
@@ -43,6 +43,11 @@ parameters:
       The subnet CIDR of the control plane network. (The parameter is
       automatically resolved from the ctlplane subnet's cidr attribute.)
     type: string
+  ControlPlaneDefaultRoute:
+    default: ''
+    description: The default route of the control plane network. (The parameter
+      is automatically resolved from the ctlplane subnet's gateway_ip attribute.)
+    type: string
   OvSBridgeMtu:
     default: 1300
     description: The mtu of the OvS bridge
diff --git a/ci/common/net-config-multinode.yaml b/ci/common/net-config-multinode.yaml
index eb74a39e8c..3cf40e1236 100644
--- a/ci/common/net-config-multinode.yaml
+++ b/ci/common/net-config-multinode.yaml
@@ -43,6 +43,11 @@ parameters:
       The subnet CIDR of the control plane network. (The parameter is
       automatically resolved from the ctlplane subnet's cidr attribute.)
     type: string
+  ControlPlaneDefaultRoute:
+    default: ''
+    description: The default route of the control plane network. (The parameter
+      is automatically resolved from the ctlplane subnet's gateway_ip attribute.)
+    type: string
 
 resources:
   OsNetConfigImpl:
diff --git a/ci/common/net-config-simple-bridge.yaml b/ci/common/net-config-simple-bridge.yaml
index f777d74fdb..575984c392 100644
--- a/ci/common/net-config-simple-bridge.yaml
+++ b/ci/common/net-config-simple-bridge.yaml
@@ -12,6 +12,11 @@ parameters:
       The subnet CIDR of the control plane network. (The parameter is
       automatically resolved from the ctlplane subnet's cidr attribute.)
     type: string
+  ControlPlaneDefaultRoute:
+    default: ''
+    description: The default route of the control plane network. (The parameter
+      is automatically resolved from the ctlplane subnet's gateway_ip attribute.)
+    type: string
   ExternalIpSubnet:
     default: ''
     description: IP address/subnet on the external network
diff --git a/ci/environments/network/multiple-nics-ipv6/network-environment.yaml b/ci/environments/network/multiple-nics-ipv6/network-environment.yaml
index be1d57aa2b..860aa32e96 100644
--- a/ci/environments/network/multiple-nics-ipv6/network-environment.yaml
+++ b/ci/environments/network/multiple-nics-ipv6/network-environment.yaml
@@ -7,7 +7,6 @@ resource_registry:
   OS::TripleO::CephStorage::Net::SoftwareConfig: nic-configs/ceph-storage.yaml
 
 parameter_defaults:
-  ControlPlaneDefaultRoute: 192.168.24.1
   EC2MetadataIp: 192.168.24.1
   ExternalNetCidr: 2001:db8:fd00:1000::/64
   ExternalAllocationPools: [{"start": "2001:db8:fd00:1000::10", "end": "2001:db8:fd00:1000:ffff:ffff:ffff:fffe"}]
diff --git a/ci/environments/network/multiple-nics-ipv6/nic-configs/ceph-storage.yaml b/ci/environments/network/multiple-nics-ipv6/nic-configs/ceph-storage.yaml
index bfbfcc7e7b..e55c7f2e4a 100644
--- a/ci/environments/network/multiple-nics-ipv6/nic-configs/ceph-storage.yaml
+++ b/ci/environments/network/multiple-nics-ipv6/nic-configs/ceph-storage.yaml
@@ -68,8 +68,10 @@ parameters:
       The subnet CIDR of the control plane network. (The parameter is
       automatically resolved from the ctlplane subnet's cidr attribute.)
     type: string
-  ControlPlaneDefaultRoute: # Override this via parameter_defaults
-    description: The default route of the control plane network.
+  ControlPlaneDefaultRoute:
+    default: ''
+    description: The default route of the control plane network. (The parameter
+      is automatically resolved from the ctlplane subnet's gateway_ip attribute.)
     type: string
   DnsServers: # Override this via parameter_defaults
     default: []
diff --git a/ci/environments/network/multiple-nics-ipv6/nic-configs/cinder-storage.yaml b/ci/environments/network/multiple-nics-ipv6/nic-configs/cinder-storage.yaml
index 816accf974..de5d919635 100644
--- a/ci/environments/network/multiple-nics-ipv6/nic-configs/cinder-storage.yaml
+++ b/ci/environments/network/multiple-nics-ipv6/nic-configs/cinder-storage.yaml
@@ -68,8 +68,10 @@ parameters:
       The subnet CIDR of the control plane network. (The parameter is
       automatically resolved from the ctlplane subnet's cidr attribute.)
     type: string
-  ControlPlaneDefaultRoute: # Override this via parameter_defaults
-    description: The default route of the control plane network.
+  ControlPlaneDefaultRoute:
+    default: ''
+    description: The default route of the control plane network. (The parameter
+      is automatically resolved from the ctlplane subnet's gateway_ip attribute.)
     type: string
   DnsServers: # Override this via parameter_defaults
     default: []
diff --git a/ci/environments/network/multiple-nics-ipv6/nic-configs/compute.yaml b/ci/environments/network/multiple-nics-ipv6/nic-configs/compute.yaml
index 157655e07e..b2fe4f72a6 100644
--- a/ci/environments/network/multiple-nics-ipv6/nic-configs/compute.yaml
+++ b/ci/environments/network/multiple-nics-ipv6/nic-configs/compute.yaml
@@ -68,8 +68,10 @@ parameters:
       The subnet CIDR of the control plane network. (The parameter is
       automatically resolved from the ctlplane subnet's cidr attribute.)
     type: string
-  ControlPlaneDefaultRoute: # Override this via parameter_defaults
-    description: The default route of the control plane network.
+  ControlPlaneDefaultRoute:
+    default: ''
+    description: The default route of the control plane network. (The parameter
+      is automatically resolved from the ctlplane subnet's gateway_ip attribute.)
     type: string
   DnsServers: # Override this via parameter_defaults
     default: []
diff --git a/ci/environments/network/multiple-nics-ipv6/nic-configs/controller.yaml b/ci/environments/network/multiple-nics-ipv6/nic-configs/controller.yaml
index 4df246f16e..a119e720ad 100644
--- a/ci/environments/network/multiple-nics-ipv6/nic-configs/controller.yaml
+++ b/ci/environments/network/multiple-nics-ipv6/nic-configs/controller.yaml
@@ -68,8 +68,10 @@ parameters:
       The subnet CIDR of the control plane network. (The parameter is
       automatically resolved from the ctlplane subnet's cidr attribute.)
     type: string
-  ControlPlaneDefaultRoute: # Override this via parameter_defaults
-    description: The default route of the control plane network.
+  ControlPlaneDefaultRoute:
+    default: ''
+    description: The default route of the control plane network. (The parameter
+      is automatically resolved from the ctlplane subnet's gateway_ip attribute.)
     type: string
   DnsServers: # Override this via parameter_defaults
     default: []
diff --git a/ci/environments/network/multiple-nics-ipv6/nic-configs/swift-storage.yaml b/ci/environments/network/multiple-nics-ipv6/nic-configs/swift-storage.yaml
index 816accf974..de5d919635 100644
--- a/ci/environments/network/multiple-nics-ipv6/nic-configs/swift-storage.yaml
+++ b/ci/environments/network/multiple-nics-ipv6/nic-configs/swift-storage.yaml
@@ -68,8 +68,10 @@ parameters:
       The subnet CIDR of the control plane network. (The parameter is
       automatically resolved from the ctlplane subnet's cidr attribute.)
     type: string
-  ControlPlaneDefaultRoute: # Override this via parameter_defaults
-    description: The default route of the control plane network.
+  ControlPlaneDefaultRoute:
+    default: ''
+    description: The default route of the control plane network. (The parameter
+      is automatically resolved from the ctlplane subnet's gateway_ip attribute.)
     type: string
   DnsServers: # Override this via parameter_defaults
     default: []
diff --git a/ci/environments/network/multiple-nics/network-environment.yaml b/ci/environments/network/multiple-nics/network-environment.yaml
index 6a9c160637..4f5e0b5274 100644
--- a/ci/environments/network/multiple-nics/network-environment.yaml
+++ b/ci/environments/network/multiple-nics/network-environment.yaml
@@ -7,7 +7,6 @@ resource_registry:
   OS::TripleO::CephStorage::Net::SoftwareConfig: nic-configs/ceph-storage.yaml
 
 parameter_defaults:
-  ControlPlaneDefaultRoute: 192.168.24.1
   EC2MetadataIp: 192.168.24.1
   ExternalNetCidr: 10.0.0.0/24
   ExternalAllocationPools: [{"start": "10.0.0.10", "end": "10.0.0.50"}]
diff --git a/ci/environments/network/multiple-nics/nic-configs/ceph-storage.yaml b/ci/environments/network/multiple-nics/nic-configs/ceph-storage.yaml
index 5aa345bc36..6e3ac01a03 100644
--- a/ci/environments/network/multiple-nics/nic-configs/ceph-storage.yaml
+++ b/ci/environments/network/multiple-nics/nic-configs/ceph-storage.yaml
@@ -68,8 +68,10 @@ parameters:
       The subnet CIDR of the control plane network. (The parameter is
       automatically resolved from the ctlplane subnet's cidr attribute.)
     type: string
-  ControlPlaneDefaultRoute: # Override this via parameter_defaults
-    description: The default route of the control plane network.
+  ControlPlaneDefaultRoute:
+    default: ''
+    description: The default route of the control plane network. (The parameter
+      is automatically resolved from the ctlplane subnet's gateway_ip attribute.)
     type: string
   DnsServers: # Override this via parameter_defaults
     default: []
diff --git a/ci/environments/network/multiple-nics/nic-configs/cinder-storage.yaml b/ci/environments/network/multiple-nics/nic-configs/cinder-storage.yaml
index efb41bf2cb..4ca0188b09 100644
--- a/ci/environments/network/multiple-nics/nic-configs/cinder-storage.yaml
+++ b/ci/environments/network/multiple-nics/nic-configs/cinder-storage.yaml
@@ -68,8 +68,10 @@ parameters:
       The subnet CIDR of the control plane network. (The parameter is
       automatically resolved from the ctlplane subnet's cidr attribute.)
     type: string
-  ControlPlaneDefaultRoute: # Override this via parameter_defaults
-    description: The default route of the control plane network.
+  ControlPlaneDefaultRoute:
+    default: ''
+    description: The default route of the control plane network. (The parameter
+      is automatically resolved from the ctlplane subnet's gateway_ip attribute.)
     type: string
   DnsServers: # Override this via parameter_defaults
     default: []
diff --git a/ci/environments/network/multiple-nics/nic-configs/compute.yaml b/ci/environments/network/multiple-nics/nic-configs/compute.yaml
index f2a729a19c..444726d581 100644
--- a/ci/environments/network/multiple-nics/nic-configs/compute.yaml
+++ b/ci/environments/network/multiple-nics/nic-configs/compute.yaml
@@ -68,8 +68,10 @@ parameters:
       The subnet CIDR of the control plane network. (The parameter is
       automatically resolved from the ctlplane subnet's cidr attribute.)
     type: string
-  ControlPlaneDefaultRoute: # Override this via parameter_defaults
-    description: The default route of the control plane network.
+  ControlPlaneDefaultRoute:
+    default: ''
+    description: The default route of the control plane network. (The parameter
+      is automatically resolved from the ctlplane subnet's gateway_ip attribute.)
     type: string
   DnsServers: # Override this via parameter_defaults
     default: []
diff --git a/ci/environments/network/multiple-nics/nic-configs/controller.yaml b/ci/environments/network/multiple-nics/nic-configs/controller.yaml
index 67ff1982fe..f58604af83 100644
--- a/ci/environments/network/multiple-nics/nic-configs/controller.yaml
+++ b/ci/environments/network/multiple-nics/nic-configs/controller.yaml
@@ -68,8 +68,10 @@ parameters:
       The subnet CIDR of the control plane network. (The parameter is
       automatically resolved from the ctlplane subnet's cidr attribute.)
     type: string
-  ControlPlaneDefaultRoute: # Override this via parameter_defaults
-    description: The default route of the control plane network.
+  ControlPlaneDefaultRoute:
+    default: ''
+    description: The default route of the control plane network. (The parameter
+      is automatically resolved from the ctlplane subnet's gateway_ip attribute.)
     type: string
   DnsServers: # Override this via parameter_defaults
     default: []
diff --git a/ci/environments/network/multiple-nics/nic-configs/swift-storage.yaml b/ci/environments/network/multiple-nics/nic-configs/swift-storage.yaml
index efb41bf2cb..4ca0188b09 100644
--- a/ci/environments/network/multiple-nics/nic-configs/swift-storage.yaml
+++ b/ci/environments/network/multiple-nics/nic-configs/swift-storage.yaml
@@ -68,8 +68,10 @@ parameters:
       The subnet CIDR of the control plane network. (The parameter is
       automatically resolved from the ctlplane subnet's cidr attribute.)
     type: string
-  ControlPlaneDefaultRoute: # Override this via parameter_defaults
-    description: The default route of the control plane network.
+  ControlPlaneDefaultRoute:
+    default: ''
+    description: The default route of the control plane network. (The parameter
+      is automatically resolved from the ctlplane subnet's gateway_ip attribute.)
     type: string
   DnsServers: # Override this via parameter_defaults
     default: []
diff --git a/ci/environments/network/public-bond/network-environment.yaml b/ci/environments/network/public-bond/network-environment.yaml
index 905a876082..6ff32a7049 100644
--- a/ci/environments/network/public-bond/network-environment.yaml
+++ b/ci/environments/network/public-bond/network-environment.yaml
@@ -7,7 +7,6 @@ resource_registry:
   OS::TripleO::CephStorage::Net::SoftwareConfig: nic-configs/ceph-storage.yaml
 
 parameter_defaults:
-  ControlPlaneDefaultRoute: 192.168.24.1
   EC2MetadataIp: 192.168.24.1
   ExternalNetCidr: 10.0.0.0/24
   ExternalAllocationPools: [{"start": "10.0.0.10", "end": "10.0.0.50"}]
diff --git a/ci/environments/network/public-bond/nic-configs/ceph-storage.yaml b/ci/environments/network/public-bond/nic-configs/ceph-storage.yaml
index 0f66ba81c8..7b8091f499 100644
--- a/ci/environments/network/public-bond/nic-configs/ceph-storage.yaml
+++ b/ci/environments/network/public-bond/nic-configs/ceph-storage.yaml
@@ -68,8 +68,10 @@ parameters:
       The subnet CIDR of the control plane network. (The parameter is
       automatically resolved from the ctlplane subnet's cidr attribute.)
     type: string
-  ControlPlaneDefaultRoute: # Override this via parameter_defaults
-    description: The default route of the control plane network.
+  ControlPlaneDefaultRoute:
+    default: ''
+    description: The default route of the control plane network. (The parameter
+      is automatically resolved from the ctlplane subnet's gateway_ip attribute.)
     type: string
   DnsServers: # Override this via parameter_defaults
     default: []
diff --git a/ci/environments/network/public-bond/nic-configs/cinder-storage.yaml b/ci/environments/network/public-bond/nic-configs/cinder-storage.yaml
index 441c84a37e..94f23c9d7e 100644
--- a/ci/environments/network/public-bond/nic-configs/cinder-storage.yaml
+++ b/ci/environments/network/public-bond/nic-configs/cinder-storage.yaml
@@ -68,8 +68,10 @@ parameters:
       The subnet CIDR of the control plane network. (The parameter is
       automatically resolved from the ctlplane subnet's cidr attribute.)
     type: string
-  ControlPlaneDefaultRoute: # Override this via parameter_defaults
-    description: The default route of the control plane network.
+  ControlPlaneDefaultRoute:
+    default: ''
+    description: The default route of the control plane network. (The parameter
+      is automatically resolved from the ctlplane subnet's gateway_ip attribute.)
     type: string
   DnsServers: # Override this via parameter_defaults
     default: []
diff --git a/ci/environments/network/public-bond/nic-configs/compute.yaml b/ci/environments/network/public-bond/nic-configs/compute.yaml
index e8bb722be9..66622a149e 100644
--- a/ci/environments/network/public-bond/nic-configs/compute.yaml
+++ b/ci/environments/network/public-bond/nic-configs/compute.yaml
@@ -68,8 +68,10 @@ parameters:
       The subnet CIDR of the control plane network. (The parameter is
       automatically resolved from the ctlplane subnet's cidr attribute.)
     type: string
-  ControlPlaneDefaultRoute: # Override this via parameter_defaults
-    description: The default route of the control plane network.
+  ControlPlaneDefaultRoute:
+    default: ''
+    description: The default route of the control plane network. (The parameter
+      is automatically resolved from the ctlplane subnet's gateway_ip attribute.)
     type: string
   DnsServers: # Override this via parameter_defaults
     default: []
diff --git a/ci/environments/network/public-bond/nic-configs/controller.yaml b/ci/environments/network/public-bond/nic-configs/controller.yaml
index 968cd63835..896995ee11 100644
--- a/ci/environments/network/public-bond/nic-configs/controller.yaml
+++ b/ci/environments/network/public-bond/nic-configs/controller.yaml
@@ -68,8 +68,10 @@ parameters:
       The subnet CIDR of the control plane network. (The parameter is
       automatically resolved from the ctlplane subnet's cidr attribute.)
     type: string
-  ControlPlaneDefaultRoute: # Override this via parameter_defaults
-    description: The default route of the control plane network.
+  ControlPlaneDefaultRoute:
+    default: ''
+    description: The default route of the control plane network. (The parameter
+      is automatically resolved from the ctlplane subnet's gateway_ip attribute.)
     type: string
   DnsServers: # Override this via parameter_defaults
     default: []
diff --git a/ci/environments/network/public-bond/nic-configs/swift-storage.yaml b/ci/environments/network/public-bond/nic-configs/swift-storage.yaml
index 441c84a37e..94f23c9d7e 100644
--- a/ci/environments/network/public-bond/nic-configs/swift-storage.yaml
+++ b/ci/environments/network/public-bond/nic-configs/swift-storage.yaml
@@ -68,8 +68,10 @@ parameters:
       The subnet CIDR of the control plane network. (The parameter is
       automatically resolved from the ctlplane subnet's cidr attribute.)
     type: string
-  ControlPlaneDefaultRoute: # Override this via parameter_defaults
-    description: The default route of the control plane network.
+  ControlPlaneDefaultRoute:
+    default: ''
+    description: The default route of the control plane network. (The parameter
+      is automatically resolved from the ctlplane subnet's gateway_ip attribute.)
     type: string
   DnsServers: # Override this via parameter_defaults
     default: []
diff --git a/environments/network-environment-v6.j2.yaml b/environments/network-environment-v6.j2.yaml
index 041bc4966b..5242fea944 100644
--- a/environments/network-environment-v6.j2.yaml
+++ b/environments/network-environment-v6.j2.yaml
@@ -21,9 +21,10 @@ parameter_defaults:
   # ControlPlaneSubnetCidr: It is no longer a requirement to provide this
   #                         parameter. The attribute is resolved from the
   #                         ctlplane subnet(s).
+  # ControlPlaneDefaultRoute: It is no longer a requirement to provide this
+  #                           parameter. The attribute is resolved from the
+  #                           ctlplane subnet(s).
   #
-  # Gateway router for the provisioning network (or Undercloud IP)
-  ControlPlaneDefaultRoute: 192.168.24.254
   EC2MetadataIp: 192.168.24.1  # Generally the IP of the Undercloud
 {% for network in networks if network.enabled|default(true) %}
 {%-     if network.name != 'Tenant' %}
diff --git a/environments/network-environment.j2.yaml b/environments/network-environment.j2.yaml
index a2adcfc32e..a44a3dd8d1 100644
--- a/environments/network-environment.j2.yaml
+++ b/environments/network-environment.j2.yaml
@@ -17,9 +17,10 @@ parameter_defaults:
   # ControlPlaneSubnetCidr: It is no longer a requirement to provide the
   #                         parameter. The attribute is resolved from the
   #                         ctlplane subnet(s).
+  # ControlPlaneDefaultRoute: It is no longer a requirement to provide this
+  #                           parameter. The attribute is resolved from the
+  #                           ctlplane subnet(s).
   #
-  # Gateway router for the provisioning network (or Undercloud IP)
-  ControlPlaneDefaultRoute: 192.168.24.254
   EC2MetadataIp: 192.168.24.1  # Generally the IP of the Undercloud
 {% for network in networks if network.enabled|default(true) %}
   # Customize the IP subnet to match the local environment
diff --git a/net-config-bond.j2.yaml b/net-config-bond.j2.yaml
index da0b5a61fe..537efac323 100644
--- a/net-config-bond.j2.yaml
+++ b/net-config-bond.j2.yaml
@@ -22,6 +22,11 @@ parameters:
       The subnet CIDR of the control plane network. (The parameter is
       automatically resolved from the ctlplane subnet's cidr attribute.)
     type: string
+  ControlPlaneDefaultRoute:
+    default: ''
+    description: The default route of the control plane network. (The parameter
+      is automatically resolved from the ctlplane subnet's gateway_ip attribute.)
+    type: string
   {%- for network in networks %}
   {{network.name}}IpSubnet:
     default: ''
diff --git a/net-config-bridge.j2.yaml b/net-config-bridge.j2.yaml
index 7ef75b86d3..c1b922122b 100644
--- a/net-config-bridge.j2.yaml
+++ b/net-config-bridge.j2.yaml
@@ -12,6 +12,11 @@ parameters:
       The subnet CIDR of the control plane network. (The parameter is
       automatically resolved from the ctlplane subnet's cidr attribute.)
     type: string
+  ControlPlaneDefaultRoute:
+    default: ''
+    description: The default route of the control plane network. (The parameter
+      is automatically resolved from the ctlplane subnet's gateway_ip attribute.)
+    type: string
   {%- for network in networks %}
   {{network.name}}IpSubnet:
     default: ''
diff --git a/net-config-linux-bridge.j2.yaml b/net-config-linux-bridge.j2.yaml
index 5f822628ca..6a838e63f8 100644
--- a/net-config-linux-bridge.j2.yaml
+++ b/net-config-linux-bridge.j2.yaml
@@ -12,8 +12,9 @@ parameters:
     description: IP address/subnet on the {{network.name_lower}} network
     type: string
   {%- endfor %}
-  ControlPlaneDefaultRoute: # Override this via parameter_defaults
-    description: The default route of the control plane network.
+  ControlPlaneDefaultRoute:
+    description: The default route of the control plane network. (The parameter
+      is automatically resolved from the ctlplane subnet's gateway_ip attribute.)
     type: string
     default: 192.168.24.1
   ControlPlaneSubnetCidr:
diff --git a/net-config-noop.j2.yaml b/net-config-noop.j2.yaml
index 2c032974e6..8be8f7baf8 100644
--- a/net-config-noop.j2.yaml
+++ b/net-config-noop.j2.yaml
@@ -15,6 +15,11 @@ parameters:
       The subnet CIDR of the control plane network. (The parameter is
       automatically resolved from the ctlplane subnet's cidr attribute.)
     type: string
+  ControlPlaneDefaultRoute:
+    default: ''
+    description: The default route of the control plane network. (The parameter
+      is automatically resolved from the ctlplane subnet's gateway_ip attribute.)
+    type: string
   {%- for network in networks %}
   {{network.name}}IpSubnet:
     default: ''
diff --git a/net-config-standalone.j2.yaml b/net-config-standalone.j2.yaml
index 1e09c2ef16..7480ca38a9 100644
--- a/net-config-standalone.j2.yaml
+++ b/net-config-standalone.j2.yaml
@@ -19,6 +19,11 @@ parameters:
       The subnet CIDR of the control plane network. (The parameter is
       automatically resolved from the ctlplane subnet's cidr attribute.)
     type: string
+  ControlPlaneDefaultRoute:
+    default: ''
+    description: The default route of the control plane network. (The parameter
+      is automatically resolved from the ctlplane subnet's gateway_ip attribute.)
+    type: string
   ControlPlaneStaticRoutes:
     default: []
     description: A list of static routes
diff --git a/net-config-static-bridge-with-external-dhcp.j2.yaml b/net-config-static-bridge-with-external-dhcp.j2.yaml
index 8b047e957a..0beff02aa2 100644
--- a/net-config-static-bridge-with-external-dhcp.j2.yaml
+++ b/net-config-static-bridge-with-external-dhcp.j2.yaml
@@ -19,8 +19,10 @@ parameters:
       The subnet CIDR of the control plane network. (The parameter is
       automatically resolved from the ctlplane subnet's cidr attribute.)
     type: string
-  ControlPlaneDefaultRoute: # Override this via parameter_defaults
-    description: The default route of the control plane network.
+  ControlPlaneDefaultRoute:
+    default: ''
+    description: The default route of the control plane network. (The parameter
+      is automatically resolved from the ctlplane subnet's gateway_ip attribute.)
     type: string
   DnsServers: # Override this via parameter_defaults
     default: []
diff --git a/net-config-static-bridge.j2.yaml b/net-config-static-bridge.j2.yaml
index 51d97653b0..f1a6bd363b 100644
--- a/net-config-static-bridge.j2.yaml
+++ b/net-config-static-bridge.j2.yaml
@@ -19,8 +19,10 @@ parameters:
       The subnet CIDR of the control plane network. (The parameter is
       automatically resolved from the ctlplane subnet's cidr attribute.)
     type: string
-  ControlPlaneDefaultRoute: # Override this via parameter_defaults
-    description: The default route of the control plane network.
+  ControlPlaneDefaultRoute:
+    default: ''
+    description: The default route of the control plane network. (The parameter
+      is automatically resolved from the ctlplane subnet's gateway_ip attribute.)
     type: string
   DnsServers: # Override this via parameter_defaults
     default: []
diff --git a/net-config-static.j2.yaml b/net-config-static.j2.yaml
index 0cda610a75..75aa65636c 100644
--- a/net-config-static.j2.yaml
+++ b/net-config-static.j2.yaml
@@ -18,8 +18,10 @@ parameters:
       The subnet CIDR of the control plane network. (The parameter is
       automatically resolved from the ctlplane subnet's cidr attribute.)
     type: string
-  ControlPlaneDefaultRoute: # Override this via parameter_defaults
-    description: The default route of the control plane network.
+  ControlPlaneDefaultRoute:
+    default: ''
+    description: The default route of the control plane network. (The parameter
+      is automatically resolved from the ctlplane subnet's gateway_ip attribute.)
     type: string
   DnsServers: # Override this via parameter_defaults
     default: []
diff --git a/net-config-undercloud.j2.yaml b/net-config-undercloud.j2.yaml
index ea1c1882d8..7720d71f1b 100644
--- a/net-config-undercloud.j2.yaml
+++ b/net-config-undercloud.j2.yaml
@@ -19,6 +19,11 @@ parameters:
       The subnet CIDR of the control plane network. (The parameter is
       automatically resolved from the ctlplane subnet's cidr attribute.)
     type: string
+  ControlPlaneDefaultRoute:
+    default: ''
+    description: The default route of the control plane network. (The parameter
+      is automatically resolved from the ctlplane subnet's gateway_ip attribute.)
+    type: string
   ControlPlaneStaticRoutes:
     default: []
     description: A list of static routes
diff --git a/network/config/bond-with-vlans/controller-no-external.j2.yaml b/network/config/bond-with-vlans/controller-no-external.j2.yaml
index 7358affea3..62e922a5d5 100644
--- a/network/config/bond-with-vlans/controller-no-external.j2.yaml
+++ b/network/config/bond-with-vlans/controller-no-external.j2.yaml
@@ -16,8 +16,10 @@ parameters:
       The subnet CIDR of the control plane network. (The parameter is
       automatically resolved from the ctlplane subnet's cidr attribute.)
     type: string
-  ControlPlaneDefaultRoute: # Override this via parameter_defaults
-    description: The default route of the control plane network.
+  ControlPlaneDefaultRoute:
+    default: ''
+    description: The default route of the control plane network. (The parameter
+      is automatically resolved from the ctlplane subnet's gateway_ip attribute.)
     type: string
 {%- for network in networks %}
   {{network.name}}IpSubnet:
diff --git a/network/config/bond-with-vlans/controller-v6.j2.yaml b/network/config/bond-with-vlans/controller-v6.j2.yaml
index 2403a40db0..a676459188 100644
--- a/network/config/bond-with-vlans/controller-v6.j2.yaml
+++ b/network/config/bond-with-vlans/controller-v6.j2.yaml
@@ -14,8 +14,10 @@ parameters:
       The subnet CIDR of the control plane network. (The parameter is
       automatically resolved from the ctlplane subnet's cidr attribute.)
     type: string
-  ControlPlaneDefaultRoute: # Override this via parameter_defaults
-    description: The default route of the control plane network.
+  ControlPlaneDefaultRoute:
+    default: ''
+    description: The default route of the control plane network. (The parameter
+      is automatically resolved from the ctlplane subnet's gateway_ip attribute.)
     type: string
 {%- for network in networks %}
   {{network.name}}IpSubnet:
diff --git a/network/config/bond-with-vlans/role.role.j2.yaml b/network/config/bond-with-vlans/role.role.j2.yaml
index 0580a8b441..b6a8c9e3d0 100644
--- a/network/config/bond-with-vlans/role.role.j2.yaml
+++ b/network/config/bond-with-vlans/role.role.j2.yaml
@@ -12,8 +12,10 @@ parameters:
       The subnet CIDR of the control plane network. (The parameter is
       automatically resolved from the ctlplane subnet's cidr attribute.)
     type: string
-  ControlPlaneDefaultRoute: # Override this via parameter_defaults
-    description: The default route of the control plane network.
+  ControlPlaneDefaultRoute:
+    default: ''
+    description: The default route of the control plane network. (The parameter
+      is automatically resolved from the ctlplane subnet's gateway_ip attribute.)
     type: string
 {%- for network in networks %}
   {{network.name}}IpSubnet:
diff --git a/network/config/multiple-nics/compute-dvr.j2.yaml b/network/config/multiple-nics/compute-dvr.j2.yaml
index 519f4b9937..e631862454 100644
--- a/network/config/multiple-nics/compute-dvr.j2.yaml
+++ b/network/config/multiple-nics/compute-dvr.j2.yaml
@@ -14,8 +14,10 @@ parameters:
       The subnet CIDR of the control plane network. (The parameter is
       automatically resolved from the ctlplane subnet's cidr attribute.)
     type: string
-  ControlPlaneDefaultRoute: # Override this via parameter_defaults
-    description: The default route of the control plane network.
+  ControlPlaneDefaultRoute:
+    default: ''
+    description: The default route of the control plane network. (The parameter
+      is automatically resolved from the ctlplane subnet's gateway_ip attribute.)
     type: string
 {%- for network in networks %}
   {{network.name}}IpSubnet:
diff --git a/network/config/multiple-nics/controller-v6.j2.yaml b/network/config/multiple-nics/controller-v6.j2.yaml
index 4441c4afaf..fde66f50c0 100644
--- a/network/config/multiple-nics/controller-v6.j2.yaml
+++ b/network/config/multiple-nics/controller-v6.j2.yaml
@@ -13,8 +13,10 @@ parameters:
       The subnet CIDR of the control plane network. (The parameter is
       automatically resolved from the ctlplane subnet's cidr attribute.)
     type: string
-  ControlPlaneDefaultRoute: # Override this via parameter_defaults
-    description: The default route of the control plane network.
+  ControlPlaneDefaultRoute:
+    default: ''
+    description: The default route of the control plane network. (The parameter
+      is automatically resolved from the ctlplane subnet's gateway_ip attribute.)
     type: string
 {%- for network in networks %}
   {{network.name}}IpSubnet:
diff --git a/network/config/multiple-nics/role.role.j2.yaml b/network/config/multiple-nics/role.role.j2.yaml
index 3b3452178c..e9686564b0 100644
--- a/network/config/multiple-nics/role.role.j2.yaml
+++ b/network/config/multiple-nics/role.role.j2.yaml
@@ -12,8 +12,10 @@ parameters:
       The subnet CIDR of the control plane network. (The parameter is
       automatically resolved from the ctlplane subnet's cidr attribute.)
     type: string
-  ControlPlaneDefaultRoute: # Override this via parameter_defaults
-    description: The default route of the control plane network.
+  ControlPlaneDefaultRoute:
+    default: ''
+    description: The default route of the control plane network. (The parameter
+      is automatically resolved from the ctlplane subnet's gateway_ip attribute.)
     type: string
 {%- for network in networks %}
   {{network.name}}IpSubnet:
diff --git a/network/config/single-nic-linux-bridge-vlans/controller-v6.j2.yaml b/network/config/single-nic-linux-bridge-vlans/controller-v6.j2.yaml
index 9aea70c4c9..d5a398f42f 100644
--- a/network/config/single-nic-linux-bridge-vlans/controller-v6.j2.yaml
+++ b/network/config/single-nic-linux-bridge-vlans/controller-v6.j2.yaml
@@ -13,8 +13,10 @@ parameters:
       The subnet CIDR of the control plane network. (The parameter is
       automatically resolved from the ctlplane subnet's cidr attribute.)
     type: string
-  ControlPlaneDefaultRoute: # Override this via parameter_defaults
-    description: The default route of the control plane network.
+  ControlPlaneDefaultRoute:
+    default: ''
+    description: The default route of the control plane network. (The parameter
+      is automatically resolved from the ctlplane subnet's gateway_ip attribute.)
     type: string
 {%- for network in networks %}
   {{network.name}}IpSubnet:
diff --git a/network/config/single-nic-linux-bridge-vlans/role.role.j2.yaml b/network/config/single-nic-linux-bridge-vlans/role.role.j2.yaml
index 30c9eed79a..e2a1b02fc4 100644
--- a/network/config/single-nic-linux-bridge-vlans/role.role.j2.yaml
+++ b/network/config/single-nic-linux-bridge-vlans/role.role.j2.yaml
@@ -12,8 +12,10 @@ parameters:
       The subnet CIDR of the control plane network. (The parameter is
       automatically resolved from the ctlplane subnet's cidr attribute.)
     type: string
-  ControlPlaneDefaultRoute: # Override this via parameter_defaults
-    description: The default route of the control plane network.
+  ControlPlaneDefaultRoute:
+    default: ''
+    description: The default route of the control plane network. (The parameter
+      is automatically resolved from the ctlplane subnet's gateway_ip attribute.)
     type: string
 {%- for network in networks %}
   {{network.name}}IpSubnet:
diff --git a/network/config/single-nic-vlans/controller-no-external.j2.yaml b/network/config/single-nic-vlans/controller-no-external.j2.yaml
index 6ebb96f66e..e6ab1efb55 100644
--- a/network/config/single-nic-vlans/controller-no-external.j2.yaml
+++ b/network/config/single-nic-vlans/controller-no-external.j2.yaml
@@ -16,8 +16,10 @@ parameters:
       The subnet CIDR of the control plane network. (The parameter is
       automatically resolved from the ctlplane subnet's cidr attribute.)
     type: string
-  ControlPlaneDefaultRoute: # Override this via parameter_defaults
-    description: The default route of the control plane network.
+  ControlPlaneDefaultRoute:
+    default: ''
+    description: The default route of the control plane network. (The parameter
+      is automatically resolved from the ctlplane subnet's gateway_ip attribute.)
     type: string
 {%- for network in networks %}
   {{network.name}}IpSubnet:
diff --git a/network/config/single-nic-vlans/controller-v6.j2.yaml b/network/config/single-nic-vlans/controller-v6.j2.yaml
index 9dff4ad7b1..4fc3c2fc1d 100644
--- a/network/config/single-nic-vlans/controller-v6.j2.yaml
+++ b/network/config/single-nic-vlans/controller-v6.j2.yaml
@@ -13,8 +13,10 @@ parameters:
       The subnet CIDR of the control plane network. (The parameter is
       automatically resolved from the ctlplane subnet's cidr attribute.)
     type: string
-  ControlPlaneDefaultRoute: # Override this via parameter_defaults
-    description: The default route of the control plane network.
+  ControlPlaneDefaultRoute:
+    default: ''
+    description: The default route of the control plane network. (The parameter
+      is automatically resolved from the ctlplane subnet's gateway_ip attribute.)
     type: string
 {%- for network in networks %}
   {{network.name}}IpSubnet:
diff --git a/network/config/single-nic-vlans/role.role.j2.yaml b/network/config/single-nic-vlans/role.role.j2.yaml
index 368fa2b259..fd2ea24176 100644
--- a/network/config/single-nic-vlans/role.role.j2.yaml
+++ b/network/config/single-nic-vlans/role.role.j2.yaml
@@ -12,8 +12,10 @@ parameters:
       The subnet CIDR of the control plane network. (The parameter is
       automatically resolved from the ctlplane subnet's cidr attribute.)
     type: string
-  ControlPlaneDefaultRoute: # Override this via parameter_defaults
-    description: The default route of the control plane network.
+  ControlPlaneDefaultRoute:
+    default: ''
+    description: The default route of the control plane network. (The parameter
+      is automatically resolved from the ctlplane subnet's gateway_ip attribute.)
     type: string
 {%- for network in networks %}
   {{network.name}}IpSubnet:
diff --git a/puppet/role.role.j2.yaml b/puppet/role.role.j2.yaml
index 84c8d9f06f..661bbbe6b8 100644
--- a/puppet/role.role.j2.yaml
+++ b/puppet/role.role.j2.yaml
@@ -250,6 +250,11 @@ parameters:
       The subnet CIDR of the control plane network. (The parameter is
       automatically resolved from the ctlplane subnet's cidr attribute.)
     type: string
+  ControlPlaneDefaultRoute:
+    default: ''
+    description: The default route of the control plane network. (The parameter
+      is automatically resolved from the ctlplane subnet's gateway_ip attribute.)
+    type: string
 
   ServerDeletionPolicy:
     description: Whether to retain or delete servers on deletion of the stack
@@ -324,6 +329,9 @@ conditions:
   ctlplane_subnet_cidr_set:
     not:
       equals: [{get_param: ControlPlaneSubnetCidr}, '']
+  ctlplane_default_route_set:
+    not:
+      equals: [{get_param: ControlPlaneDefaultRoute}, '']
 
 resources:
   {{server_resource_name}}:
@@ -449,6 +457,11 @@ resources:
           - ctlplane_subnet_cidr_set
           - {get_param: ControlPlaneSubnetCidr}
           - {str_split: ['/', {get_attr: [{{server_resource_name}}, addresses, ctlplane, 0, subnets, 0, cidr]}, 1]}
+      ControlPlaneDefaultRoute:
+        if:
+          - ctlplane_default_route_set
+          - {get_param: ControlPlaneDefaultRoute}
+          - {get_attr: [{{server_resource_name}}, addresses, ctlplane, 0, subnets, 0, gateway_ip]}
   {%- for network in networks %}
       {{network.name}}IpSubnet: {get_attr: [{{network.name}}Port, ip_subnet]}
   {%- endfor %}
diff --git a/releasenotes/notes/use-subnet-attrs-ctlplane-default-route-625ef5e414a65f2e.yaml b/releasenotes/notes/use-subnet-attrs-ctlplane-default-route-625ef5e414a65f2e.yaml
new file mode 100644
index 0000000000..8fcada3f03
--- /dev/null
+++ b/releasenotes/notes/use-subnet-attrs-ctlplane-default-route-625ef5e414a65f2e.yaml
@@ -0,0 +1,25 @@
+---
+features:
+  - |
+    It is no longer a requirement to provide the parameter:
+    ``ControlPlaneDefaultRoute``  in the environment when deploying. Now
+    ``get_attr`` on the server resource is used to resolve the value from the
+    ``ctlplane`` subnet's ``gateway_ip`` attribute. A conditional is used to
+    determine if the user provided the parameter in the environment. If the
+    user provided the parameter, the user provided value is used.
+upgrade:
+  - |
+    Since the the ``ControlPlaneDefaultRoute`` can now be resolved from the
+    ``ctlplane`` subnet(s) this parameter can be removed from the environment
+    (``network-environment.yaml``).
+
+    .. Note:: Prior to removing the parameter ensure that the property of
+              the ``ctlplane`` subnet(s) is correct. In case it is not, update
+              ``undercloud.conf`` with the correct configuration and re-run the
+              ``openstack undercloud install`` command to ensure the property
+              is set correctly.
+
+    .. Note:: ``ControlPlaneDefaultRoute`` is now passed to the network config
+              template when the resource is created. Because of this the
+              parameter must be defined in the network config template, even if
+              it is not used.