diff --git a/roles/devscripts/README.md b/roles/devscripts/README.md index 85e55bf8f3..664c19156d 100644 --- a/roles/devscripts/README.md +++ b/roles/devscripts/README.md @@ -53,6 +53,7 @@ networks. * `cifmw_devscripts_cinder_volume_pvs` (list) a list of physical disks to be used for creating cinder-volumes volume-group. By default, the list contains `/dev/vda`. +* `cifmw_devscripts_sno` (bool) Enable Single Node OpenShift. Defaults to `false`. ### Secrets management diff --git a/roles/devscripts/defaults/main.yml b/roles/devscripts/defaults/main.yml index 53f35a8fb1..61c3466c29 100644 --- a/roles/devscripts/defaults/main.yml +++ b/roles/devscripts/defaults/main.yml @@ -72,3 +72,4 @@ cifmw_devscripts_config_overrides: {} cifmw_devscripts_installer_timeout: 7200 # 2 hours cifmw_devscripts_etcd_slow_profile: true cifmw_devscripts_disable_console: false +cifmw_devscripts_sno: false diff --git a/roles/devscripts/tasks/310_prepare_overlay.yml b/roles/devscripts/tasks/310_prepare_overlay.yml index 80516201fa..84214eb622 100644 --- a/roles/devscripts/tasks/310_prepare_overlay.yml +++ b/roles/devscripts/tasks/310_prepare_overlay.yml @@ -57,6 +57,17 @@ uri: "qemu:///system" loop: "{{ _current_vms.list_vms | select('match', matcher) }}" +- name: Undefine all nodes part of OpenShift platform when SNO node with NVRAM removal + when: + - cifmw_devscripts_sno | default(false) | bool + community.libvirt.virt: + command: "undefine" + flags: + - "nvram" + - "snapshots_metadata" + name: "ocp_master_0" + uri: "qemu:///system" + - name: Disable online cluster flag when: - cifmw_devscripts_ocp_online | bool diff --git a/roles/devscripts/tasks/build_config.yml b/roles/devscripts/tasks/build_config.yml index 7667cc7d52..5611f5a845 100644 --- a/roles/devscripts/tasks/build_config.yml +++ b/roles/devscripts/tasks/build_config.yml @@ -40,6 +40,13 @@ devscripts_config_patches }} +- name: Check if num_masters is equal to 1 when cifmw_devscripts_sno + when: cifmw_devscripts_sno and cifmw_devscripts_config['num_masters'] | int != 1 + ansible.builtin.fail: + msg: >- + Make sure, vms.ocp.amount (num_masters) is set to 1, + when SNO scenario is set. + - name: Replace OCP version if "stable-" alias used when: - cifmw_devscripts_config.openshift_version.startswith("stable-") diff --git a/roles/devscripts/tasks/main.yml b/roles/devscripts/tasks/main.yml index 6a87bf0237..991b4fca5a 100644 --- a/roles/devscripts/tasks/main.yml +++ b/roles/devscripts/tasks/main.yml @@ -48,10 +48,19 @@ }} block: - name: Run devscripts make all + when: not cifmw_devscripts_sno | default(false) cifmw.general.ci_script: chdir: "{{ cifmw_devscripts_repo_dir }}" output_dir: "{{ cifmw_devscripts_artifacts_dir }}" script: "timeout {{ cifmw_devscripts_installer_timeout }} make all" + + - name: Run devscripts make agent when SNO + when: cifmw_devscripts_sno | default(false) + cifmw.general.ci_script: + chdir: "{{ cifmw_devscripts_repo_dir }}" + output_dir: "{{ cifmw_devscripts_artifacts_dir }}" + script: "timeout {{ cifmw_devscripts_installer_timeout }} make agent" + always: - name: Gather logs register: _deploy_logs diff --git a/roles/devscripts/templates/conf_ciuser.j2 b/roles/devscripts/templates/conf_ciuser.j2 index f143b68dca..a35a0bb8ab 100644 --- a/roles/devscripts/templates/conf_ciuser.j2 +++ b/roles/devscripts/templates/conf_ciuser.j2 @@ -7,6 +7,40 @@ set +x export CI_TOKEN=$(cat {{ cifmw_devscripts_repo_dir }}/ci_token) set -x +{% if not cifmw_devscripts_sno %} {% for item in cifmw_devscripts_config %} export {{ item.upper() }}="{{ cifmw_devscripts_config[item] }}" {% endfor %} +{% endif %} + + +{% if cifmw_devscripts_sno %} + +{% for item in ['working_dir', 'assets_extra_folder', 'openshift_release_type', + 'openshift_version', 'cluster_name', 'base_domain', 'ntp_servers', + 'external_bootstrap_mac', 'vm_extradisks', + 'vm_extradisks_list', 'ssh_pub_key'] %} +export {{ item.upper() }}="{{ cifmw_devscripts_config[item] }}" +{% endfor %} +# https://github.com/openshift-metal3/dev-scripts/blob/master/agent/docs/none-and-external-platform.md +# https://github.com/openshift-metal3/dev-scripts/blob/master/common.sh#L470 +# SNO Configuration +export IP_STACK="v4" +export AGENT_E2E_TEST_SCENARIO="SNO_IPV4" +export AGENT_PLATFORM_TYPE="none" +export NUM_MASTERS=1 +export NUM_WORKERS=0 + +# https://github.com/openshift-metal3/dev-scripts/blob/master/network.sh +# https://github.com/openshift-metal3/dev-scripts/blob/master/vm_setup_vars.yml +# it needs to be 192.168.111.80, with 122.0/24 it fails. +# EXTERNAL_SUBNET_V4="192.168.122.0/24" + +#export RENDEZVOUS_IP="192.168.122.10" +# export API_VIP="192.168.111.10" +# # export INGRESS_VIP="192.168.111.4" +# export PROVISIONING_HOST_IP="192.168.111.1" +# # export CLUSTER_DHCP_RANGE="192.168.111.10,192.168.111.100" +# #export DNS_IP="{{ ansible_default_ipv4.address }}" +# export DNS_IP="192.168.111.1" +{% endif %} diff --git a/roles/dnsmasq/tasks/manage_host_record.yml b/roles/dnsmasq/tasks/manage_host_record.yml index 6b1ec17447..3085109024 100644 --- a/roles/dnsmasq/tasks/manage_host_record.yml +++ b/roles/dnsmasq/tasks/manage_host_record.yml @@ -55,3 +55,10 @@ vars: short_name: "{{ record.names[0] | regex_replace('^([^.]+)\\..*$', '\\1') }}" ip: "{{ record.ips[0] }}" + +- name: Remove crc.testing from host_records + when: cifmw_devscripts_sno | default(false) + become: true + ansible.builtin.shell: | + sed -i '/crc.testing/d' {{ cifmw_dnsmasq_basedir }}/host_records.conf + notify: Restart dnsmasq diff --git a/roles/libvirt_manager/tasks/add_vm_to_inventory.yml b/roles/libvirt_manager/tasks/add_vm_to_inventory.yml index b5642f9038..30c9e07921 100644 --- a/roles/libvirt_manager/tasks/add_vm_to_inventory.yml +++ b/roles/libvirt_manager/tasks/add_vm_to_inventory.yml @@ -22,3 +22,18 @@ insertafter: "^\\[{{ _group }}s\\]$" line: "{{ _ini_line }}" regexp: "^{{ _full_host_name | regex_escape() }} " + +- name: daniel debug + ansible.builtin.copy: + content: | + {{ _vm_type | default('vm_type') }} + {{ _std_group | default('std_group') }} + {{ _group | default('group') }} + {{ _ocp_name | default('ocp_name') }} + {{ _hostname | default('hostname') }} + {{ _ssh_user | default('sshuser') }} + {{ _add_ansible_host | default('add_ansible_host') }} + {{ _ansible_host | default('ansible_host') }} + {{ _full_host_name | default('fullhostname') }} + {{ _ini_line | default('ini_line') }} + dest: "{{ ansible_user_dir }}/{{ _ocp_name | default('test') }}" diff --git a/roles/libvirt_manager/tasks/generate_networking_data.yml b/roles/libvirt_manager/tasks/generate_networking_data.yml index ec393263a3..ac9f463105 100644 --- a/roles/libvirt_manager/tasks/generate_networking_data.yml +++ b/roles/libvirt_manager/tasks/generate_networking_data.yml @@ -142,11 +142,11 @@ -y --list > {{ cifmw_libvirt_manager_dst_inv_file }} ignore_errors: true # noqa: ignore-errors -- name: Remove ini file after conversion - when: _libvirt_inv_file.stat.exists - ansible.builtin.file: - path: "{{ cifmw_libvirt_manager_tmp_inv_file }}" - state: absent +#- name: Remove ini file after conversion +# when: _libvirt_inv_file.stat.exists +# ansible.builtin.file: +# path: "{{ cifmw_libvirt_manager_tmp_inv_file }}" +# state: absent - name: Generate all IPs based on MAC and networks vars: diff --git a/roles/reproducer/README.md b/roles/reproducer/README.md index 084b4999dc..c3a9a98616 100644 --- a/roles/reproducer/README.md +++ b/roles/reproducer/README.md @@ -25,6 +25,9 @@ None * `cifmw_reproducer_supported_hypervisor_os`: (List) List of supported hypervisor operating systems and their minimum version. * `cifmw_reproducer_minimum_hardware_requirements`: (Dict) Define minimum hardware requirements for specific scenarios. Example below * `cifmw_reproducer_computes_rhos_release_args`: (String) Arguments to use when installing rhos-release repos on compute nodes. Not defined by default, and `cifmw_repo_setup_rhos_release_args` is used instead. +* `cifmw_reproducer_allow_one_ocp` (Bool) Allow to deploy OpenShift cluster just with one master node. + NOTE: When using devscript, remember to set `cifmw_devscripts_sno` to `true`, otherwise it would fail. + If you don't set `cifmw_devscripts_sno` to `true`, minimum value for `ocp` nodes is `2`. ### Advanced parameters Those parameters shouldn't be used, unless the user is able to understand potential issues in their environment. @@ -55,40 +58,4 @@ Please follow the [documentation about the overall "reproducer" feature](https:/ #### Local repositories on your laptop ```YAML local_home_dir: "{{ lookup('env', 'HOME') }}" -local_base_dir: "{{ local_home_dir }}/src/github.com/openstack-k8s-operators" -remote_base_dir: "/home/zuul/src/github.com/openstack-k8s-operators" -cifmw_reproducer_repositories: - - src: "{{ local_base_dir }}/ci-framework" - dest: "{{ remote_base_dir }}" - - src: "{{ local_base_dir }}/install_yamls" - dest: "{{ remote_base_dir }}" -``` -Notes: -* `ansible_user_dir` isn't really usable due to the use of `delegate_to` in order to sync those local repositories. -* You therefore really want to use absolute paths - while the `dest` may be relative with the use of a plain `rsync` command -#### Github code -```YAML -remote_base_dir: "/home/zuul/src/github.com/openstack-k8s-operators" -cifmw_reproducer_repositories: - # Fetch specific version - - src: "https://github.com/cjeanner/ci-framework" - dest: "{{ remote_base_dir }}/ci-framework" - version: some-version - # Fetch a pull-request and checkout the specific content - - src: "https://github.com/foo/install_yamls" - dest: "{{ remote_base_dir }}/install_yamls" - refspec: pull/510/head:my-patch - version: my-patch - # Just get HEAD - - src: "https://github.com/openstack-k8s-operators/openstack-operators" - dest: "{{ remote_base_dir }}/openstack-operators" -``` - -#### Example `cifmw_reproducer_minimum_hardware_requirements`: -```YAML -cifmw_reproducer_minimum_hardware_requirements: - vcpu: 16 - memory: "32 GB" - disk: "200 GB" -``` diff --git a/roles/reproducer/defaults/main.yml b/roles/reproducer/defaults/main.yml index 63f059552d..3e7eff1b51 100644 --- a/roles/reproducer/defaults/main.yml +++ b/roles/reproducer/defaults/main.yml @@ -67,3 +67,5 @@ cifmw_reproducer_ironic_node_name_prefix: # switch_id: "22:57:f8:dd:04:02" # port_id: "ethernet1/2" cifmw_reproducer_ironic_local_link_connections: {} + +cifmw_reproducer_allow_one_ocp: false diff --git a/roles/reproducer/tasks/ocp_layout_assertions.yml b/roles/reproducer/tasks/ocp_layout_assertions.yml index d48736bc42..5629977e32 100644 --- a/roles/reproducer/tasks/ocp_layout_assertions.yml +++ b/roles/reproducer/tasks/ocp_layout_assertions.yml @@ -51,12 +51,13 @@ - _element.disksize is defined - _element.disksize | int > _disk - _element.amount is defined - - _element.amount >= _min_ocp + - _element.amount >= _min_ocp or cifmw_reproducer_allow_one_ocp quiet: true msg: >- Ensure you provide enough memory (>=16), cpus (>=10) and disksize (>50) to ocp nodes, set a correct amount (>=3) - and uefi is set to true in cifmw_libvirt_manager.vms.ocp + or set local setup (cifmw_reproducer_allow_one_ocp) and + uefi is set to true in cifmw_libvirt_manager.vms.ocp - name: Ensure we have needed data for ocp_worker if defined when: diff --git a/scenarios/reproducers/va-hci-minimal-sno.yml b/scenarios/reproducers/va-hci-minimal-sno.yml new file mode 100644 index 0000000000..b8eec845ed --- /dev/null +++ b/scenarios/reproducers/va-hci-minimal-sno.yml @@ -0,0 +1,131 @@ +--- +cifmw_parent_scenario: "scenarios/reproducers/va-hci-base.yml" + +cifmw_devscripts_sno: true +cifmw_reproducer_allow_one_ocp: true +# Time for "killing" metal3 bootstrap script, because +# it would not finish itself (workaround needed). +# Check 07-sno-workaround.sh provided by +# roles/devscripts/tasks/main.yml play. +cifmw_devscripts_sno_bootstrap_timeout: 1800 + +# HERE if you want to override kustomization, you can uncomment this parameter +# and push the data structure you want to apply. +# cifmw_architecture_user_kustomize: +# stage_0: +# 'network-values': +# data: +# starwars: Obiwan + +# HERE, if you want to stop the deployment loop at any stage, you can uncomment +# the following parameter and update the value to match the stage you want to +# reach. Known stages are: +# pre_kustomize_stage_INDEX +# pre_apply_stage_INDEX +# post_apply_stage_INDEX +# +# cifmw_deploy_architecture_stopper: + +cifmw_libvirt_manager_configuration: + # NOTE: Important not to add '' into 'ocpbm' network. + networks: + osp_trunk: | + + osp_trunk + + + + + + ocpbm: | + + ocpbm + + + + + + ocppr: | + + ocppr + + + + vms: + # https://github.com/openshift-metal3/dev-scripts/blob/master/common.sh#L470 + ocp: + amount: 1 + admin_user: core + image_local_dir: "{{ cifmw_basedir }}/images/" + disk_file_name: "ocp_master" + disksize: "100" + extra_disks_num: 3 + extra_disks_size: "50G" + cpus: 16 + memory: 32 + root_part_id: 4 + uefi: true + nets: + - ocppr + - ocpbm + - osp_trunk + compute: + uefi: "{{ cifmw_use_uefi }}" + root_part_id: "{{ cifmw_root_partition_id }}" + amount: "{{ [cifmw_libvirt_manager_compute_amount|int, 3] | max }}" + image_url: "{{ cifmw_discovered_image_url }}" + sha256_image_name: "{{ cifmw_discovered_hash }}" + image_local_dir: "{{ cifmw_basedir }}/images/" + disk_file_name: "base-os.qcow2" + disksize: "{{ [cifmw_libvirt_manager_compute_disksize|int, 50] | max }}" + memory: "{{ [cifmw_libvirt_manager_compute_memory|int, 8] | max }}" + cpus: "{{ [cifmw_libvirt_manager_compute_cpus|int, 4] | max }}" + extra_disks_num: 3 + extra_disks_size: 30G + nets: + - ocpbm + - osp_trunk + controller: + uefi: "{{ cifmw_use_uefi }}" + root_part_id: "{{ cifmw_root_partition_id }}" + image_url: "{{ cifmw_discovered_image_url }}" + sha256_image_name: "{{ cifmw_discovered_hash }}" + image_local_dir: "{{ cifmw_basedir }}/images/" + disk_file_name: "base-os.qcow2" + disksize: 50 + memory: 8 + cpus: 4 + nets: + - ocpbm + - osp_trunk + +## devscript support for OCP deploy +cifmw_devscripts_config_overrides: + fips_mode: "{{ cifmw_fips_enabled | default(false) | bool }}" + num_masters: 1 + +# Note: with that extra_network_names "osp_trunk", we instruct +# devscripts role to create a new network, and associate it to +# the OCP nodes. This one is a "private network", and will hold +# the VLANs used for network isolation. + +# Please create a custom env file to provide: +# cifmw_devscripts_ci_token: +# cifmw_devscripts_pull_secret: + +# Test Ceph file and object storage (block is enabled by default) +cifmw_ceph_daemons_layout: + rgw_enabled: true + dashboard_enabled: false + cephfs_enabled: true + ceph_nfs_enabled: false + +# Vars related to update_containers cinder volume and manila share +cifmw_update_containers_cindervolumes: + - ceph +cifmw_update_containers_manilashares: + - share1