-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an additional fail condition and make the fail_msg more verbose Update the container tests to use elevated permissions
- Loading branch information
1 parent
1b4cea6
commit cbb561e
Showing
1 changed file
with
9 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,24 @@ | ||
--- | ||
# The containers are run by root, so need to become true | ||
- name: Get container status | ||
become: true | ||
ansible.builtin.shell: | ||
cmd: | | ||
podman ps -a --format "{{ '{{.Names}} {{.Status}}' }}" | grep {{ container_name }} | ||
changed_when: false | ||
register: container_status | ||
|
||
# NOTE: leaving the existing fail message to get the status and see if it is okay | ||
- name: | | ||
TEST Verify {{ container_name }} container status | ||
{{ common_container_test_id }} | ||
ansible.builtin.assert: | ||
that: | ||
- "container_status.stdout | length != 0" | ||
- "'unhealthy' not in container_status.stdout" | ||
success_msg: "Container '{{ container_name }}' is in 'healthy' status." | ||
fail_msg: "Container '{{ container_name }}' is not in 'healthy' status. Current status: {{ container_status.stdout }}" | ||
fail_msg: | | ||
Container does not meet the required conditions: | ||
{%- if container_status.stdout | length == 0 %}Container name did not match any existing containers;{% endif %} | ||
{%- if "unhealthy" in container_status.stdout %}Container status is unhealthy;{% endif %} | ||
Container '{{ container_name }}' is not in 'healthy' status. Current status: {{ container_status.stdout }} |