Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .zuul.d/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
kaas: false
do_provision: false
do_cleanup: true
sonobuoy_tar_gz_url: >
https://github.com/vmware-tanzu/sonobuoy/releases/download/v0.57.3/sonobuoy_0.57.3_linux_amd64.tar.gz
Copy link
Contributor

@berendt berendt May 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do it this way:

Definition of sonobuoy_version : https://github.com/regiocloud/e2e-tests/blob/main/playbooks/gardener/pre.yml#L15 (this makes it easy to update the version with the help of e.g. Renovate).

wget and removal: https://github.com/regiocloud/e2e-tests/blob/main/playbooks/gardener/pre.yml#L58-L60

But I think it makes sense to have a sonobuoy_url like https://github.com/vmware-tanzu/sonobuoy/releases/download/v{{ sonobuoy_version }}/sonobuoy_{{ sonobuoy_version }}_linux_amd64.tar.gz here. This way it's easier to use a local mirror.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how Renovate works. Apart from that, specifying the full url gives you the highest degree of control, and you wouldn't even notice if they change the pattern somehow.

pre-run:
- playbooks/pre.yaml
- playbooks/pre_cloud.yaml
Expand Down
13 changes: 12 additions & 1 deletion Tests/kaas/sonobuoy_handler/sonobuoy_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import json
import logging
import os
import os.path
import shlex
import shutil
import subprocess
Expand All @@ -11,6 +12,16 @@
logger = logging.getLogger(__name__)


def _find_sonobuoy():
"""find sonobuoy in PATH, but also in a fixed location at ~/.local/bin to simplify use with Ansible"""
result = shutil.which('sonobuoy')
if result:
return result
result = os.path.join(os.path.expanduser('~'), '.local', 'bin', 'sonobuoy')
if os.path.exists(result):
return result


class SonobuoyHandler:
"""
A class that handles both the execution of sonobuoy and
Expand All @@ -34,7 +45,7 @@ def __init__(
self.kubeconfig_path = kubeconfig
self.working_directory = os.getcwd()
self.result_dir_name = result_dir_name
self.sonobuoy = shutil.which('sonobuoy')
self.sonobuoy = _find_sonobuoy()
logger.debug(f"working from {self.working_directory}")
logger.debug(f"placing results at {self.result_dir_name}")
logger.debug(f"sonobuoy executable at {self.sonobuoy}")
Expand Down
22 changes: 18 additions & 4 deletions playbooks/pre_cloud.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,29 +17,43 @@
requirements: "Tests/kaas/requirements.txt"
when: kaas | bool

- name: Create local binary dir
ansible.builtin.file:
path: "{{ ansible_user_dir}}/.local/bin"
state: directory
recurse: true

- name: Install Sonobuoy
ansible.builtin.shell:
curl -L {{ sonobuoy_tar_gz_url | trim | quote }} | tar xz sonobuoy
args:
chdir: "{{ ansible_user_dir}}/.local/bin/"
creates: sonobuoy
when: kaas | bool

- name: Create cloud config dir
ansible.builtin.file:
path: "~/.config/openstack"
path: "{{ ansible_user_dir }}/.config/openstack"
state: directory
recurse: true
mode: "0700"

- name: Create cloud config file
ansible.builtin.template:
src: "clouds.yaml.j2"
dest: "~/.config/openstack/clouds.yaml"
dest: "{{ ansible_user_dir }}/.config/openstack/clouds.yaml"
mode: "0600"
no_log: true

- name: Create cluster config dir
ansible.builtin.copy:
src: ".config"
dest: "~/"
dest: "{{ ansible_user_dir }}/"

- name: Create cluster config file
ansible.builtin.template:
src: "clusters.yaml.j2"
dest: "~/.config/scs/clusters.yaml"
dest: "{{ ansible_user_dir }}/.config/scs/clusters.yaml"
mode: "0600"
no_log: true

Expand Down