From 5abce594c31c0a7cd348034c4699a14995ded0f1 Mon Sep 17 00:00:00 2001 From: Brendan Shephard Date: Thu, 7 Sep 2023 14:07:31 +1000 Subject: [PATCH] Remove NetworkConfig override handling This change removes the CRD level override for network config files. Instead, this allows us to use the Ansible variable directly to set any require network config customizations. Depends-On: https://github.com/openstack-k8s-operators/edpm-ansible/pull/243 Signed-off-by: Brendan Shephard --- ...nstack.org_openstackdataplanenodesets.yaml | 10 ----- api/v1beta1/common.go | 38 ++++++++++-------- api/v1beta1/zz_generated.deepcopy.go | 17 -------- ...nstack.org_openstackdataplanenodesets.yaml | 10 ----- ...ane_v1beta1_openstackdataplanenodeset.yaml | 34 +++++++++++++++- ...1_openstackdataplanenodeset_baremetal.yaml | 33 ++++++++++++++- ...kdataplanenodeset_baremetal_with_ipam.yaml | 33 ++++++++++++++- ...1beta1_openstackdataplanenodeset_ceph.yaml | 36 ++++++++++++++++- ...nstackdataplanenodeset_customnetworks.yaml | 33 ++++++++++++++- ...1_openstackdataplanenodeset_with_ipam.yaml | 32 +++++++++++++++ docs/openstack_dataplanenodeset.md | 13 ------ docs/openstack_dataplaneservice.md | 13 ------ pkg/deployment/inventory.go | 20 ---------- pkg/util/ansible_execution.go | 10 ----- .../01-assert.yaml | 40 ------------------- .../dataplane-service-config/00-assert.yaml | 5 --- 16 files changed, 216 insertions(+), 161 deletions(-) diff --git a/api/bases/dataplane.openstack.org_openstackdataplanenodesets.yaml b/api/bases/dataplane.openstack.org_openstackdataplanenodesets.yaml index ef7179fae..f8e390e91 100644 --- a/api/bases/dataplane.openstack.org_openstackdataplanenodesets.yaml +++ b/api/bases/dataplane.openstack.org_openstackdataplanenodesets.yaml @@ -1039,11 +1039,6 @@ spec: items: type: string type: array - networkConfig: - properties: - template: - type: string - type: object networkData: properties: name: @@ -1833,11 +1828,6 @@ spec: type: string managementNetwork: type: string - networkConfig: - properties: - template: - type: string - type: object networkData: properties: name: diff --git a/api/v1beta1/common.go b/api/v1beta1/common.go index c2a810066..df583c12b 100644 --- a/api/v1beta1/common.go +++ b/api/v1beta1/common.go @@ -18,6 +18,7 @@ package v1beta1 import ( "encoding/json" + "reflect" infranetworkv1 "github.com/openstack-k8s-operators/infra-operator/apis/network/v1beta1" "github.com/openstack-k8s-operators/lib-common/modules/storage" @@ -52,11 +53,6 @@ type NodeSection struct { // +kubebuilder:validation:Optional HostName string `json:"hostName,omitempty"` - // NetworkConfig - Network configuration details. Contains os-net-config - // related properties. - // +kubebuilder:validation:Optional - NetworkConfig NetworkConfigSection `json:"networkConfig"` - // Networks - Instance networks // +kubebuilder:validation:Optional Networks []infranetworkv1.IPSetNetwork `json:"networks,omitempty"` @@ -103,11 +99,6 @@ type NodeTemplate struct { // +kubebuilder:validation:Optional NetworkAttachments []string `json:"networkAttachments,omitempty"` - // NetworkConfig - Network configuration details. Contains os-net-config - // related properties. - // +kubebuilder:validation:Optional - NetworkConfig NetworkConfigSection `json:"networkConfig,omitempty"` - // Networks - Instance networks // +kubebuilder:validation:Optional Networks []infranetworkv1.IPSetNetwork `json:"networks,omitempty"` @@ -153,13 +144,26 @@ type DeployStrategySection struct { AnsibleSkipTags string `json:"ansibleSkipTags,omitempty"` } -// NetworkConfigSection is a specification of the Network configuration details -type NetworkConfigSection struct { - - // Template - Contains a Ansible j2 nic config template to use when applying node - // network configuration - // +kubebuilder:validation:Optional - Template string `json:"template,omitempty" yaml:"template,omitempty"` +// UniqueSpecFields - the array of fields that must be unique between role and nodes +var UniqueSpecFields = []string{"NetworkAttachments"} + +// AssertUniquenessBetween - compare specs for uniqueness +func AssertUniquenessBetween(spec interface{}, otherSpec interface{}, suffix string) []string { + vSpec := reflect.ValueOf(spec) + vOtherSpec := reflect.ValueOf(otherSpec) + + var errorMsgs []string + for _, field := range UniqueSpecFields { + value := vSpec.FieldByName(field) + otherValue := vOtherSpec.FieldByName(field) + if value.IsZero() || otherValue.IsZero() { + continue + } + if !reflect.DeepEqual(value.Interface(), otherValue.Interface()) { + errorMsgs = append(errorMsgs, field+" mismatch between "+suffix) + } + } + return errorMsgs } // AnsibleEESpec is a specification of the ansible EE attributes diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go index 704027de1..eb22d0736 100644 --- a/api/v1beta1/zz_generated.deepcopy.go +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -129,25 +129,9 @@ func (in *KubeService) DeepCopy() *KubeService { return out } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *NetworkConfigSection) DeepCopyInto(out *NetworkConfigSection) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NetworkConfigSection. -func (in *NetworkConfigSection) DeepCopy() *NetworkConfigSection { - if in == nil { - return nil - } - out := new(NetworkConfigSection) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *NodeSection) DeepCopyInto(out *NodeSection) { *out = *in - out.NetworkConfig = in.NetworkConfig if in.Networks != nil { in, out := &in.Networks, &out.Networks *out = make([]networkv1beta1.IPSetNetwork, len(*in)) @@ -200,7 +184,6 @@ func (in *NodeTemplate) DeepCopyInto(out *NodeTemplate) { *out = make([]string, len(*in)) copy(*out, *in) } - out.NetworkConfig = in.NetworkConfig if in.Networks != nil { in, out := &in.Networks, &out.Networks *out = make([]networkv1beta1.IPSetNetwork, len(*in)) diff --git a/config/crd/bases/dataplane.openstack.org_openstackdataplanenodesets.yaml b/config/crd/bases/dataplane.openstack.org_openstackdataplanenodesets.yaml index ef7179fae..f8e390e91 100644 --- a/config/crd/bases/dataplane.openstack.org_openstackdataplanenodesets.yaml +++ b/config/crd/bases/dataplane.openstack.org_openstackdataplanenodesets.yaml @@ -1039,11 +1039,6 @@ spec: items: type: string type: array - networkConfig: - properties: - template: - type: string - type: object networkData: properties: name: @@ -1833,11 +1828,6 @@ spec: type: string managementNetwork: type: string - networkConfig: - properties: - template: - type: string - type: object networkData: properties: name: diff --git a/config/samples/dataplane_v1beta1_openstackdataplanenodeset.yaml b/config/samples/dataplane_v1beta1_openstackdataplanenodeset.yaml index 77bef53c2..13f62823d 100644 --- a/config/samples/dataplane_v1beta1_openstackdataplanenodeset.yaml +++ b/config/samples/dataplane_v1beta1_openstackdataplanenodeset.yaml @@ -48,7 +48,39 @@ spec: # Default nic config template for a EDPM compute node # These vars are edpm_network_config role vars edpm_network_config_hide_sensitive_logs: false - edpm_network_config_template: templates/single_nic_vlans/single_nic_vlans.j2 + edpm_network_config_template: | + --- + {% set mtu_list = [ctlplane_mtu] %} + {% for network in role_networks %} + {{ mtu_list.append(lookup('vars', networks_lower[network] ~ '_mtu')) }} + {%- endfor %} + {% set min_viable_mtu = mtu_list | max %} + network_config: + - type: ovs_bridge + name: {{ neutron_physical_bridge_name }} + mtu: {{ min_viable_mtu }} + use_dhcp: false + dns_servers: {{ ctlplane_dns_nameservers }} + domain: {{ dns_search_domains }} + addresses: + - ip_netmask: {{ ctlplane_ip }}/{{ ctlplane_subnet_cidr }} + routes: {{ ctlplane_host_routes }} + members: + - type: interface + name: nic1 + mtu: {{ min_viable_mtu }} + # force the MAC address of the bridge to this interface + primary: true + {% for network in role_networks %} + - type: vlan + mtu: {{ lookup('vars', networks_lower[network] ~ '_mtu') }} + vlan_id: {{ lookup('vars', networks_lower[network] ~ '_vlan_id') }} + addresses: + - ip_netmask: + {{ lookup('vars', networks_lower[network] ~ '_ip') }}/{{ lookup('vars', networks_lower[network] ~ '_cidr') }} + routes: {{ lookup('vars', networks_lower[network] ~ '_host_routes') }} + {% endfor %} + # These vars are for the network config templates themselves and are # considered EDPM network defaults. neutron_physical_bridge_name: br-ex diff --git a/config/samples/dataplane_v1beta1_openstackdataplanenodeset_baremetal.yaml b/config/samples/dataplane_v1beta1_openstackdataplanenodeset_baremetal.yaml index 24b780ca9..9fc281e47 100644 --- a/config/samples/dataplane_v1beta1_openstackdataplanenodeset_baremetal.yaml +++ b/config/samples/dataplane_v1beta1_openstackdataplanenodeset_baremetal.yaml @@ -67,7 +67,38 @@ spec: # edpm_network_config # Default nic config template for a EDPM compute node # These vars are edpm_network_config role vars - edpm_network_config_template: templates/single_nic_vlans/single_nic_vlans.j2 + edpm_network_config_template: | + --- + {% set mtu_list = [ctlplane_mtu] %} + {% for network in role_networks %} + {{ mtu_list.append(lookup('vars', networks_lower[network] ~ '_mtu')) }} + {%- endfor %} + {% set min_viable_mtu = mtu_list | max %} + network_config: + - type: ovs_bridge + name: {{ neutron_physical_bridge_name }} + mtu: {{ min_viable_mtu }} + use_dhcp: false + dns_servers: {{ ctlplane_dns_nameservers }} + domain: {{ dns_search_domains }} + addresses: + - ip_netmask: {{ ctlplane_ip }}/{{ ctlplane_subnet_cidr }} + routes: {{ ctlplane_host_routes }} + members: + - type: interface + name: nic1 + mtu: {{ min_viable_mtu }} + # force the MAC address of the bridge to this interface + primary: true + {% for network in role_networks %} + - type: vlan + mtu: {{ lookup('vars', networks_lower[network] ~ '_mtu') }} + vlan_id: {{ lookup('vars', networks_lower[network] ~ '_vlan_id') }} + addresses: + - ip_netmask: + {{ lookup('vars', networks_lower[network] ~ '_ip') }}/{{ lookup('vars', networks_lower[network] ~ '_cidr') }} + routes: {{ lookup('vars', networks_lower[network] ~ '_host_routes') }} + {% endfor %} edpm_network_config_hide_sensitive_logs: false # These vars are for the network config templates themselves and are diff --git a/config/samples/dataplane_v1beta1_openstackdataplanenodeset_baremetal_with_ipam.yaml b/config/samples/dataplane_v1beta1_openstackdataplanenodeset_baremetal_with_ipam.yaml index 0c5de8e37..3fd6bf895 100644 --- a/config/samples/dataplane_v1beta1_openstackdataplanenodeset_baremetal_with_ipam.yaml +++ b/config/samples/dataplane_v1beta1_openstackdataplanenodeset_baremetal_with_ipam.yaml @@ -56,7 +56,38 @@ spec: # Default nic config template for a EDPM compute node # These vars are edpm_network_config role vars edpm_network_config_hide_sensitive_logs: false - edpm_network_config_template: templates/single_nic_vlans/single_nic_vlans.j2 + edpm_network_config_template: | + --- + {% set mtu_list = [ctlplane_mtu] %} + {% for network in role_networks %} + {{ mtu_list.append(lookup('vars', networks_lower[network] ~ '_mtu')) }} + {%- endfor %} + {% set min_viable_mtu = mtu_list | max %} + network_config: + - type: ovs_bridge + name: {{ neutron_physical_bridge_name }} + mtu: {{ min_viable_mtu }} + use_dhcp: false + dns_servers: {{ ctlplane_dns_nameservers }} + domain: {{ dns_search_domains }} + addresses: + - ip_netmask: {{ ctlplane_ip }}/{{ ctlplane_subnet_cidr }} + routes: {{ ctlplane_host_routes }} + members: + - type: interface + name: nic1 + mtu: {{ min_viable_mtu }} + # force the MAC address of the bridge to this interface + primary: true + {% for network in role_networks %} + - type: vlan + mtu: {{ lookup('vars', networks_lower[network] ~ '_mtu') }} + vlan_id: {{ lookup('vars', networks_lower[network] ~ '_vlan_id') }} + addresses: + - ip_netmask: + {{ lookup('vars', networks_lower[network] ~ '_ip') }}/{{ lookup('vars', networks_lower[network] ~ '_cidr') }} + routes: {{ lookup('vars', networks_lower[network] ~ '_host_routes') }} + {% endfor %} # These vars are for the network config templates themselves and are # considered EDPM network defaults. neutron_physical_bridge_name: br-ex diff --git a/config/samples/dataplane_v1beta1_openstackdataplanenodeset_ceph.yaml b/config/samples/dataplane_v1beta1_openstackdataplanenodeset_ceph.yaml index 040ad25a9..89df952e8 100644 --- a/config/samples/dataplane_v1beta1_openstackdataplanenodeset_ceph.yaml +++ b/config/samples/dataplane_v1beta1_openstackdataplanenodeset_ceph.yaml @@ -2,7 +2,7 @@ apiVersion: dataplane.openstack.org/v1beta1 kind: OpenStackDataPlaneNodeSet metadata: - name: openstack-edpm-ceph + name: openstack-edpm spec: env: - name: ANSIBLE_FORCE_COLOR @@ -67,7 +67,39 @@ spec: # edpm_network_config # Default nic config template for a EDPM compute node # These vars are edpm_network_config role vars - edpm_network_config_template: templates/single_nic_vlans/single_nic_vlans.j2 + edpm_network_config_template: | + --- + {% set mtu_list = [ctlplane_mtu] %} + {% for network in role_networks %} + {{ mtu_list.append(lookup('vars', networks_lower[network] ~ '_mtu')) }} + {%- endfor %} + {% set min_viable_mtu = mtu_list | max %} + network_config: + - type: ovs_bridge + name: {{ neutron_physical_bridge_name }} + mtu: {{ min_viable_mtu }} + use_dhcp: false + dns_servers: {{ ctlplane_dns_nameservers }} + domain: {{ dns_search_domains }} + addresses: + - ip_netmask: {{ ctlplane_ip }}/{{ ctlplane_subnet_cidr }} + routes: {{ ctlplane_host_routes }} + members: + - type: interface + name: nic1 + mtu: {{ min_viable_mtu }} + # force the MAC address of the bridge to this interface + primary: true + {% for network in role_networks %} + - type: vlan + mtu: {{ lookup('vars', networks_lower[network] ~ '_mtu') }} + vlan_id: {{ lookup('vars', networks_lower[network] ~ '_vlan_id') }} + addresses: + - ip_netmask: + {{ lookup('vars', networks_lower[network] ~ '_ip') }}/{{ lookup('vars', networks_lower[network] ~ '_cidr') }} + routes: {{ lookup('vars', networks_lower[network] ~ '_host_routes') }} + {% endfor %} + edpm_network_config_hide_sensitive_logs: false # # These vars are for the network config templates themselves and are diff --git a/config/samples/dataplane_v1beta1_openstackdataplanenodeset_customnetworks.yaml b/config/samples/dataplane_v1beta1_openstackdataplanenodeset_customnetworks.yaml index 165781bf4..e1e4def43 100644 --- a/config/samples/dataplane_v1beta1_openstackdataplanenodeset_customnetworks.yaml +++ b/config/samples/dataplane_v1beta1_openstackdataplanenodeset_customnetworks.yaml @@ -49,7 +49,38 @@ spec: # edpm_network_config # Default nic config template for a EDPM compute node # These vars are edpm_network_config role vars - edpm_network_config_template: /runner/network/nic-config-template + edpm_network_config_template: | + --- + {% set mtu_list = [ctlplane_mtu] %} + {% for network in role_networks %} + {{ mtu_list.append(lookup('vars', networks_lower[network] ~ '_mtu')) }} + {%- endfor %} + {% set min_viable_mtu = mtu_list | max %} + network_config: + - type: ovs_bridge + name: {{ neutron_physical_bridge_name }} + mtu: {{ min_viable_mtu }} + use_dhcp: false + dns_servers: {{ ctlplane_dns_nameservers }} + domain: {{ dns_search_domains }} + addresses: + - ip_netmask: {{ ctlplane_ip }}/{{ ctlplane_subnet_cidr }} + routes: {{ ctlplane_host_routes }} + members: + - type: interface + name: nic1 + mtu: {{ min_viable_mtu }} + # force the MAC address of the bridge to this interface + primary: true + {% for network in role_networks %} + - type: vlan + mtu: {{ lookup('vars', networks_lower[network] ~ '_mtu') }} + vlan_id: {{ lookup('vars', networks_lower[network] ~ '_vlan_id') }} + addresses: + - ip_netmask: + {{ lookup('vars', networks_lower[network] ~ '_ip') }}/{{ lookup('vars', networks_lower[network] ~ '_cidr') }} + routes: {{ lookup('vars', networks_lower[network] ~ '_host_routes') }} + {% endfor %} edpm_network_config_hide_sensitive_logs: false edpm_network_config_update: false # diff --git a/config/samples/dataplane_v1beta1_openstackdataplanenodeset_with_ipam.yaml b/config/samples/dataplane_v1beta1_openstackdataplanenodeset_with_ipam.yaml index 496bbc5ac..126030424 100644 --- a/config/samples/dataplane_v1beta1_openstackdataplanenodeset_with_ipam.yaml +++ b/config/samples/dataplane_v1beta1_openstackdataplanenodeset_with_ipam.yaml @@ -86,6 +86,38 @@ spec: # edpm_network_config # Default nic config template for a EDPM compute node # These vars are edpm_network_config role vars + edpm_network_config_template: | + --- + {% set mtu_list = [ctlplane_mtu] %} + {% for network in role_networks %} + {{ mtu_list.append(lookup('vars', networks_lower[network] ~ '_mtu')) }} + {%- endfor %} + {% set min_viable_mtu = mtu_list | max %} + network_config: + - type: ovs_bridge + name: {{ neutron_physical_bridge_name }} + mtu: {{ min_viable_mtu }} + use_dhcp: false + dns_servers: {{ ctlplane_dns_nameservers }} + domain: {{ dns_search_domains }} + addresses: + - ip_netmask: {{ ctlplane_ip }}/{{ ctlplane_subnet_cidr }} + routes: {{ ctlplane_host_routes }} + members: + - type: interface + name: nic1 + mtu: {{ min_viable_mtu }} + # force the MAC address of the bridge to this interface + primary: true + {% for network in role_networks %} + - type: vlan + mtu: {{ lookup('vars', networks_lower[network] ~ '_mtu') }} + vlan_id: {{ lookup('vars', networks_lower[network] ~ '_vlan_id') }} + addresses: + - ip_netmask: + {{ lookup('vars', networks_lower[network] ~ '_ip') }}/{{ lookup('vars', networks_lower[network] ~ '_cidr') }} + routes: {{ lookup('vars', networks_lower[network] ~ '_host_routes') }} + {% endfor %} edpm_network_config_hide_sensitive_logs: false # These vars are for the network config templates themselves and are # considered EDPM network defaults. diff --git a/docs/openstack_dataplanenodeset.md b/docs/openstack_dataplanenodeset.md index e4d4f3824..7d236aeaf 100644 --- a/docs/openstack_dataplanenodeset.md +++ b/docs/openstack_dataplanenodeset.md @@ -8,7 +8,6 @@ * [AnsibleEESpec](#ansibleeespec) * [AnsibleOpts](#ansibleopts) * [DeployStrategySection](#deploystrategysection) -* [NetworkConfigSection](#networkconfigsection) * [NodeSection](#nodesection) * [NodeTemplate](#nodetemplate) * [OpenStackDataPlaneNodeSetList](#openstackdataplanenodesetlist) @@ -58,16 +57,6 @@ DeployStrategySection for fields controlling the deployment [Back to Custom Resources](#custom-resources) -#### NetworkConfigSection - -NetworkConfigSection is a specification of the Network configuration details - -| Field | Description | Scheme | Required | -| ----- | ----------- | ------ | -------- | -| template | Template - Contains a Ansible j2 nic config template to use when applying node network configuration | string | false | - -[Back to Custom Resources](#custom-resources) - #### NodeSection NodeSection defines the top level attributes inherited by nodes in the CR. @@ -75,7 +64,6 @@ NodeSection defines the top level attributes inherited by nodes in the CR. | Field | Description | Scheme | Required | | ----- | ----------- | ------ | -------- | | hostName | HostName - node name | string | false | -| networkConfig | NetworkConfig - Network configuration details. Contains os-net-config related properties. | [NetworkConfigSection](#networkconfigsection) | true | | networks | Networks - Instance networks | []infranetworkv1.IPSetNetwork | false | | managementNetwork | ManagementNetwork - Name of network to use for management (SSH/Ansible) | string | false | | ansible | Ansible is the group of Ansible related configuration options. | [AnsibleOpts](#ansibleopts) | false | @@ -94,7 +82,6 @@ NodeTemplate is a specification of the node attributes that override top level a | ansibleSSHPrivateKeySecret | AnsibleSSHPrivateKeySecret Name of a private SSH key secret containing private SSH key for connecting to node. The named secret must be of the form: Secret.data.ssh-privatekey: | string | false | | nodes | Nodes - Map of Node Names and node specific data. Values here override defaults in the upper level section. | map[string][NodeSection](#nodesection) | true | | networkAttachments | NetworkAttachments is a list of NetworkAttachment resource names to pass to the ansibleee resource which allows to connect the ansibleee runner to the given network | []string | false | -| networkConfig | NetworkConfig - Network configuration details. Contains os-net-config related properties. | [NetworkConfigSection](#networkconfigsection) | false | | networks | Networks - Instance networks | []infranetworkv1.IPSetNetwork | false | | managementNetwork | ManagementNetwork - Name of network to use for management (SSH/Ansible) | string | false | | ansible | Ansible is the group of Ansible related configuration options. | [AnsibleOpts](#ansibleopts) | false | diff --git a/docs/openstack_dataplaneservice.md b/docs/openstack_dataplaneservice.md index b34a47644..f0b4f8922 100644 --- a/docs/openstack_dataplaneservice.md +++ b/docs/openstack_dataplaneservice.md @@ -8,7 +8,6 @@ * [AnsibleEESpec](#ansibleeespec) * [AnsibleOpts](#ansibleopts) * [DeployStrategySection](#deploystrategysection) -* [NetworkConfigSection](#networkconfigsection) * [NodeSection](#nodesection) * [NodeTemplate](#nodetemplate) * [KubeService](#kubeservice) @@ -59,16 +58,6 @@ DeployStrategySection for fields controlling the deployment [Back to Custom Resources](#custom-resources) -#### NetworkConfigSection - -NetworkConfigSection is a specification of the Network configuration details - -| Field | Description | Scheme | Required | -| ----- | ----------- | ------ | -------- | -| template | Template - Contains a Ansible j2 nic config template to use when applying node network configuration | string | false | - -[Back to Custom Resources](#custom-resources) - #### NodeSection NodeSection defines the top level attributes inherited by nodes in the CR. @@ -76,7 +65,6 @@ NodeSection defines the top level attributes inherited by nodes in the CR. | Field | Description | Scheme | Required | | ----- | ----------- | ------ | -------- | | hostName | HostName - node name | string | false | -| networkConfig | NetworkConfig - Network configuration details. Contains os-net-config related properties. | [NetworkConfigSection](#networkconfigsection) | true | | networks | Networks - Instance networks | []infranetworkv1.IPSetNetwork | false | | managementNetwork | ManagementNetwork - Name of network to use for management (SSH/Ansible) | string | false | | ansible | Ansible is the group of Ansible related configuration options. | [AnsibleOpts](#ansibleopts) | false | @@ -95,7 +83,6 @@ NodeTemplate is a specification of the node attributes that override top level a | ansibleSSHPrivateKeySecret | AnsibleSSHPrivateKeySecret Name of a private SSH key secret containing private SSH key for connecting to node. The named secret must be of the form: Secret.data.ssh-privatekey: | string | false | | nodes | Nodes - Map of Node Names and node specific data. Values here override defaults in the upper level section. | map[string][NodeSection](#nodesection) | true | | networkAttachments | NetworkAttachments is a list of NetworkAttachment resource names to pass to the ansibleee resource which allows to connect the ansibleee runner to the given network | []string | false | -| networkConfig | NetworkConfig - Network configuration details. Contains os-net-config related properties. | [NetworkConfigSection](#networkconfigsection) | false | | networks | Networks - Instance networks | []infranetworkv1.IPSetNetwork | false | | managementNetwork | ManagementNetwork - Name of network to use for management (SSH/Ansible) | string | false | | ansible | Ansible is the group of Ansible related configuration options. | [AnsibleOpts](#ansibleopts) | false | diff --git a/pkg/deployment/inventory.go b/pkg/deployment/inventory.go index 7aa9874be..5d217a6cf 100644 --- a/pkg/deployment/inventory.go +++ b/pkg/deployment/inventory.go @@ -93,11 +93,6 @@ func GenerateNodeSetInventory(ctx context.Context, helper *helper.Helper, host.Vars[entry+"_host_routes"] = res.Routes dnsSearchDomains = append(dnsSearchDomains, res.DNSDomain) } - networkConfig := getAnsibleNetworkConfig(instance, nodeName) - - if networkConfig.Template != "" { - host.Vars["edpm_network_config_template"] = NicConfigTemplateFile - } host.Vars["ansible_user"] = getAnsibleUser(instance, nodeName) host.Vars["ansible_port"] = getAnsiblePort(instance, nodeName) @@ -134,7 +129,6 @@ func GenerateNodeSetInventory(ctx context.Context, helper *helper.Helper, } secretData := map[string]string{ "inventory": string(invData), - "network": string(instance.Spec.NodeTemplate.NetworkConfig.Template), } secretName := fmt.Sprintf("dataplanenodeset-%s", instance.Name) template := []utils.Template{ @@ -215,14 +209,6 @@ func getAnsibleManagementNetwork( return instance.Spec.NodeTemplate.ManagementNetwork } -// getAnsibleNetworkConfig returns a JSON string value from the template unless it is set in the node -func getAnsibleNetworkConfig(instance *dataplanev1.OpenStackDataPlaneNodeSet, nodeName string) dataplanev1.NetworkConfigSection { - if instance.Spec.NodeTemplate.Nodes[nodeName].NetworkConfig.Template != "" { - return instance.Spec.NodeTemplate.Nodes[nodeName].NetworkConfig - } - return instance.Spec.NodeTemplate.NetworkConfig -} - // getAnsibleNetworks returns a JSON string mapping fixedIP and/or network name to their valules func getAnsibleNetworks(instance *dataplanev1.OpenStackDataPlaneNodeSet, nodeName string) []infranetworkv1.IPSetNetwork { if len(instance.Spec.NodeTemplate.Nodes[nodeName].Networks) > 0 { @@ -296,9 +282,6 @@ func resolveAnsibleVars(nodeTemplate *dataplanev1.NodeTemplate, host *ansible.Ho if nodeTemplate.ManagementNetwork != "" { ansibleVarsData["management_network"] = nodeTemplate.ManagementNetwork } - if nodeTemplate.NetworkConfig.Template != "" { - ansibleVarsData["edpm_network_config_template"] = NicConfigTemplateFile - } if len(nodeTemplate.Networks) > 0 { ansibleVarsData["networks"] = nodeTemplate.Networks } @@ -340,9 +323,6 @@ func resolveNodeAnsibleVars(node *dataplanev1.NodeSection, host *ansible.Host, g if node.ManagementNetwork != "" { ansibleVarsData["management_network"] = node.ManagementNetwork } - if node.NetworkConfig.Template != "" { - ansibleVarsData["edpm_network_config_template"] = NicConfigTemplateFile - } if len(node.Networks) > 0 { ansibleVarsData["networks"] = node.Networks } diff --git a/pkg/util/ansible_execution.go b/pkg/util/ansible_execution.go index f7fd0cbbc..213cae427 100644 --- a/pkg/util/ansible_execution.go +++ b/pkg/util/ansible_execution.go @@ -127,10 +127,6 @@ func AnsibleExecution( Key: "inventory", Path: "inventory", }, - { - Key: "network", - Path: "network", - }, }, }, }, @@ -140,17 +136,11 @@ func AnsibleExecution( MountPath: "/runner/inventory/hosts", SubPath: "inventory", } - networkConfigMount := corev1.VolumeMount{ - Name: "inventory", - MountPath: "/runner/network/nic-config-template", - SubPath: "network", - } ansibleEEMounts.Volumes = append(ansibleEEMounts.Volumes, sshKeyVolume) ansibleEEMounts.Volumes = append(ansibleEEMounts.Volumes, inventoryVolume) ansibleEEMounts.Mounts = append(ansibleEEMounts.Mounts, sshKeyMount) ansibleEEMounts.Mounts = append(ansibleEEMounts.Mounts, inventoryMount) - ansibleEEMounts.Mounts = append(ansibleEEMounts.Mounts, networkConfigMount) ansibleEE.Spec.ExtraMounts = append(aeeSpec.ExtraMounts, []storage.VolMounts{ansibleEEMounts}...) ansibleEE.Spec.Env = aeeSpec.Env diff --git a/tests/kuttl/tests/dataplane-deploy-no-nodes-test/01-assert.yaml b/tests/kuttl/tests/dataplane-deploy-no-nodes-test/01-assert.yaml index d23ae3967..921508e04 100644 --- a/tests/kuttl/tests/dataplane-deploy-no-nodes-test/01-assert.yaml +++ b/tests/kuttl/tests/dataplane-deploy-no-nodes-test/01-assert.yaml @@ -97,9 +97,6 @@ spec: - mountPath: /runner/inventory/hosts name: inventory subPath: inventory - - mountPath: /runner/network/nic-config-template - name: inventory - subPath: network volumes: - name: ssh-key secret: @@ -112,8 +109,6 @@ spec: items: - key: inventory path: inventory - - key: network - path: network secretName: dataplanenodeset-edpm-compute-no-nodes image: quay.io/openstack-k8s-operators/openstack-ansibleee-runner:latest name: openstackansibleee @@ -153,9 +148,6 @@ spec: - mountPath: /runner/inventory/hosts name: inventory subPath: inventory - - mountPath: /runner/network/nic-config-template - name: inventory - subPath: network volumes: - name: ssh-key secret: @@ -168,8 +160,6 @@ spec: items: - key: inventory path: inventory - - key: network - path: network secretName: dataplanenodeset-edpm-compute-no-nodes image: quay.io/openstack-k8s-operators/openstack-ansibleee-runner:latest name: openstackansibleee @@ -209,9 +199,6 @@ spec: - mountPath: /runner/inventory/hosts name: inventory subPath: inventory - - mountPath: /runner/network/nic-config-template - name: inventory - subPath: network volumes: - name: ssh-key secret: @@ -224,8 +211,6 @@ spec: items: - key: inventory path: inventory - - key: network - path: network secretName: dataplanenodeset-edpm-compute-no-nodes image: quay.io/openstack-k8s-operators/openstack-ansibleee-runner:latest name: openstackansibleee @@ -266,9 +251,6 @@ spec: - mountPath: /runner/inventory/hosts name: inventory subPath: inventory - - mountPath: /runner/network/nic-config-template - name: inventory - subPath: network volumes: - name: ssh-key secret: @@ -281,8 +263,6 @@ spec: items: - key: inventory path: inventory - - key: network - path: network secretName: dataplanenodeset-edpm-compute-no-nodes image: quay.io/openstack-k8s-operators/openstack-ansibleee-runner:latest name: openstackansibleee @@ -322,9 +302,6 @@ spec: - mountPath: /runner/inventory/hosts name: inventory subPath: inventory - - mountPath: /runner/network/nic-config-template - name: inventory - subPath: network volumes: - name: ssh-key secret: @@ -337,8 +314,6 @@ spec: items: - key: inventory path: inventory - - key: network - path: network secretName: dataplanenodeset-edpm-compute-no-nodes image: quay.io/openstack-k8s-operators/openstack-ansibleee-runner:latest name: openstackansibleee @@ -390,9 +365,6 @@ spec: - mountPath: /runner/inventory/hosts name: inventory subPath: inventory - - mountPath: /runner/network/nic-config-template - name: inventory - subPath: network volumes: - name: ssh-key secret: @@ -405,8 +377,6 @@ spec: items: - key: inventory path: inventory - - key: network - path: network secretName: dataplanenodeset-edpm-compute-no-nodes image: quay.io/openstack-k8s-operators/openstack-ansibleee-runner:latest name: openstackansibleee @@ -449,9 +419,6 @@ spec: - mountPath: /runner/inventory/hosts name: inventory subPath: inventory - - mountPath: /runner/network/nic-config-template - name: inventory - subPath: network volumes: - name: ssh-key secret: @@ -464,8 +431,6 @@ spec: items: - key: inventory path: inventory - - key: network - path: network secretName: dataplanenodeset-edpm-compute-no-nodes image: quay.io/openstack-k8s-operators/openstack-ansibleee-runner:latest name: openstackansibleee @@ -513,9 +478,6 @@ spec: - mountPath: /runner/inventory/hosts name: inventory subPath: inventory - - mountPath: /runner/network/nic-config-template - name: inventory - subPath: network volumes: - name: ssh-key secret: @@ -528,8 +490,6 @@ spec: items: - key: inventory path: inventory - - key: network - path: network secretName: dataplanenodeset-edpm-compute-no-nodes image: quay.io/openstack-k8s-operators/openstack-ansibleee-runner:latest name: openstackansibleee diff --git a/tests/kuttl/tests/dataplane-service-config/00-assert.yaml b/tests/kuttl/tests/dataplane-service-config/00-assert.yaml index f9f5c6fbb..90cfd14b8 100644 --- a/tests/kuttl/tests/dataplane-service-config/00-assert.yaml +++ b/tests/kuttl/tests/dataplane-service-config/00-assert.yaml @@ -73,9 +73,6 @@ spec: - mountPath: /runner/inventory/hosts name: inventory subPath: inventory - - mountPath: /runner/network/nic-config-template - name: inventory - subPath: network volumes: - name: ssh-key secret: @@ -88,8 +85,6 @@ spec: items: - key: inventory path: inventory - - key: network - path: network secretName: dataplanenodeset-edpm-compute-no-nodes image: quay.io/openstack-k8s-operators/openstack-ansibleee-runner:latest name: openstackansibleee