diff --git a/roles/collect-container-logs/tasks/main.yaml b/roles/collect-container-logs/tasks/main.yaml index c1cea7541..c2a612620 100644 --- a/roles/collect-container-logs/tasks/main.yaml +++ b/roles/collect-container-logs/tasks/main.yaml @@ -1,14 +1,14 @@ -- name: List containers - command: "{{ container_command }} ps -a --format '{{ '{{ .Names }}' }}'" - register: docker_containers - failed_when: false - - name: Create container log dir file: path: "{{ ansible_user_dir }}/zuul-output/logs/{{ container_command }}" state: directory mode: 0755 +- name: List containers + command: "{{ container_command }} ps -a --format '{{ '{{ .Names }}' }}'" + register: docker_containers + failed_when: false + - name: Save container logs loop: "{{ docker_containers.stdout_lines | default([]) }}" # We can't use the default 'item' because roles may be used in @@ -19,6 +19,7 @@ args: executable: /bin/bash failed_when: false + when: docker_containers.rc == 0 - name: Open container logs permissions file: