694241ad77
This started with me wondering why gerritbot was putting all its output into /var/log/syslog -- it turns out Xenial docker is configured to use journalctl (which forwards to syslog) and Bionic onwards uses json-file. Both are sub-optimial; but particularly the json-file because we lose the logs when the container dies. This proposes moving to a more standard model of having the containers log to syslog and redirecting that to files on disk. Install a rsyslog configuration to capture "docker-*" program names and put them into logfiles in /var/log/containers. Also install rotation for these files. In an initial group of docker-compose files, setup logging to syslog which should then be captured into these files. Add some basic testing. If this works OK, I think we can standardise our docker-compose files like this to caputure the logs the same everywhere. Change-Id: I940a5b05057e832e2efad79d9a2ed5325020ed0c
70 lines
1.5 KiB
YAML
70 lines
1.5 KiB
YAML
- name: Create docker directory
|
|
become: yes
|
|
file:
|
|
state: directory
|
|
path: /etc/docker
|
|
|
|
- name: Install docker-ce from upstream
|
|
include: upstream.yaml
|
|
when: use_upstream_docker|bool
|
|
|
|
- name: Install docker-engine from distro
|
|
include: distro.yaml
|
|
when: not use_upstream_docker|bool
|
|
|
|
- name: reset ssh connection to pick up docker group
|
|
meta: reset_connection
|
|
|
|
# We install docker-compose from pypi to get features like
|
|
# stop_grace_period.
|
|
|
|
# On arm64 we need build-essential, python3-dev, libffi-dev, and libssl-dev
|
|
# because wheels don't exist for all the things on arm64
|
|
|
|
- name: Install arm64 dev pacakges
|
|
when: ansible_architecture == 'aarch64'
|
|
package:
|
|
name:
|
|
- build-essential
|
|
- python3-dev
|
|
- libffi-dev
|
|
- libssl-dev
|
|
state: present
|
|
|
|
- name: ensure pip3 is installed
|
|
include_role:
|
|
name: pip3
|
|
|
|
- name: Install docker-compose
|
|
pip:
|
|
name: docker-compose
|
|
state: present
|
|
executable: pip3
|
|
|
|
- name: Install rsyslog redirector for container tags
|
|
copy:
|
|
src: '98-docker.conf'
|
|
dest: /etc/rsyslog.d/
|
|
owner: root
|
|
group: root
|
|
mode: 0644
|
|
notify:
|
|
- Restart rsyslog
|
|
|
|
- name: Ensure rsyslog restarted now
|
|
meta: flush_handlers
|
|
|
|
- name: Create container log directories
|
|
file:
|
|
state: directory
|
|
path: /var/log/containers/
|
|
owner: syslog
|
|
group: adm
|
|
mode: 0775
|
|
|
|
- name: Install log rotation for docker files
|
|
include_role:
|
|
name: logrotate
|
|
vars:
|
|
logrotate_file_name: '/var/log/containers/*.log'
|