From a6572bacb2c8596aacca4bfc57fba4ce84ea2c38 Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Fri, 12 Apr 2024 09:47:45 +0100 Subject: [PATCH] Support building docker-rally image in tempest playbook --- ansible/kayobe-automation-run-tempest.yml | 37 +++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/ansible/kayobe-automation-run-tempest.yml b/ansible/kayobe-automation-run-tempest.yml index b77b6ed..01c04c4 100644 --- a/ansible/kayobe-automation-run-tempest.yml +++ b/ansible/kayobe-automation-run-tempest.yml @@ -14,6 +14,10 @@ rally_docker_registry: ghcr.io rally_docker_registry_username: rally_docker_registry_password: + # Set to true to build the docker-rally image locally. + docker_rally_build: false + docker_rally_src_repo: https://github.com/stackhpc/docker-rally + docker_rally_src_version: HEAD load_list_path_remote: "{{ results_path_remote.path }}/tempest-load-list" skip_list_path_remote: "{{ results_path_remote.path }}/tempest-skip-list" accounts_path_remote: "{{ results_path_remote.path }}/tempest-accounts" @@ -45,6 +49,32 @@ - rally_docker_registry_password is not none become: true + - when: docker_rally_build | bool + block: + - name: Create temporary source directory + ansible.builtin.tempfile: + state: directory + suffix: docker-rally + register: src_path_remote + + - name: Clone docker-rally repository + git: + depth: 1 + dest: "{{ src_path_remote.path }}" + repo: "{{ docker_rally_src_repo }}" + single_branch: true + version: "{{ docker_rally_src_version }}" + + - name: Ensure rally image exists on runner + docker_image: + build: + path: "{{ src_path_remote.path }}" + name: "{{ rally_image_full }}" + network: host + state: present + source: build + become: true + - name: Ensure rally image exists on runner docker_image: name: "{{ rally_image_full }}" @@ -52,6 +82,7 @@ force_source: "{{ rally_force_pull | bool }}" source: pull become: true + when: not docker_rally_build | bool - name: Copy tempest load list to remote host copy: @@ -148,3 +179,9 @@ path: "{{ results_path_remote.path }}" state: absent when: results_path_remote.path is defined + + - name: cleanup source + file: + path: "{{ src_path_remote.path }}" + state: absent + when: src_path_remote.path is defined