Grab container logs at the end of run-base

So that we automatically get container logs for future jobs
which use containers.

Change-Id: I329c67eefb8c6a2ff9a8ce8ef69cc844cef6012a
This commit is contained in:
James E. Blair 2019-01-31 09:25:46 -08:00
parent 22ad414a86
commit 8062f4c1ec
2 changed files with 27 additions and 0 deletions

View File

@ -344,6 +344,7 @@
copy_output:
'/var/log/syslog': logs_txt
'/var/log/messages': logs_txt
'/var/log/docker': logs
host-vars:
bridge.openstack.org:
host_copy_output:

View File

@ -16,6 +16,32 @@
- hosts: all
tasks:
- name: List containers
command: "docker ps -a --format '{{ '{{ .Names }}' }}'"
register: docker_containers
ignore_errors: true
become: true
- name: Create container log dir
file:
path: "/var/log/docker"
state: directory
become: true
- name: Save container logs
loop: "{{ docker_containers.stdout_lines | default([]) }}"
shell: "docker logs {{ item }} &> /var/log/docker/{{item}}.txt"
args:
executable: /bin/bash
become: true
- name: Open container logs permissions
file:
dest: /var/log/docker
mode: u=rwX,g=rX,o=rX
recurse: yes
become: yes
- include_role:
name: stage-output