diff --git a/roles/common/README.md b/roles/common/README.md index 7b06b9be..27545d40 100644 --- a/roles/common/README.md +++ b/roles/common/README.md @@ -106,7 +106,6 @@ For cr\_tests.yml tasks: - polarion ID number for each test of readiness of the CR - Dependencies ------------ diff --git a/roles/common/defaults/main.yml b/roles/common/defaults/main.yml new file mode 100644 index 00000000..28cf403f --- /dev/null +++ b/roles/common/defaults/main.yml @@ -0,0 +1,2 @@ +--- +# defaults file for roles/common diff --git a/roles/common/tasks/container_status.yml b/roles/common/tasks/container_status.yml new file mode 100644 index 00000000..72c96c88 --- /dev/null +++ b/roles/common/tasks/container_status.yml @@ -0,0 +1,13 @@ +--- +- name: "[TEST] verify container status" + ansible.builtin.shell: + cmd: | + podman ps -a --format "{{ '{{.Names}} {{.Status}}' }}" | grep "{{ container_name }}" | awk '{print $2}' + changed_when: false + register: container_status + +- name: Fail if container is not 'Up' + ansible.builtin.fail: + msg: "Container '{{ container_name }}' is not in 'Up' status. Current status: {{ container_status.stdout }}" + when: + - "'Up' not in container_status.stdout" \ No newline at end of file diff --git a/roles/common/tasks/service_tests.yml b/roles/common/tasks/service_tests.yml index a6505d66..3c23e45a 100644 --- a/roles/common/tasks/service_tests.yml +++ b/roles/common/tasks/service_tests.yml @@ -13,4 +13,4 @@ that: - "'NotFound' not in output.stderr" success_msg: "service {{ item }} is running." - fail_msg: "service {{ item }} not running. Error: {{ output.stderr }}" \ No newline at end of file + fail_msg: "service {{ item }} not running. Error: {{ output.stderr }}" diff --git a/roles/common/vars/main.yml b/roles/common/vars/main.yml new file mode 100644 index 00000000..f83eed77 --- /dev/null +++ b/roles/common/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for roles/common