diff --git a/roles/update/README.md b/roles/update/README.md index 97f1fc1d9c..45a90e7a79 100644 --- a/roles/update/README.md +++ b/roles/update/README.md @@ -21,5 +21,6 @@ Role to run update * `cifmw_update_ansible_ssh_private_key_file`: (String) Define the path to the private key file used for the compute nodes. * `cifmw_update_wait_retries_reboot`: (Integer) Number of retries to wait for a compute node reboot. One retry is done every five seconds. Default to 60, so five minutes. * `cifmw_update_resources_monitoring_interval`: (Integer) Interval, in seconds, between two resources monitor during update. Default to 10 seconds. +* `cifmw_update_dont_cleanup`: (Bool) By default we cleanup the resources created on OpenStack during testing. Setting this parameter to `true` prevents it. Useful for debugging. Default to `false`. ## Examples diff --git a/roles/update/defaults/main.yml b/roles/update/defaults/main.yml index 384f47cc07..e86b2fade1 100644 --- a/roles/update/defaults/main.yml +++ b/roles/update/defaults/main.yml @@ -48,6 +48,7 @@ cifmw_update_openstack_cmd: >- oc rsh -n {{ cifmw_update_namespace }} openstackclient openstack ## User facing +cifmw_update_dont_cleanup: false cifmw_update_reboot_test: false cifmw_update_ansible_ssh_private_key_file: >- "{{ ansible_ssh_private_key_file | default(ansible_user_dir ~ '/.ssh/id_cifw') }}" diff --git a/roles/update/tasks/cleanup.yml b/roles/update/tasks/cleanup.yml index f64f70392c..5fb6a9891d 100644 --- a/roles/update/tasks/cleanup.yml +++ b/roles/update/tasks/cleanup.yml @@ -14,6 +14,19 @@ # License for the specific language governing permissions and limitations # under the License. -- name: Cleaning the World - ansible.builtin.debug: - msg: "So here update should clean things up!" +- name: Cleanup ping test resources + block: + - name: Cleaning the ping vm if needed + ansible.builtin.shell: | + set -e + set -o pipefail + cat {{ cifmw_update_workload_launch_script }} | \ + podman exec -i lopenstackclient env WKL_MODE=cleanup bash -i 2>&1 \ + {{ cifmw_update_timestamper_cmd }} | tee {{ cifmw_update_artifacts_basedir }}/workload_cleanup.log + + - name: Get logs from update instance creation + ansible.builtin.shell: > + podman cp lopenstackclient:{{ cifmw_update_artifacts_basedir_suffix }}/. + {{ cifmw_update_artifacts_basedir }} + when: + - cifmw_update_ping_test | bool diff --git a/roles/update/tasks/main.yml b/roles/update/tasks/main.yml index 627475977e..5e5b7c238d 100644 --- a/roles/update/tasks/main.yml +++ b/roles/update/tasks/main.yml @@ -208,3 +208,9 @@ cmd: > {{ cifmw_update_artifacts_basedir }}/update_event.sh Update complete + +- name: Cleanup ressources used for testing on OpenStack + ansible.builtin.include_tasks: cleanup.yml + when: + - not (cifmw_update_dont_cleanup | bool) + - not (cifmw_update_run_dryrun | bool)