Inject log-driver for podman containers

Currently, docker daemon runtime has a default --log-driver set
to journald.
Podman lack of daemon prevent such a global application, meaning
we have to set that driver for each and every container when we
either create or run them.

Notes:
- podman only supports "json-file", and it's not even a json.
- docker json-file doesn't support "path" option, making this output
  unusable in the end: logs end in
  /var/lib/docker/containers/ID/ID-json.log

Related-Bug: #1814897
Change-Id: Ia613fc3812aa34376c3fe64c21abfed51cfc9cab
This commit is contained in:
Cédric Jeanneret 2019-02-06 14:40:08 +01:00
parent 94203f0447
commit edfe180634
2 changed files with 13 additions and 0 deletions

View File

@ -29,6 +29,13 @@
selevel: s0
tags:
- host_config
- name: Create /var/log/containers/stdouts directory
file:
path: /var/log/containers/stdouts
state: directory
selevel: s0
tags:
- host_config
- name: Create /var/lib/tripleo-config directory
file:
path: /var/lib/tripleo-config

View File

@ -409,6 +409,7 @@ def mp_puppet_config(*args):
'--env', 'NO_ARCHIVE=%s' % os.environ.get('NO_ARCHIVE', ''),
'--env', 'STEP=%s' % os.environ.get('STEP', '6'),
'--env', 'NET_HOST=%s' % os.environ.get('NET_HOST', 'false'),
'--log-driver', 'json-file',
'--volume', '/etc/localtime:/etc/localtime:ro',
'--volume', '%s:/etc/config.pp:ro' % tmp_man.name,
'--volume', '/etc/puppet/:/tmp/puppet-etc/:ro',
@ -423,6 +424,11 @@ def mp_puppet_config(*args):
if privileged:
common_dcmd.push('--privileged')
if container_cli == 'podman':
logging = ['--log-opt',
'path=/var/log/containers/stdouts/%s.log' % uname]
common_dcmd.extend(logging)
dcmd = common_dcmd + cli_dcmd