From e323dc117beb3dd8ee85d10fc6b60b4d1528b0ed Mon Sep 17 00:00:00 2001 From: Clark Boylan Date: Fri, 31 Jan 2020 15:13:43 -0800 Subject: [PATCH] Don't use item in collect container logs loop The default loop variable 'item' cannot be nested. Because roles like collect-container-logs may be called from higher level loops that use 'item' we override the loop control var to a name that should be unique. This should probably be done to all of the other roles in zuul-jobs too. Change-Id: I2f647596dd40c662aa7447e3d3c8844a77c6b109 --- roles/collect-container-logs/tasks/main.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/roles/collect-container-logs/tasks/main.yaml b/roles/collect-container-logs/tasks/main.yaml index ef7bc9607..65f2b4a23 100644 --- a/roles/collect-container-logs/tasks/main.yaml +++ b/roles/collect-container-logs/tasks/main.yaml @@ -10,7 +10,11 @@ - name: Save container logs loop: "{{ docker_containers.stdout_lines | default([]) }}" - shell: "{{ container_command }} logs {{ item }} &> {{ ansible_user_dir }}/zuul-output/logs/{{ container_command }}/{{ item }}.txt" + # We can't use the default 'item' because roles may be used in + # higher level loops and 'item' could conflict in that case. + loop_control: + loop_var: loop_container_name + shell: "{{ container_command }} logs {{ loop_container_name }} &> {{ ansible_user_dir }}/zuul-output/logs/{{ container_command }}/{{ loop_container_name }}.txt" args: executable: /bin/bash ignore_errors: true