mirror of
https://github.com/containers/ansible-podman-collections.git
synced 2026-02-04 07:11:49 +00:00
Fixes for podman_container for Podman v3 (#209)
Fix logs, networks, etc.
This commit is contained in:
parent
9f45c40ea9
commit
c4ba85f73c
4 changed files with 44 additions and 9 deletions
|
|
@ -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']
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@
|
|||
image: "{{ idem_image }}"
|
||||
name: idempotency
|
||||
state: present
|
||||
log_level: error
|
||||
log_level: fatal
|
||||
command: 1h
|
||||
register: test7
|
||||
|
||||
|
|
@ -117,7 +117,7 @@
|
|||
|
||||
- name: Check info with default log level
|
||||
assert:
|
||||
that: test8 is not changed
|
||||
that: test8 is changed
|
||||
|
||||
- name: Run container with log opt tag
|
||||
containers.podman.podman_container:
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@
|
|||
image: "{{ idem_image }}"
|
||||
name: idempotency
|
||||
state: present
|
||||
workdir: /app
|
||||
workdir: /var
|
||||
command: 1h
|
||||
register: test4
|
||||
|
||||
|
|
@ -59,7 +59,7 @@
|
|||
image: "{{ idem_image }}"
|
||||
name: idempotency
|
||||
state: present
|
||||
workdir: /app
|
||||
workdir: /var
|
||||
command: 1h
|
||||
register: test5
|
||||
|
||||
|
|
@ -82,7 +82,7 @@
|
|||
image: "{{ idem_image }}"
|
||||
name: idempotency
|
||||
state: present
|
||||
workdir: /app
|
||||
workdir: /var
|
||||
command: 1h
|
||||
register: test7
|
||||
|
||||
|
|
@ -173,7 +173,7 @@
|
|||
image: alpine
|
||||
name: idempotency1
|
||||
state: present
|
||||
workdir: /app
|
||||
workdir: /var
|
||||
command: sleep 1h
|
||||
register: test12
|
||||
|
||||
|
|
|
|||
|
|
@ -71,15 +71,16 @@
|
|||
command: podman container rm -f {{ container_name }}
|
||||
|
||||
- name: Make checks
|
||||
# https://github.com/containers/podman/issues/9490
|
||||
assert:
|
||||
that:
|
||||
- "'containers' in existing_container"
|
||||
- existing_container.containers
|
||||
- "existing_container.containers == podman_inspect_result"
|
||||
- all_containers.containers == existing_container.containers
|
||||
# - "existing_container.containers == podman_inspect_result"
|
||||
# - all_containers.containers == existing_container.containers
|
||||
- "'containers' in mixed_existing_container"
|
||||
- mixed_existing_container.containers
|
||||
- existing_container.containers == mixed_existing_container.containers
|
||||
# - existing_container.containers == mixed_existing_container.containers
|
||||
|
||||
always:
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue