Skip to content

Commit

Permalink
Added --log-opt: max_file option to podman_play.py
Browse files Browse the repository at this point in the history
Signed-off-by: Ahmad Kasem <[email protected]>
  • Loading branch information
AhmadKasem committed Dec 28, 2023
1 parent 2d265c9 commit b9c01e1
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/podman_container_module.html
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,14 @@ <h2><a class="toc-backref" href="#id3" role="doc-backlink">Parameters</a><a clas
<td><div class="ansible-option-indent-desc"></div><div class="ansible-option-cell"><p>Specify a max size of the log file (e.g 10mb).</p>
</div></td>
</tr>
<tr class="row-odd"><td><div class="ansible-option-indent"></div><div class="ansible-option-cell">
<div class="ansibleOptionAnchor" id="parameter-log_opt/max_file"></div>
<div class="ansibleOptionAnchor" id="parameter-log_options/max_file"></div><p class="ansible-option-title" id="ansible-collections-containers-podman-podman-container-module-parameter-log-options-max-file"><span id="ansible-collections-containers-podman-podman-container-module-parameter-log-opt-max-file"></span><strong>max_file</strong></p>
<a class="ansibleOptionLink" href="#parameter-log_opt/max_file" title="Permalink to this option"></a><p class="ansible-option-type-line"><span class="ansible-option-type">string</span></p>
</div></td>
<td><div class="ansible-option-indent-desc"></div><div class="ansible-option-cell"><p>Specify a max number of the log files (e.g 10).</p>
</div></td>
</tr>
<tr class="row-even"><td><div class="ansible-option-indent"></div><div class="ansible-option-cell">
<div class="ansibleOptionAnchor" id="parameter-log_opt/path"></div>
<div class="ansibleOptionAnchor" id="parameter-log_options/path"></div><p class="ansible-option-title" id="ansible-collections-containers-podman-podman-container-module-parameter-log-options-path"><span id="ansible-collections-containers-podman-podman-container-module-parameter-log-opt-path"></span><strong>path</strong></p>
Expand Down
11 changes: 11 additions & 0 deletions plugins/module_utils/podman/podman_container_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
log_opt=dict(type='dict', aliases=['log_options'],
options=dict(
max_size=dict(type='str'),
max_file=dict(type='str'),
path=dict(type='str'),
tag=dict(type='str'))),
mac_address=dict(type='str'),
Expand Down Expand Up @@ -473,6 +474,16 @@ def addparam_log_opt(self, c):
errors='surrogate_or_strict')])]
return c

def addparam_log_opt_file_size(self, c):
for k, v in self.params['log_opt'].items():
if v is not None:
c += ['--log-opt',
b"=".join([to_bytes(k.replace('max_file', 'max-file'),
errors='surrogate_or_strict'),
to_bytes(v,
errors='surrogate_or_strict')])]
return c

def addparam_log_level(self, c):
return c + ['--log-level', self.params['log_level']]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@
log_opt:
path: /tmp/container3.log
max_size: 100mb
max_file: '10'
tag: sometag
command: 1h

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
log_opt:
path: "{{ log_opt.path }}"
max_size: "{{ log_opt.size }}"
max_file: "{{ log_opt.file }}"
register: play_pod

- name: Get pod info
Expand Down

0 comments on commit b9c01e1

Please sign in to comment.