From de82b9c7b85347a8bf1240b2caa816e5fc60f022 Mon Sep 17 00:00:00 2001 From: Christian Berendt Date: Fri, 15 Sep 2023 08:29:00 +0200 Subject: [PATCH] Enable zuul builds Signed-off-by: Christian Berendt --- .cirrus.yml | 81 --------------------------------------------- .zuul.yaml | 28 +++++++++++++--- playbooks/build.yml | 19 ++++++----- playbooks/pre.yml | 75 +++++++++++++++++------------------------ 4 files changed, 65 insertions(+), 138 deletions(-) delete mode 100644 .cirrus.yml diff --git a/.cirrus.yml b/.cirrus.yml deleted file mode 100644 index 59ee05c..0000000 --- a/.cirrus.yml +++ /dev/null @@ -1,81 +0,0 @@ ---- -# NOTE: That didn't work, thus use of instance with nested virtualization enabled. -# -# container: -# image: ubuntu:20.04 -# kvm: true - -compute_engine_instance: - image_project: cirrus-images - image: family/docker-kvm - platform: linux - cpu: 4 - memory: 16G - disk: 100 - nested_virtualization: true - -# environment variables - -env: - DEBIAN_FRONTEND: noninteractive - HOME: "$CIRRUS_WORKING_DIR" - PACKER_TMP_DIR: "$CIRRUS_WORKING_DIR/.packer.d" - MINIO_ACCESS_KEY: "ENCRYPTED[200d9115444ec47abe42a397594fe726c2f01e4f8394817c6ac6c1c3c2914d713c885b080c2992f9b7605dc6a848caba]" - MINIO_SECRET_KEY: "ENCRYPTED[f9bca5bdb6d905bb4fbbf3f64df81194ceb970c61917142c8eb74975ec357ffc30de73e4e6bea63b71e0da809bcdb815]" - -build_task_template: &BUILD_TASK_TEMPLATE - timeout_in: 120m - install_script: - - while fuser /var/lib/dpkg/lock >/dev/null 2>&1; do sleep 5; done; - - while fuser /var/lib/dpkg/lock-frontend >/dev/null 2>&1; do sleep 5; done; - - apt-get update - - apt-get install -y git make python3-pip curl jq unzip - - prepare_script: - - git clone https://github.com/kubernetes-sigs/image-builder - - cd image-builder/images/capi - - export PATH=$PWD/.bin:$HOME/.local/bin:$PATH - - make deps-qemu - - build_script: - - cd image-builder/images/capi - - export PATH=$PWD/.bin:$HOME/.local/bin:$PATH - - make build-qemu-ubuntu-2204 - - prepare_push_script: - - wget https://dl.min.io/client/mc/release/linux-amd64/mc - - chmod +x mc - - ./mc alias set minio https://swift.services.a.regiocloud.tech $MINIO_ACCESS_KEY $MINIO_SECRET_KEY - - cd image-builder/images/capi/output - - find . -type f -execdir bash -c 'x={}; cp $x ${x%.*}.qcow2; mv $x $x.qcow2' \; - - find . -type f -execdir bash -c 'x={}; virt-sparsify --in-place $x' \; - - find . -type f -execdir bash -c 'x={}; sha256sum $x > $x.CHECKSUM' \; - - du -h - - push_script: - - ./mc cp --recursive image-builder/images/capi/output/* minio/openstack-k8s-capi-images - - ./mc policy set download minio/openstack-k8s-capi-images - -build_126_task: - <<: *BUILD_TASK_TEMPLATE - skip: "!changesInclude('extra_vars_126.json')" - env: - PACKER_VAR_FILES: ../../../extra_vars_126.json - -build_127_task: - <<: *BUILD_TASK_TEMPLATE - skip: "!changesInclude('extra_vars_127.json')" - env: - PACKER_VAR_FILES: ../../../extra_vars_127.json - -build_128_task: - <<: *BUILD_TASK_TEMPLATE - skip: "!changesInclude('extra_vars_128.json')" - env: - PACKER_VAR_FILES: ../../../extra_vars_128.json - -build_129_task: - <<: *BUILD_TASK_TEMPLATE - skip: "!changesInclude('extra_vars_129.json')" - env: - PACKER_VAR_FILES: ../../../extra_vars_129.json diff --git a/.zuul.yaml b/.zuul.yaml index 255d4e9..f58d078 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -1,6 +1,8 @@ --- - job: name: k8s-capi-images-build + nodeset: ubuntu-jammy-large + abstract: true parent: base pre-run: playbooks/pre.yml run: playbooks/build.yml @@ -13,6 +15,24 @@ vars: kubernetes_version: 126 +- job: + name: k8s-capi-images-build-127 + parent: k8s-capi-images-build + vars: + kubernetes_version: 127 + +- job: + name: k8s-capi-images-build-128 + parent: k8s-capi-images-build + vars: + kubernetes_version: 128 + +- job: + name: k8s-capi-images-build-129 + parent: k8s-capi-images-build + vars: + kubernetes_version: 129 + - project: merge-mode: squash-merge default-branch: main @@ -20,10 +40,10 @@ jobs: - flake8 - yamllint - gate: - jobs: - - flake8 - - yamllint + - k8s-capi-images-build-126 + - k8s-capi-images-build-127 + - k8s-capi-images-build-128 + - k8s-capi-images-build-129 periodic-daily: jobs: - flake8 diff --git a/playbooks/build.yml b/playbooks/build.yml index 97853b0..87e9e6b 100644 --- a/playbooks/build.yml +++ b/playbooks/build.yml @@ -1,16 +1,14 @@ --- - name: Build image - # hosts: all - hosts: localhost + hosts: all connection: local vars: - distro: "{{ lookup('ansible.builtin.env', 'DISTRO', default='ubuntu') }}" - distro_version: "{{ lookup('ansible.builtin.env', 'DISTRO_VERSION', default='2204') }}" - extra_vars_openstack_directory: "{{ repo_path }}/osism/k8s-capi-images" - kubernetes_version: "{{ lookup('ansible.builtin.env', 'KUBERNETES_VERSION', default='124') }}" - repo_path: "{{ ansible_user_dir|default('~') }}/src/github.com" - working_directory: "{{ repo_path }}/kubernetes-sigs/image-builder/images/capi" + basepath: "{{ ansible_user_dir }}/src/github.com" + working_directory: "{{ basepath }}/kubernetes-sigs/image-builder/images/capi" + + distro: ubuntu + distro_version: 2204 tasks: - name: Run build script @@ -21,7 +19,10 @@ set -e set -x - export PACKER_VAR_FILES={{ extra_vars_openstack_directory }}/extra_vars_openstack_{{ distro }}_{{ kubernetes_version }}.json + pwd + ls -la + + export PACKER_VAR_FILES={{ basepath }}/osism/k8s-capi-images/extra_vars_{{ kubernetes_version }}.json export PATH=~/.local/bin:$PATH make build-qemu-{{ distro }}-{{ distro_version }} diff --git a/playbooks/pre.yml b/playbooks/pre.yml index 034c35d..b750bd1 100644 --- a/playbooks/pre.yml +++ b/playbooks/pre.yml @@ -1,17 +1,41 @@ --- -- name: Pre tasks - part 1 - # hosts: all - hosts: localhost - connection: local +- name: Pre play + hosts: all vars: + ppg_version: "3.1.4" + packer_version: "1.8.6" + working_directory: "{{ zuul.project.src_dir|default('~') }}" tasks: + - name: Install required packages + become: true + ansible.builtin.apt: + name: + - curl + - git + - jq + - libguestfs-tools + - make + - patch + - python3-pip + - qemu-kvm + - software-properties-common + - unzip + update_cache: true + + - name: Install packer + ansible.builtin.include_role: + name: ensure-packer + + - name: Install pip + ansible.builtin.include_role: + name: ensure-pip + - name: Run install script ansible.builtin.shell: executable: /bin/bash - chdir: "{{ working_directory }}" cmd: | set -e set -x @@ -32,51 +56,14 @@ software-properties-common \ unzip + sudo pip3 install ansible + sudo chmod 0777 /dev/kvm echo "Host *" | sudo tee /etc/ssh/ssh_config echo " PubkeyAcceptedAlgorithms +ssh-rsa" | sudo tee /etc/ssh/ssh_config echo " HostkeyAlgorithms +ssh-rsa" | sudo tee /etc/ssh/ssh_config - lsmod - - -# Only required by Zuul CI. -# -# - name: Pre roles -# hosts: all -# -# vars: -# install_packer: false -# install_pip: false -# -# roles: -# - role: ensure-packer -# vars: -# packer_version: "1.8.6" -# when: install_packer|bool -# -# - role: ensure-pip -# when: install_pip|bool - -- name: Pre tasks - part 2 - # hosts: all - hosts: localhost - connection: local - - vars: - ppg_version: "3.1.4" # packer-provisioner-goss - working_directory: "{{ zuul.project.src_dir|default('~') }}" - - tasks: - - name: Run install script - ansible.builtin.shell: - executable: /bin/bash - chdir: "{{ working_directory }}" - cmd: | - set -e - set -x - wget \ -O packer-provisioner-goss.zip \ https://github.com/YaleUniversity/packer-provisioner-goss/releases/download/v{{ ppg_version }}/packer-provisioner-goss-v{{ ppg_version }}-linux-amd64.zip