1
0
Fork 0
mirror of https://github.com/containers/ansible-podman-collections.git synced 2026-04-09 10:57:13 +00:00

Fixes for podman_container for Podman v3 (#209)

Fix logs, networks, etc.
This commit is contained in:
Sergey 2021-02-24 07:52:30 +02:00 committed by GitHub
parent 9f45c40ea9
commit c4ba85f73c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 44 additions and 9 deletions

View file

@ -895,9 +895,16 @@ class PodmanContainerDiff:
# Parameter has limited idempotency, unable to guess the default log_path
def diffparam_log_opt(self):
before, after = {}, {}
# Log path
path_before = None
if 'logpath' in self.info:
path_before = self.info['logpath']
# For Podman v3
if ('logconfig' in self.info['hostconfig'] and
'path' in self.info['hostconfig']['logconfig']):
path_before = self.info['hostconfig']['logconfig']['path']
if path_before is not None:
if (self.module_params['log_opt'] and
'path' in self.module_params['log_opt'] and
self.module_params['log_opt']['path'] is not None):
@ -909,8 +916,14 @@ class PodmanContainerDiff:
after.update({'log-path': path_after})
# Log tag
tag_before = None
if 'logtag' in self.info:
tag_before = self.info['logtag']
# For Podman v3
if ('logconfig' in self.info['hostconfig'] and
'tag' in self.info['hostconfig']['logconfig']):
tag_before = self.info['hostconfig']['logconfig']['tag']
if tag_before is not None:
if (self.module_params['log_opt'] and
'tag' in self.module_params['log_opt'] and
self.module_params['log_opt']['tag'] is not None):
@ -921,6 +934,24 @@ class PodmanContainerDiff:
before.update({'log-tag': tag_before})
after.update({'log-tag': tag_after})
# Log size
# For Podman v3
# size_before = '0B'
# TODO(sshnaidm): integrate B/KB/MB/GB calculation for sizes
# if ('logconfig' in self.info['hostconfig'] and
# 'size' in self.info['hostconfig']['logconfig']):
# size_before = self.info['hostconfig']['logconfig']['size']
# if size_before != '0B':
# if (self.module_params['log_opt'] and
# 'max_size' in self.module_params['log_opt'] and
# self.module_params['log_opt']['max_size'] is not None):
# size_after = self.params['log_opt']['max_size']
# else:
# size_after = ''
# if size_before != size_after:
# before.update({'log-size': size_before})
# after.update({'log-size': size_after})
return self._diff_update_and_compare('log_opt', before, after)
def diffparam_mac_address(self):
@ -955,6 +986,9 @@ class PodmanContainerDiff:
net_mode_before = self.info['hostconfig']['networkmode']
net_mode_after = ''
before = list(self.info['networksettings'].get('networks', {}))
# Remove default 'podman' network in v3 for comparison
if before == ['podman']:
before = []
# Special case for options for slirp4netns rootless networking from v2
if net_mode_before == 'slirp4netns' and 'createcommand' in self.info['config']:
cr_com = self.info['config']['createcommand']