Jonathan Rosser 51a254943f Add role to install and run sonobouy k8s validation tests
Change-Id: Ic5af3ec8f8553f54f95e945a91068873f02d1d1a
2024-02-12 21:38:31 +00:00

47 lines
1.6 KiB
YAML

# Copyright (c) 2024 BBC R&D.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
- name: Create dir to hold kubeconfig
ansible.builtin.file:
state: directory
path: "{{ sonobuoy_kubeconfig_file | dirname }}"
- name: Retrieve kubeconfig
vars:
ansible_python_interpreter: "{{ openstack_service_setup_host_python_interpreter }}"
ansible.builtin.command:
cmd: openstack coe cluster config --dir "{{ sonobuoy_kubeconfig_file | dirname }}" "{{ sonobuoy_coe_cluster }}"
creates: "{{ sonobuoy_kubeconfig_file }}"
environment:
OS_CLOUD: default
- name: Run sonobuoy tests
when: sonobuoy_run
environment:
KUBECONFIG: "{{ sonobuoy_kubeconfig_file }}"
block:
- name: Execute tests
ansible.builtin.shell:
cmd: "{{ sonobuoy_unarchive_dest ~ '/sonobuoy run ' ~ sonobuoy_run_options }}"
- name: Get sonobuoy results
ansible.builtin.command:
cmd: "{{ sonobuoy_unarchive_dest ~ '/sonobuoy retrieve' }}"
register: _retrieve
- name: Cleanup
ansible.builtin.command:
cmd: "{{ sonobuoy_unarchive_dest ~ '/sonobuoy delete --wait' }}"
when: sonobuoy_delete