From 5f013deb7b83734c2101328b256626c64cd43134 Mon Sep 17 00:00:00 2001 From: Itay Matza Date: Thu, 22 May 2025 14:45:20 +0300 Subject: [PATCH] Update CentOS repos and modernize shell/Python syntax - Update base container from CentOS 7 to CentOS Stream 8 - Fix CentOS repository mirrors by switching to vault.centos.org - Replace 'source' with '.' for POSIX shell compatibility - Update Python venv creation to use 'python3 -m venv' syntax - Change instackenv.json URLs from /cloud/ to /instack/ - Add certificate validation bypass for scale lab downloads - Add foreman CLI tools to hammer container --- Dockerfile | 26 ++++++++++++++++++++------ browbeat.yml | 6 +++--- hammer/Dockerfile | 3 +++ introspect.yml | 4 ++-- overcloud.yml | 2 +- scale_compute_vms.yml | 2 +- scale_compute_vms_deploy.yml | 2 +- tag.yml | 2 +- tasks/load_instackenv.yml | 5 +++-- tasks/setup_infrared.yml | 6 +++--- undercloud.yml | 4 ++-- virtual_undercloud.yml | 4 ++-- 12 files changed, 42 insertions(+), 24 deletions(-) diff --git a/Dockerfile b/Dockerfile index 7162db69..3a736548 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,9 +1,23 @@ -FROM centos:7 +FROM quay.io/centos/centos:stream8 -RUN yum -y install git -RUN yum -y install epel-release -RUN yum -y install ansible +ARG foreman_url=https://foreman.example.com -RUN git clone https://github.com/redhat-performance/jetpack.git +RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-* +RUN sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-* -ENTRYPOINT ansible-playbook jetpack/main.yml +RUN dnf install -y epel-release \ + python3 + +RUN dnf install -y --skip-broken https://yum.theforeman.org/releases/2.1/el8/x86_64/foreman-release.rpm \ + https://yum.theforeman.org/releases/2.1/el8/x86_64/rubygem-hammer_cli-2.1.0-1.el8.noarch.rpm \ + http://yum.theforeman.org/releases/2.1/el8/x86_64/rubygem-hammer_cli_foreman-2.1.0-2.el8.noarch.rpm + +RUN dnf install -y rubygem-hammer_cli \ + rubygem-hammer_cli_foreman + +RUN pip3 install j2cli + +RUN hammer --fetch-ca-cert ${foreman_url} + +COPY foreman.yml.j2 /root/ +RUN j2 /root/foreman.yml.j2 > /etc/hammer/cli.modules.d/foreman.yml diff --git a/browbeat.yml b/browbeat.yml index 30909aa8..6205188e 100644 --- a/browbeat.yml +++ b/browbeat.yml @@ -18,18 +18,18 @@ sed -i 's/dns_server: 8.8.8.8/dns_server: {{ dns_server.stdout }}/g' {{ browbeat_dir }}/ansible/install/group_vars/all.yml - name: generate hosts file shell: | - source /home/stack/stackrc + . /home/stack/stackrc ./generate_tripleo_inventory.sh -l args: chdir: "{{ browbeat_dir }}/ansible" - name: install browbeat shell: | - source /home/stack/.bash_profile + . /home/stack/.bash_profile ansible-playbook -i hosts.yml install/browbeat.yml args: chdir: "{{ browbeat_dir }}/ansible" - name: Activate virtualenv to run tests shell: | - source .browbeat-venv/bin/activate + . .browbeat-venv/bin/activate args: chdir: "{{ browbeat_dir }}" diff --git a/hammer/Dockerfile b/hammer/Dockerfile index 100a5890..3a736548 100644 --- a/hammer/Dockerfile +++ b/hammer/Dockerfile @@ -2,6 +2,9 @@ FROM quay.io/centos/centos:stream8 ARG foreman_url=https://foreman.example.com +RUN sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-* +RUN sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-* + RUN dnf install -y epel-release \ python3 diff --git a/introspect.yml b/introspect.yml index fc70a055..5884b7b9 100644 --- a/introspect.yml +++ b/introspect.yml @@ -14,7 +14,7 @@ - block: - name: run tripleo-overcloud introspection shell: | - source .venv/bin/activate + . .venv/bin/activate infrared tripleo-overcloud -vvv --version {{ osp_release }} {{ custom_instackenv | default('') }} --deployment-files {{ nic_configs }} --introspect yes {{ hybrid_params | default('') }} > {{ log_directory }}/overcloud_introspect.log 2>&1 args: chdir: "{{ infrared_dir }}" @@ -27,7 +27,7 @@ - block: - name: run tripleo-overcloud introspection shell: | - source .venv/bin/activate + . .venv/bin/activate infrared tripleo-overcloud -vvv --version {{ osp_release }} {{ custom_instackenv | default('') }} --deployment-files {{ nic_configs }} --introspect yes {{ hybrid_params | default('') }} > {{ log_directory }}/overcloud_introspect.log 2>&1 args: chdir: "{{ infrared_dir }}" diff --git a/overcloud.yml b/overcloud.yml index 9f04bf27..4aab862e 100644 --- a/overcloud.yml +++ b/overcloud.yml @@ -353,7 +353,7 @@ - name: run tripleo-overcloud deploy shell: | - source .venv/bin/activate + . .venv/bin/activate infrared tripleo-overcloud -vvv --version {{ osp_release }} --deployment-timeout {{ deployment_timeout | default(240) }} --build {{ osp_puddle }} --deployment-files {{ nic_configs }} --introspect no --tagging no --deploy yes --controller-nodes {{ controller_count }} --compute-nodes {{ compute_count }} --storage-nodes {{ ceph_node_count }} --overcloud-image-name full {{ oc_extra_templates }} {{ dvr_params | default('') }} --network-protocol ipv4 --network-backend {{ network_backend }} {{ network_type }} true {{ ceph_params | default('') }} {{ storage_protocol_backend | default('') }} --ntp-server {{ gateway }} --public-network false {{ oc_heat_configs | default('') }} {{ oc_config_resource | default('') }} > {{ log_directory }}/overcloud_deploy.log 2>&1 args: chdir: "{{ infrared_dir }}" diff --git a/scale_compute_vms.yml b/scale_compute_vms.yml index cfa08a08..a5b21663 100644 --- a/scale_compute_vms.yml +++ b/scale_compute_vms.yml @@ -109,7 +109,7 @@ - name: run virsh for multi hypervisor shell: | - source .venv/bin/activate + . .venv/bin/activate infrared virsh {{ host_address }} --host-key {{ ansible_ssh_key }} --topology-nodes compute:{{ compute_count|default(1) }} --topology-network {{ topology_network_path }} --host-memory-overcommit True > {{ log_directory }}/virsh.log 2>&1 args: chdir: "{{ infrared_dir }}" diff --git a/scale_compute_vms_deploy.yml b/scale_compute_vms_deploy.yml index 196b6581..765f54fd 100644 --- a/scale_compute_vms_deploy.yml +++ b/scale_compute_vms_deploy.yml @@ -41,7 +41,7 @@ - name: run virsh for multi hypervisor shell: | - source .venv/bin/activate + . .venv/bin/activate echo infrared virsh {{ host_address }} --host-key {{ ansible_ssh_key }} --topology-nodes compute:{{ compute_count|default(1) }} --topology-network {{ topology_network_path }} --host-memory-overcommit True > {{ log_directory }}/virsh.log 2>&1 args: chdir: "{{ infrared_dir }}" diff --git a/tag.yml b/tag.yml index 89594599..be1f1b48 100644 --- a/tag.yml +++ b/tag.yml @@ -19,7 +19,7 @@ - name: run tripleo-overcloud tagging shell: | - source .venv/bin/activate + . .venv/bin/activate infrared tripleo-overcloud -vvv --version {{ osp_release }} --deployment-files {{ nic_configs }} --introspect no --tagging yes > {{ log_directory }}/overcloud_tagging.log 2>&1 args: chdir: "{{ infrared_dir }}" diff --git a/tasks/load_instackenv.yml b/tasks/load_instackenv.yml index fa5cacfe..04da5634 100644 --- a/tasks/load_instackenv.yml +++ b/tasks/load_instackenv.yml @@ -10,7 +10,7 @@ - name: Download instackenv.json get_url: - url: "{{ alias.lab_url }}/cloud/{{ cloud_name }}_instackenv.json" + url: "{{ alias.lab_url }}/instack/{{ cloud_name }}_instackenv.json" dest: "{{ instackenv_file }}" mode: '0644' force: yes @@ -18,10 +18,11 @@ - name: Download instackenv.json get_url: - url: "{{ scale.lab_url }}/cloud/{{ cloud_name }}_instackenv.json" + url: "{{ scale.lab_url }}/instack/{{ cloud_name }}_instackenv.json" dest: "{{ instackenv_file }}" mode: '0644' force: yes + validate_certs: no when: st.stat.exists == False and lab_name == "scale" - name: remove the name field from instackenv diff --git a/tasks/setup_infrared.yml b/tasks/setup_infrared.yml index e40257ca..56e2f029 100644 --- a/tasks/setup_infrared.yml +++ b/tasks/setup_infrared.yml @@ -14,7 +14,7 @@ - name: infrared setup shell: | - virtualenv --python=python3 .venv && source .venv/bin/activate + python3 -m venv .venv && . .venv/bin/activate pip install --upgrade pip pip install --upgrade setuptools pip install . @@ -24,7 +24,7 @@ changed_when: false - name: add infrared plugins - shell: source .venv/bin/activate && infrared plugin add all + shell: . .venv/bin/activate && infrared plugin add all args: chdir: "{{ infrared_dir }}" register: plugin_add @@ -35,7 +35,7 @@ - name: Create infrared workspace shell: | - source .venv/bin/activate + . .venv/bin/activate infrared workspace create {{ workspace_name }} infrared workspace checkout {{ workspace_name }} args: diff --git a/undercloud.yml b/undercloud.yml index 59712c8a..7cf0aabb 100644 --- a/undercloud.yml +++ b/undercloud.yml @@ -83,7 +83,7 @@ when: osp_release|int < 17 - name: run tripleo-undercloud for osp17 shell: | - source {{ infrared_dir }}/.venv/bin/activate + . {{ infrared_dir }}/.venv/bin/activate infrared tripleo-undercloud -vv \ --version {{ osp_release }} \ --build {{ osp_puddle }} \ @@ -98,7 +98,7 @@ - name: Run the undercloud-ipa-install.yml playbook shell: | - source /home/stack/.bash_profile + . /home/stack/.bash_profile ansible-playbook --ssh-extra-args "-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" /usr/share/ansible/tripleo-playbooks/undercloud-ipa-install.yaml when: tls_everywhere == true delegate_to: undercloud diff --git a/virtual_undercloud.yml b/virtual_undercloud.yml index 2ffc4202..a7b0a221 100644 --- a/virtual_undercloud.yml +++ b/virtual_undercloud.yml @@ -22,14 +22,14 @@ - name: clean previous vm shell: | - source {{ infrared_dir }}/.venv/bin/activate + . {{ infrared_dir }}/.venv/bin/activate infrared virsh --host-address 127.0.0.1 --host-key /root/.ssh/id_rsa --image-url '{{ image_url }}' --topology-network virtual_uc_network --topology-nodes virtual_uc_topology:1 --host-memory-overcommit True --cleanup True retries: 3 ignore_errors: yes - name: create undercloud vm shell: | - source {{ infrared_dir }}/.venv/bin/activate + . {{ infrared_dir }}/.venv/bin/activate infrared virsh --host-address 127.0.0.1 --host-key /root/.ssh/id_rsa --image-url '{{ image_url }}' --topology-network virtual_uc_network --topology-nodes virtual_uc_topology:1 --host-memory-overcommit True -vvv 2>&1 | tee log_virsh1