mirror of
https://github.com/containers/ansible-podman-collections.git
synced 2026-02-04 07:11:49 +00:00
Add support for health-on-failure action (#658)
Signed-off-by: Denis Medeiros <denis.medeiros@bbd.ca>
This commit is contained in:
parent
a9fc6b9764
commit
3c0d2cc58c
2 changed files with 25 additions and 0 deletions
|
|
@ -67,6 +67,8 @@ ARGUMENTS_SPEC_CONTAINER = dict(
|
|||
healthcheck_retries=dict(type='int'),
|
||||
healthcheck_start_period=dict(type='str'),
|
||||
healthcheck_timeout=dict(type='str'),
|
||||
healthcheck_failure_action=dict(type='str', choices=[
|
||||
'none', 'kill', 'restart', 'stop']),
|
||||
hooks_dir=dict(type='list', elements='str'),
|
||||
hostname=dict(type='str'),
|
||||
http_proxy=dict(type='bool'),
|
||||
|
|
@ -411,6 +413,10 @@ class PodmanModuleParams:
|
|||
return c + ['--healthcheck-timeout',
|
||||
self.params['healthcheck_timeout']]
|
||||
|
||||
def addparam_healthcheck_failure_action(self, c):
|
||||
return c + ['--health-on-failure',
|
||||
self.params['healthcheck_failure_action']]
|
||||
|
||||
def addparam_hooks_dir(self, c):
|
||||
for hook_dir in self.params['hooks_dir']:
|
||||
c += ['--hooks-dir=%s' % hook_dir]
|
||||
|
|
@ -952,6 +958,14 @@ class PodmanContainerDiff:
|
|||
after = self.params['healthcheck'] or before
|
||||
return self._diff_update_and_compare('healthcheck', before, after)
|
||||
|
||||
def diffparam_healthcheck_failure_action(self):
|
||||
if 'healthcheckonfailureaction' in self.info['config']:
|
||||
before = self.info['config']['healthcheckonfailureaction']
|
||||
else:
|
||||
before = ''
|
||||
after = self.params['healthcheck_failure_action'] or before
|
||||
return self._diff_update_and_compare('healthcheckonfailureaction', before, after)
|
||||
|
||||
# Because of hostname is random generated, this parameter has partial idempotency only.
|
||||
def diffparam_hostname(self):
|
||||
before = self.info['config']['hostname']
|
||||
|
|
|
|||
|
|
@ -436,6 +436,17 @@ options:
|
|||
is considered failed. Like start-period, the value can be expressed in
|
||||
a time format such as 1m22s. The default value is 30s
|
||||
type: str
|
||||
healthcheck_failure_action:
|
||||
description:
|
||||
- The action to be taken when the container is considered unhealthy. The action must be one of
|
||||
"none", "kill", "restart", or "stop".
|
||||
The default policy is "none".
|
||||
type: str
|
||||
choices:
|
||||
- 'none'
|
||||
- 'kill'
|
||||
- 'restart'
|
||||
- 'stop'
|
||||
hooks_dir:
|
||||
description:
|
||||
- Each .json file in the path configures a hook for Podman containers.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue