From b2d3c05f4e6926413a657fd5579f39bf5e1cb4be Mon Sep 17 00:00:00 2001 From: Rabi Mishra Date: Thu, 24 Sep 2020 09:14:56 +0530 Subject: [PATCH] Replace bridge_name and interface_name in config The new ansible os_net_config does not replace the interface_name and bridge_name variables in net config. This replaces those variables beforehand. Though it would have been good to handle it in module itself, in the proposed way to generate these configs with ansible would allow us to replace them with group_vars. Change-Id: I2049d3ce2ad10507fd846d3876e20cc3ec4b9fbe Closes-Bug: #1896829 --- net-config-bond.j2.yaml | 7 ++++++- net-config-bridge.j2.yaml | 13 +++++++++++-- net-config-linux-bridge.j2.yaml | 13 ++++++++++--- ...config-static-bridge-with-external-dhcp.j2.yaml | 12 ++++++++++-- net-config-static-bridge.j2.yaml | 12 ++++++++++-- net-config-static.j2.yaml | 7 +++++-- .../config/2-linux-bonds-vlans/role.role.j2.yaml | 7 +++++-- .../bond-with-vlans/controller-no-external.j2.yaml | 7 ++++++- network/config/bond-with-vlans/role.role.j2.yaml | 7 ++++++- .../config/multiple-nics-vlans/compute-dvr.j2.yaml | 6 +++++- .../config/multiple-nics-vlans/role.role.j2.yaml | 7 ++++++- network/config/multiple-nics/compute-dvr.j2.yaml | 6 +++++- network/config/multiple-nics/role.role.j2.yaml | 7 ++++++- .../role.role.j2.yaml | 14 +++++++++++--- .../controller-no-external.j2.yaml | 6 +++++- network/config/single-nic-vlans/role.role.j2.yaml | 6 +++++- 16 files changed, 112 insertions(+), 25 deletions(-) diff --git a/net-config-bond.j2.yaml b/net-config-bond.j2.yaml index 1789c25efd..3bfa060274 100644 --- a/net-config-bond.j2.yaml +++ b/net-config-bond.j2.yaml @@ -72,6 +72,11 @@ parameters: description: Vlan ID for the {{network.name_lower}} network traffic. type: number {%- endfor %} + NeutronPhysicalBridge: + default: 'br-ex' + description: An OVS bridge to create for accessing external networks. + type: string + resources: OsNetConfigImpl: type: OS::Heat::Value @@ -79,7 +84,7 @@ resources: value: network_config: - type: ovs_bridge - name: bridge_name + name: {get_param: NeutronPhysicalBridge} use_dhcp: true dns_servers: get_param: DnsServers diff --git a/net-config-bridge.j2.yaml b/net-config-bridge.j2.yaml index db898e7d57..71cef47a6f 100644 --- a/net-config-bridge.j2.yaml +++ b/net-config-bridge.j2.yaml @@ -70,6 +70,15 @@ parameters: description: Vlan ID for the {{network.name_lower}} network traffic. type: number {%- endfor %} + NeutronPublicInterface: + default: nic1 + description: Which interface to add to the NeutronPhysicalBridge. + type: string + NeutronPhysicalBridge: + default: 'br-ex' + description: An OVS bridge to create for accessing external networks. + type: string + resources: OsNetConfigImpl: type: OS::Heat::Value @@ -77,7 +86,7 @@ resources: value: network_config: - type: ovs_bridge - name: bridge_name + name: {get_param: NeutronPhysicalBridge} use_dhcp: true dns_servers: get_param: DnsServers @@ -85,7 +94,7 @@ resources: get_param: DnsSearchDomains members: - type: interface - name: interface_name + name: {get_param: NeutronPublicInterface} # force the MAC address of the bridge to this interface primary: true outputs: diff --git a/net-config-linux-bridge.j2.yaml b/net-config-linux-bridge.j2.yaml index 2f1fc4c02e..81db547f71 100644 --- a/net-config-linux-bridge.j2.yaml +++ b/net-config-linux-bridge.j2.yaml @@ -70,7 +70,14 @@ parameters: default: [] description: A list of DNS search domains to be added (in order) to resolv.conf. type: comma_delimited_list - + NeutronPublicInterface: + default: nic1 + description: Which interface to add to the NeutronPhysicalBridge. + type: string + NeutronPhysicalBridge: + default: 'br-ex' + description: An OVS bridge to create for accessing external networks. + type: string resources: OsNetConfigImpl: @@ -79,7 +86,7 @@ resources: value: network_config: - type: linux_bridge - name: bridge_name + name: {get_param: NeutronPhysicalBridge} addresses: - ip_netmask: get_param: ControlPlaneIp @@ -89,7 +96,7 @@ resources: get_param: DnsSearchDomains members: - type: interface - name: interface_name + name: {get_param: NeutronPublicInterface} # force the MAC address of the bridge to this interface primary: true routes: diff --git a/net-config-static-bridge-with-external-dhcp.j2.yaml b/net-config-static-bridge-with-external-dhcp.j2.yaml index f066574ea3..67ac472f86 100644 --- a/net-config-static-bridge-with-external-dhcp.j2.yaml +++ b/net-config-static-bridge-with-external-dhcp.j2.yaml @@ -71,6 +71,14 @@ parameters: default: [] description: A list of DNS search domains to be added (in order) to resolv.conf. type: comma_delimited_list + NeutronPublicInterface: + default: nic1 + description: Which interface to add to the NeutronPhysicalBridge. + type: string + NeutronPhysicalBridge: + default: 'br-ex' + description: An OVS bridge to create for accessing external networks. + type: string resources: OsNetConfigImpl: @@ -79,7 +87,7 @@ resources: value: network_config: - type: ovs_bridge - name: bridge_name + name: {get_param: NeutronPhysicalBridge} use_dhcp: true dns_servers: get_param: DnsServers @@ -87,7 +95,7 @@ resources: get_param: DnsSearchDomains members: - type: interface - name: interface_name + name: {get_param: NeutronPublicInterface} # force the MAC address of the bridge to this interface primary: true - type: interface diff --git a/net-config-static-bridge.j2.yaml b/net-config-static-bridge.j2.yaml index a119d0cadb..efa758da14 100644 --- a/net-config-static-bridge.j2.yaml +++ b/net-config-static-bridge.j2.yaml @@ -71,6 +71,14 @@ parameters: default: [] description: A list of DNS search domains to be added (in order) to resolv.conf. type: comma_delimited_list + NeutronPublicInterface: + default: nic1 + description: Which interface to add to the NeutronPhysicalBridge. + type: string + NeutronPhysicalBridge: + default: 'br-ex' + description: An OVS bridge to create for accessing external networks. + type: string resources: OsNetConfigImpl: @@ -79,7 +87,7 @@ resources: value: network_config: - type: ovs_bridge - name: bridge_name + name: {get_param: NeutronPhysicalBridge} use_dhcp: false dns_servers: get_param: DnsServers @@ -97,7 +105,7 @@ resources: get_param: ControlPlaneDefaultRoute members: - type: interface - name: interface_name + name: {get_param: NeutronPublicInterface} # force the MAC address of the bridge to this interface primary: true outputs: diff --git a/net-config-static.j2.yaml b/net-config-static.j2.yaml index 5c683ef5db..bba5bd3273 100644 --- a/net-config-static.j2.yaml +++ b/net-config-static.j2.yaml @@ -70,6 +70,10 @@ parameters: default: [] description: A list of DNS search domains to be added (in order) to resolv.conf. type: comma_delimited_list + NeutronPublicInterface: + default: nic1 + description: Which interface to add to the NeutronPhysicalBridge. + type: string resources: OsNetConfigImpl: @@ -78,7 +82,7 @@ resources: value: network_config: - type: interface - name: interface_name + name: {get_param: NeutronPublicInterface} use_dhcp: false dns_servers: get_param: DnsServers @@ -99,4 +103,3 @@ outputs: description: The OsNetConfigImpl resource. get_attr: get_attr: [OsNetConfigImpl, value] - diff --git a/network/config/2-linux-bonds-vlans/role.role.j2.yaml b/network/config/2-linux-bonds-vlans/role.role.j2.yaml index e57d5b5a2f..bd32ad3b33 100644 --- a/network/config/2-linux-bonds-vlans/role.role.j2.yaml +++ b/network/config/2-linux-bonds-vlans/role.role.j2.yaml @@ -98,7 +98,10 @@ parameters: default: 1 type: number {%- endif %} - + NeutronPhysicalBridge: + default: 'br-ex' + description: An OVS bridge to create for accessing external networks. + type: string resources: @@ -202,7 +205,7 @@ resources: {%- endfor %} {%- if not role.name.startswith('ComputeOvsDpdk') %} - type: ovs_bridge - name: bridge_name + name: {get_param: NeutronPhysicalBridge} dns_servers: get_param: DnsServers members: 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 8a0a7b3b72..813eb61b5f 100644 --- a/network/config/bond-with-vlans/controller-no-external.j2.yaml +++ b/network/config/bond-with-vlans/controller-no-external.j2.yaml @@ -80,6 +80,11 @@ parameters: interface. Set things like lacp=active and/or bond_mode=balance-slb for OVS bonds or like mode=4 for Linux bonds using this option.' type: string + NeutronPhysicalBridge: + default: 'br-ex' + description: An OVS bridge to create for accessing external networks. + type: string + resources: OsNetConfigImpl: type: OS::Heat::Value @@ -106,7 +111,7 @@ resources: next_hop: get_param: ControlPlaneDefaultRoute - type: ovs_bridge - name: bridge_name + name: {get_param: NeutronPhysicalBridge} use_dhcp: true members: - type: ovs_bond diff --git a/network/config/bond-with-vlans/role.role.j2.yaml b/network/config/bond-with-vlans/role.role.j2.yaml index ac3660c44b..06657b4386 100644 --- a/network/config/bond-with-vlans/role.role.j2.yaml +++ b/network/config/bond-with-vlans/role.role.j2.yaml @@ -95,6 +95,11 @@ parameters: default: 1 type: number {%- endif %} + NeutronPhysicalBridge: + default: 'br-ex' + description: An OVS bridge to create for accessing external networks. + type: string + resources: MinViableMtu: @@ -143,7 +148,7 @@ resources: {%- if role.name.startswith('CephStorage') or role.name.startswith('ObjectStorage') or role.name.startswith('BlockStorage') %} name: br-bond {%- else %} - name: bridge_name + name: {get_param: NeutronPhysicalBridge} {%- endif %} dns_servers: get_param: DnsServers diff --git a/network/config/multiple-nics-vlans/compute-dvr.j2.yaml b/network/config/multiple-nics-vlans/compute-dvr.j2.yaml index c6a6c26be8..44f0e2e253 100644 --- a/network/config/multiple-nics-vlans/compute-dvr.j2.yaml +++ b/network/config/multiple-nics-vlans/compute-dvr.j2.yaml @@ -76,6 +76,10 @@ parameters: default: [] description: A list of DNS search domains to be added (in order) to resolv.conf. type: comma_delimited_list + NeutronPhysicalBridge: + default: 'br-ex' + description: An OVS bridge to create for accessing external networks. + type: string resources: OsNetConfigImpl: @@ -155,7 +159,7 @@ resources: primary: true # External bridge for DVR (no IP address required) - type: ovs_bridge - name: bridge_name + name: {get_param: NeutronPhysicalBridge} mtu: get_param: ExternalMtu dns_servers: diff --git a/network/config/multiple-nics-vlans/role.role.j2.yaml b/network/config/multiple-nics-vlans/role.role.j2.yaml index 44ebc6395c..3e33d0e9da 100644 --- a/network/config/multiple-nics-vlans/role.role.j2.yaml +++ b/network/config/multiple-nics-vlans/role.role.j2.yaml @@ -99,6 +99,11 @@ parameters: default: 1 type: number {%- endif %} + NeutronPhysicalBridge: + default: 'br-ex' + description: An OVS bridge to create for accessing external networks. + type: string + resources: OsNetConfigImpl: type: OS::Heat::Value @@ -159,7 +164,7 @@ resources: {%- elif network.name in role.networks or 'external_bridge' in role.tags %} - type: ovs_bridge {%- if network.name == "External" %} - name: bridge_name + name: {get_param: NeutronPhysicalBridge} {%- else %} name: br-{{network.name_lower}} {%- endif %} diff --git a/network/config/multiple-nics/compute-dvr.j2.yaml b/network/config/multiple-nics/compute-dvr.j2.yaml index 735e4e2d0b..5b04229531 100644 --- a/network/config/multiple-nics/compute-dvr.j2.yaml +++ b/network/config/multiple-nics/compute-dvr.j2.yaml @@ -76,6 +76,10 @@ parameters: default: [] description: A list of DNS search domains to be added (in order) to resolv.conf. type: comma_delimited_list + NeutronPhysicalBridge: + default: 'br-ex' + description: An OVS bridge to create for accessing external networks. + type: string resources: OsNetConfigImpl: @@ -143,7 +147,7 @@ resources: primary: true # External bridge for DVR (no IP address required) - type: ovs_bridge - name: bridge_name + name: {get_param: NeutronPhysicalBridge} mtu: get_param: ExternalMtu dns_servers: diff --git a/network/config/multiple-nics/role.role.j2.yaml b/network/config/multiple-nics/role.role.j2.yaml index 9f9e6afda0..5b012a456f 100644 --- a/network/config/multiple-nics/role.role.j2.yaml +++ b/network/config/multiple-nics/role.role.j2.yaml @@ -99,6 +99,11 @@ parameters: default: 1 type: number {%- endif %} + NeutronPhysicalBridge: + default: 'br-ex' + description: An OVS bridge to create for accessing external networks. + type: string + resources: OsNetConfigImpl: type: OS::Heat::Value @@ -153,7 +158,7 @@ resources: {%- elif network.name in _role_networks or 'external_bridge' in role.tags %} - type: ovs_bridge {%- if network.name == "External" %} - name: bridge_name + name: {get_param: NeutronPhysicalBridge} {%- else %} name: br-{{network.name_lower}} {%- endif %} 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 b1673cd1e9..f46d9f7f42 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 @@ -83,6 +83,14 @@ parameters: default: [] description: A list of DNS search domains to be added (in order) to resolv.conf. type: comma_delimited_list + NeutronPublicInterface: + default: nic1 + description: Which interface to add to the NeutronPhysicalBridge. + type: string + NeutronPhysicalBridge: + default: 'br-ex' + description: An OVS bridge to create for accessing external networks. + type: string resources: @@ -112,7 +120,7 @@ resources: {%- if role.name.startswith('CephStorage') or role.name.startswith('ObjectStorage') or role.name.startswith('BlockStorage') %} name: br-storage {%- else %} - name: bridge_name + name: {get_param: NeutronPhysicalBridge} {%- endif %} mtu: get_attr: [MinViableMtu, value] @@ -137,7 +145,7 @@ resources: {%- endif %} members: - type: interface - name: interface_name + name: {get_param: NeutronPublicInterface} mtu: get_attr: [MinViableMtu, value] primary: true @@ -151,7 +159,7 @@ and network.name not in role.networks_skip_config|default([]) %} {%- if role.name.startswith('CephStorage') or role.name.startswith('ObjectStorage') or role.name.startswith('BlockStorage') %} device: br-storage {%- else %} - device: bridge_name + device: {get_param: NeutronPhysicalBridge} {%- endif %} addresses: - ip_netmask: 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 6005a96db1..5326111abc 100644 --- a/network/config/single-nic-vlans/controller-no-external.j2.yaml +++ b/network/config/single-nic-vlans/controller-no-external.j2.yaml @@ -74,6 +74,10 @@ parameters: default: [] description: A list of DNS search domains to be added (in order) to resolv.conf. type: comma_delimited_list + NeutronPhysicalBridge: + default: 'br-ex' + description: An OVS bridge to create for accessing external networks. + type: string resources: OsNetConfigImpl: @@ -82,7 +86,7 @@ resources: value: network_config: - type: ovs_bridge - name: bridge_name + name: {get_param: NeutronPhysicalBridge} use_dhcp: false dns_servers: get_param: DnsServers diff --git a/network/config/single-nic-vlans/role.role.j2.yaml b/network/config/single-nic-vlans/role.role.j2.yaml index f7fbcc9f84..0cf30685a7 100644 --- a/network/config/single-nic-vlans/role.role.j2.yaml +++ b/network/config/single-nic-vlans/role.role.j2.yaml @@ -83,6 +83,10 @@ parameters: default: [] description: A list of DNS search domains to be added (in order) to resolv.conf. type: comma_delimited_list + NeutronPhysicalBridge: + default: 'br-ex' + description: An OVS bridge to create for accessing external networks. + type: string resources: @@ -112,7 +116,7 @@ resources: {%- if role.name.startswith('CephStorage') or role.name.startswith('ObjectStorage') or role.name.startswith('BlockStorage') %} name: br-storage {%- else %} - name: bridge_name + name: {get_param: NeutronPhysicalBridge} {%- endif %} mtu: get_attr: [MinViableMtu, value]