From 50df571a46391b86bde12bc3864a671c971e5ab4 Mon Sep 17 00:00:00 2001 From: Pablo Rodriguez Nava Date: Wed, 30 Oct 2024 17:52:18 +0100 Subject: [PATCH] [ci_netconfig] Remove unused and outdated role This role was part of the old effort to have a common strategy to deploy VA/DTs and install_yamls deployments but the approach drastically changed during its development and it has never been used nor updated to use the networking mapper. --- ci/config/molecule.yaml | 3 - roles/ci_netconfig/README.md | 49 ------- roles/ci_netconfig/defaults/main.yml | 24 ---- roles/ci_netconfig/meta/main.yml | 30 ---- .../molecule/default/converge.yml | 134 ------------------ .../molecule/default/molecule.yml | 11 -- .../ci_netconfig/molecule/default/prepare.yml | 66 --------- roles/ci_netconfig/tasks/cleanup.yml | 41 ------ roles/ci_netconfig/tasks/main.yml | 37 ----- roles/ci_netconfig/templates/netconfig.yml.j2 | 50 ------- zuul.d/molecule.yaml | 11 -- zuul.d/projects.yaml | 1 - 12 files changed, 457 deletions(-) delete mode 100644 roles/ci_netconfig/README.md delete mode 100644 roles/ci_netconfig/defaults/main.yml delete mode 100644 roles/ci_netconfig/meta/main.yml delete mode 100644 roles/ci_netconfig/molecule/default/converge.yml delete mode 100644 roles/ci_netconfig/molecule/default/molecule.yml delete mode 100644 roles/ci_netconfig/molecule/default/prepare.yml delete mode 100644 roles/ci_netconfig/tasks/cleanup.yml delete mode 100644 roles/ci_netconfig/tasks/main.yml delete mode 100644 roles/ci_netconfig/templates/netconfig.yml.j2 diff --git a/ci/config/molecule.yaml b/ci/config/molecule.yaml index 790aea0e3a..c19acf33f1 100644 --- a/ci/config/molecule.yaml +++ b/ci/config/molecule.yaml @@ -39,9 +39,6 @@ - job: name: cifmw-molecule-ci_multus parent: cifmw-molecule-base-crc -- job: - name: cifmw-molecule-ci_netconfig - parent: cifmw-molecule-base-crc - job: name: cifmw-molecule-ci_nmstate parent: cifmw-molecule-base-crc diff --git a/roles/ci_netconfig/README.md b/roles/ci_netconfig/README.md deleted file mode 100644 index 0969a1ffd1..0000000000 --- a/roles/ci_netconfig/README.md +++ /dev/null @@ -1,49 +0,0 @@ -# ci_netconfig - -It creates NetConfig resources in an OCP cluster - -## Parameters - -- `cifmw_ci_netconfig_basedir`: (String) Base directory. Defaults to `cifmw_basedir` which defaults to `~/ci-framework-data`. -- `cifmw_ci_netconfig_manifests_dir`: (String) Directory where OCP manifests will be placed. Defaults to `"{{ cifmw_manifests | default(cifmw_ci_netconfig_basedir ~ '/artifacts/manifests') }}"`. -- `cifmw_ci_netconfig_namespace`: (String) The namespace where OCP resources will be installed. Defaults to `openstack`. -- `cifmw_ci_netconfig_dict`: (Dict) Dictionary of Network configuration to be created in destination OCP cluster. Defaults to `{}`. - -## Examples - -```YAML - - name: Configure networks - vars: - cifmw_ci_netconfig_list: - ctlPlane: - network_v4: 192.168.122.0/24 - gw_v4: 192.168.122.1 - searchDomain: ctlplane.example.com - tools: - netconfig: - ranges: - - end: 192.168.122.120 - start: 192.168.122.100 - - end: 192.168.122.200 - start: 192.168.122.150 - internalApi: - searchDomain: internalapi.example.com - network_v4: 172.17.0.0/24 - vlan: 20 - tools: - netconfig: - ranges: - - end: 172.17.0.250 - start: 172.17.0.100 - external: - searchDomain: external.example.com - network_v4: 10.0.0.0/24 - gw_v4: 10.0.0.1 - tools: - netconfig: - ranges: - - end: 10.0.0.250 - start: 10.0.0.100 - ansible.builtin.include_role: - name: "ci_netconfig" -``` diff --git a/roles/ci_netconfig/defaults/main.yml b/roles/ci_netconfig/defaults/main.yml deleted file mode 100644 index eb1b05e1a0..0000000000 --- a/roles/ci_netconfig/defaults/main.yml +++ /dev/null @@ -1,24 +0,0 @@ ---- -# Copyright Red Hat, Inc. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - - -# All variables intended for modification should be placed in this file. -# All variables within this role should have a prefix of "cifmw_ci_netconfig" -cifmw_ci_netconfig_basedir: "{{ cifmw_basedir | default(ansible_user_dir ~ '/ci-framework-data') }}" -cifmw_ci_netconfig_manifests_dir: "{{ cifmw_manifests | default(cifmw_ci_netconfig_basedir ~ '/artifacts/manifests') }}/netconfig" -cifmw_ci_netconfig_namespace: "openstack" -# Input configuration for ci_netconfig role -cifmw_ci_netconfig_dict: {} diff --git a/roles/ci_netconfig/meta/main.yml b/roles/ci_netconfig/meta/main.yml deleted file mode 100644 index ae3748fe55..0000000000 --- a/roles/ci_netconfig/meta/main.yml +++ /dev/null @@ -1,30 +0,0 @@ ---- -# Copyright Red Hat, Inc. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - - -galaxy_info: - author: CI Framework - description: CI Framework Role -- ci_netconfig - company: Red Hat - license: Apache-2.0 - min_ansible_version: "2.14" - namespace: cifmw - galaxy_tags: - - cifmw - -# List your role dependencies here, one per line. Be sure to remove the '[]' above, -# if you add dependencies to this list. -dependencies: [] diff --git a/roles/ci_netconfig/molecule/default/converge.yml b/roles/ci_netconfig/molecule/default/converge.yml deleted file mode 100644 index 6a24e2b1a2..0000000000 --- a/roles/ci_netconfig/molecule/default/converge.yml +++ /dev/null @@ -1,134 +0,0 @@ ---- -# Copyright Red Hat, Inc. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - - -- name: Converge - hosts: all - gather_facts: true - vars: - cifmw_path: "{{ ansible_user_dir }}/.crc/bin:{{ ansible_user_dir }}/.crc/bin/oc:{{ ansible_user_dir }}/bin:{{ ansible_env.PATH }}" - cifmw_openshift_kubeconfig: "{{ ansible_user_dir }}/.crc/machines/crc/kubeconfig" - tasks: - - name: Add crc hostname with it's IP to /etc/hosts - become: true - ansible.builtin.lineinfile: - path: /etc/hosts - line: "192.168.130.11 crc" - - - name: Add the crc host dynamically - ansible.builtin.add_host: - name: crc - ansible_ssh_private_key_file: "{{ ansible_user_dir }}/.crc/machines/crc/id_ecdsa" - ansible_ssh_user: core - - - name: Fetch crc network facts - ansible.builtin.setup: - gather_subset: network - delegate_to: crc - delegate_facts: true - - - name: Prepare the network var for the role - ansible.builtin.set_fact: - cifmw_ci_netconfig_dict: - - ctlPlane: - network_v4: 192.168.122.0/24 - gw_v4: 192.168.122.1 - search_domain: ctlplane.example.com - tools: - netconfig: - ranges: - - end: 192.168.122.120 - start: 192.168.122.100 - - end: 192.168.122.200 - start: 192.168.122.150 - - internalApi: - search_domain: internalapi.example.com - network_v4: 172.17.0.0/24 - vlan: 20 - tools: - netconfig: - ranges: - - end: 172.17.0.250 - start: 172.17.0.100 - - external: - search_domain: external.example.com - network_v4: 10.0.0.0/24 - gw_v4: 10.0.0.1 - tools: - netconfig: - ranges: - - end: 10.0.0.250 - start: 10.0.0.100 - - - name: Call ci_netconfig role - ansible.builtin.include_role: - name: "ci_netconfig" - - # Verify the run - - name: Fetch files stat results - ansible.builtin.stat: - path: >- - {{ - [ - ansible_user_dir, - 'ci-framework-data', - 'artifacts', - 'manifests/netconfig/ci_netconfig.yml' - ] | ansible.builtin.path_join - }} - register: _ci_netconfig_molecule_stat_out - - - name: Assert that file exist - ansible.builtin.assert: - that: _ci_netconfig_molecule_stat_out.stat.exists - - - name: Fetch all files content - ansible.builtin.slurp: - path: "{{ _ci_netconfig_molecule_stat_out.stat.path }}" - register: _ci_netconfig_molecule_slurp_out - - - name: Assert that all files contains proper YAML data - ansible.builtin.assert: - that: "_ci_netconfig_molecule_slurp_out.content | b64decode | from_yaml | length > 0" - - - name: Check if NetConfig resources were created - kubernetes.core.k8s_info: - kubeconfig: "{{ cifmw_openshift_kubeconfig }}" - namespace: "{{ cifmw_ci_netconfig_namespace }}" - api_version: network.openstack.org/v1beta1 - kind: NetConfig - register: _ci_netconfig_molecule_out - failed_when: >- - (_ci_netconfig_molecule_out is not defined) or - (_ci_netconfig_molecule_out is failed) or - (_ci_netconfig_molecule_out.resources | length == 0) - - - name: Call cleanup - ansible.builtin.import_role: - name: ci_netconfig - tasks_from: cleanup.yml - - - name: Check if netconfig resources were deleted - kubernetes.core.k8s_info: - kubeconfig: "{{ cifmw_openshift_kubeconfig }}" - namespace: "{{ cifmw_ci_netconfig_namespace }}" - api_version: network.openstack.org/v1beta1 - kind: NetConfig - register: _ci_netconfig_molecule_cleanup_out - failed_when: >- - (_ci_netconfig_molecule_cleanup_out is not defined) or - (_ci_netconfig_molecule_cleanup_out is failed) or - (_ci_netconfig_molecule_cleanup_out.resources | length > 0) diff --git a/roles/ci_netconfig/molecule/default/molecule.yml b/roles/ci_netconfig/molecule/default/molecule.yml deleted file mode 100644 index fda947cafe..0000000000 --- a/roles/ci_netconfig/molecule/default/molecule.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- -# Mainly used to override the defaults set in .config/molecule/ -# By default, it uses the "config_podman.yml" - in CI, it will use -# "config_local.yml". -log: true - -provisioner: - name: ansible - log: true - env: - ANSIBLE_STDOUT_CALLBACK: yaml diff --git a/roles/ci_netconfig/molecule/default/prepare.yml b/roles/ci_netconfig/molecule/default/prepare.yml deleted file mode 100644 index b435ae257f..0000000000 --- a/roles/ci_netconfig/molecule/default/prepare.yml +++ /dev/null @@ -1,66 +0,0 @@ ---- -# Copyright Red Hat, Inc. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - - -- name: Prepare - hosts: all - vars: - cifmw_path: "{{ ansible_user_dir }}/.crc/bin:{{ ansible_user_dir }}/.crc/bin/oc:{{ ansible_user_dir }}/bin:{{ ansible_env.PATH }}" - cifmw_openshift_kubeconfig: "{{ ansible_user_dir }}/.crc/machines/crc/kubeconfig" - pre_tasks: - - name: Ensure CRC is started - async: 1800 - poll: 0 - register: _crc_start - ansible.builtin.command: - cmd: crc start - roles: - - role: test_deps - - role: ci_setup - - role: install_yamls - tasks: - - name: Check for CRC status - ansible.builtin.async_status: - jid: "{{ _crc_start.ansible_job_id }}" - register: _crc_status - until: _crc_status.finished - retries: 100 - delay: 10 - - name: Install infra operator - ansible.builtin.include_role: - name: 'install_yamls_makes' - tasks_from: "{{ item }}" - loop: - - 'make_namespace.yml' - - 'make_infra.yml' - - name: Wait for infra operator to be intalled - environment: - KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}" - PATH: "{{ cifmw_path }}" - ansible.builtin.command: - cmd: >- - oc get ClusterServiceVersion - -n openstack-operators - -o jsonpath='{.items[*].status.phase}' - changed_when: false - register: _infra_csv_out - retries: 12 - delay: 10 - until: - - _infra_csv_out is defined - - _infra_csv_out.failed is false - - _infra_csv_out.stdout_lines | length > 0 - - "(_infra_csv_out.stdout_lines[0] | lower) == 'succeeded'" diff --git a/roles/ci_netconfig/tasks/cleanup.yml b/roles/ci_netconfig/tasks/cleanup.yml deleted file mode 100644 index 0b54990098..0000000000 --- a/roles/ci_netconfig/tasks/cleanup.yml +++ /dev/null @@ -1,41 +0,0 @@ ---- -# Copyright Red Hat, Inc. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - - -- name: Clean OCP resources if available - when: cifmw_openshift_kubeconfig is defined - block: - - name: Fetch netconfig resources - kubernetes.core.k8s_info: - kubeconfig: "{{ cifmw_openshift_kubeconfig }}" - api_key: "{{ cifmw_openshift_token | default(omit)}}" - context: "{{ cifmw_openshift_context | default(omit)}}" - namespace: "{{ cifmw_ci_netconfig_namespace }}" - api_version: network.openstack.org/v1beta1 - kind: NetConfig - register: _netconfig_info_cleanup_out - - - name: Delete netconfig resources - kubernetes.core.k8s: - state: absent - kubeconfig: "{{ cifmw_openshift_kubeconfig }}" - api_key: "{{ cifmw_openshift_token | default(omit)}}" - context: "{{ cifmw_openshift_context | default(omit)}}" - namespace: "{{ cifmw_ci_netconfig_namespace }}" - resource_definition: "{{ item }}" - loop: "{{ _netconfig_info_cleanup_out.resources | default([]) }}" - loop_control: - label: "{{ item.metadata.name }}" diff --git a/roles/ci_netconfig/tasks/main.yml b/roles/ci_netconfig/tasks/main.yml deleted file mode 100644 index 2d7f7a2f9e..0000000000 --- a/roles/ci_netconfig/tasks/main.yml +++ /dev/null @@ -1,37 +0,0 @@ ---- -# Copyright Red Hat, Inc. -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -- name: Create role needed directories - ansible.builtin.file: - path: "{{ cifmw_ci_netconfig_manifests_dir }}" - state: directory - mode: "0755" - -- name: Create network config definitions in manifest dir - vars: - _cifmw_ci_netconfig_dict: "{{ cifmw_ci_netconfig_dict }}" - ansible.builtin.template: - src: "netconfig.yml.j2" - dest: "{{ cifmw_ci_netconfig_manifests_dir }}/ci_netconfig.yml" - lstrip_blocks: true - -- name: Apply network config definitions - kubernetes.core.k8s: - kubeconfig: "{{ cifmw_openshift_kubeconfig }}" - api_key: "{{ cifmw_openshift_token | default(omit) }}" - context: "{{ cifmw_openshift_context | default(omit) }}" - state: present - definition: "{{ lookup('file', cifmw_ci_netconfig_manifests_dir + '/ci_netconfig.yml') | from_yaml }}" diff --git a/roles/ci_netconfig/templates/netconfig.yml.j2 b/roles/ci_netconfig/templates/netconfig.yml.j2 deleted file mode 100644 index 56cf8fbdd8..0000000000 --- a/roles/ci_netconfig/templates/netconfig.yml.j2 +++ /dev/null @@ -1,50 +0,0 @@ ---- -apiVersion: network.openstack.org/v1beta1 -kind: NetConfig -metadata: - name: netconfig - namespace: {{ cifmw_ci_netconfig_namespace }} -spec: - networks: - {% for network in _cifmw_ci_netconfig_dict %} - {% for key, value in network.items() %} - - name: {{ key }} - dnsDomain: {{ value.search_domain }} - {% if value.mtu is defined %} - mtu: {{ value.mtu }} - {% endif %} - subnets: - - name: {{ 'subnet-' ~ key }} - allocationRanges: - {% for ranges in value.tools.netconfig.ranges %} - - start: {{ ranges.start }} - end: {{ ranges.end }} - {% endfor %} - {% if value.network_v4 is defined %} - cidr: {{ value.network_v4 }} - {% elif value.network_v6 is defined %} - cidr: {{ value.network_v6 }} - {% endif %} - {% if value.excludeAddresses is defined %} - excludeAddresses: - {% for address in value.excludeAddresses %} - - {{ address }} - {% endfor %} - {% endif %} - {% if value.gateway_v4 is defined %} - gateway: {{ value.gateway_v4 }} - {% elif value.gateway_v6 is defined %} - gateway: {{ value.gateway_v6 }} - {% endif %} - {% if value.routes is defined %} - routes: - {% for route in value.routes %} - - destination: {{ route.destination }} - nexthop: {{ route.nexthop }} - {% endfor %} - {% endif %} - {% if value.vlan is defined %} - vlan: {{ value.vlan }} - {% endif %} - {% endfor %} - {% endfor %} diff --git a/zuul.d/molecule.yaml b/zuul.d/molecule.yaml index bf62068dbf..1af4750b8d 100644 --- a/zuul.d/molecule.yaml +++ b/zuul.d/molecule.yaml @@ -103,17 +103,6 @@ parent: cifmw-molecule-base-crc vars: TEST_RUN: ci_multus -- job: - files: - - ^common-requirements.txt - - ^test-requirements.txt - - ^roles/ci_netconfig/(defaults|files|handlers|library|lookup_plugins|module_utils|molecule|tasks|templates|vars).* - - ^ci/playbooks/molecule.* - - ^.config/molecule/.* - name: cifmw-molecule-ci_netconfig - parent: cifmw-molecule-base-crc - vars: - TEST_RUN: ci_netconfig - job: files: - ^common-requirements.txt diff --git a/zuul.d/projects.yaml b/zuul.d/projects.yaml index a77556268e..768bb33482 100644 --- a/zuul.d/projects.yaml +++ b/zuul.d/projects.yaml @@ -25,7 +25,6 @@ - cifmw-molecule-ci_lvms_storage - cifmw-molecule-ci_metallb - cifmw-molecule-ci_multus - - cifmw-molecule-ci_netconfig - cifmw-molecule-ci_network - cifmw-molecule-ci_nmstate - cifmw-molecule-ci_setup