Skip to content

Commit

Permalink
Enable zuul builds
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Berendt <[email protected]>
  • Loading branch information
berendt committed Dec 13, 2023
1 parent ec0493c commit 5d3f4f3
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 70 deletions.
21 changes: 17 additions & 4 deletions .zuul.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -13,17 +15,28 @@
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

- project:
merge-mode: squash-merge
default-branch: main
check:
jobs:
- flake8
- yamllint
gate:
jobs:
- flake8
- yamllint
- k8s-capi-images-build-126
- k8s-capi-images-build-127
- k8s-capi-images-build-128
periodic-daily:
jobs:
- flake8
Expand Down
19 changes: 10 additions & 9 deletions playbooks/build.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 }}
86 changes: 29 additions & 57 deletions playbooks/pre.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,48 @@
---
- 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
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;
sudo apt-get update
sudo apt-get install -y \
curl \
git \
jq \
libguestfs-tools \
make \
patch \
python3-pip \
qemu-kvm \
software-properties-common \
unzip
sudo apt-add-repository --yes --update ppa:ansible/ansible
sudo apt-get install -y ansible
Expand All @@ -41,45 +52,6 @@
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
Expand Down

0 comments on commit 5d3f4f3

Please sign in to comment.