Merge "Fix triple molecule modules job" into stable/train
This commit is contained in:
commit
d7226ed6b1
|
@ -29,7 +29,7 @@ ARGUMENTS_SPEC_CONTAINER = dict(
|
|||
name=dict(required=True, type='str'),
|
||||
executable=dict(default='podman', type='str'),
|
||||
state=dict(type='str', default='started', choices=[
|
||||
'absent', 'present', 'stopped', 'started']),
|
||||
'absent', 'present', 'stopped', 'started', 'created']),
|
||||
image=dict(type='str'),
|
||||
annotation=dict(type='dict'),
|
||||
authfile=dict(type='path'),
|
||||
|
@ -1273,6 +1273,8 @@ class PodmanContainer:
|
|||
self.version,
|
||||
self.module,
|
||||
).construct_command_from_params()
|
||||
if action == 'create':
|
||||
b_command.remove(b'--detach=True')
|
||||
full_cmd = " ".join([self.module_params['executable']]
|
||||
+ [to_native(i) for i in b_command])
|
||||
self.actions.append(full_cmd)
|
||||
|
@ -1317,6 +1319,15 @@ class PodmanContainer:
|
|||
|
||||
def recreate(self):
|
||||
"""Recreate the container."""
|
||||
if self.running:
|
||||
self.stop()
|
||||
self.delete()
|
||||
self.create()
|
||||
|
||||
def recreate_run(self):
|
||||
"""Recreate and run the container."""
|
||||
if self.running:
|
||||
self.stop()
|
||||
self.delete()
|
||||
self.run()
|
||||
|
||||
|
@ -1379,9 +1390,20 @@ class PodmanManager:
|
|||
|
||||
def make_started(self):
|
||||
"""Run actions if desired state is 'started'."""
|
||||
if self.container.exists and self.restart:
|
||||
if self.container.running:
|
||||
self.container.restart()
|
||||
self.results['actions'].append('restarted %s' %
|
||||
self.container.name)
|
||||
else:
|
||||
self.container.start()
|
||||
self.results['actions'].append('started %s' %
|
||||
self.container.name)
|
||||
self.update_container_result()
|
||||
return
|
||||
if self.container.running and \
|
||||
(self.container.different or self.recreate):
|
||||
self.container.recreate()
|
||||
self.container.recreate_run()
|
||||
self.results['actions'].append('recreated %s' %
|
||||
self.container.name)
|
||||
self.update_container_result()
|
||||
|
@ -1401,7 +1423,7 @@ class PodmanManager:
|
|||
self.update_container_result()
|
||||
return
|
||||
elif self.container.stopped and self.container.different:
|
||||
self.container.recreate()
|
||||
self.container.recreate_run()
|
||||
self.results['actions'].append('recreated %s' %
|
||||
self.container.name)
|
||||
self.update_container_result()
|
||||
|
@ -1412,6 +1434,26 @@ class PodmanManager:
|
|||
self.update_container_result()
|
||||
return
|
||||
|
||||
def make_created(self):
|
||||
"""Run actions if desired state is 'created'."""
|
||||
if not self.container.exists and not self.image:
|
||||
self.module.fail_json(msg='Cannot create container when image'
|
||||
' is not specified!')
|
||||
if not self.container.exists:
|
||||
self.container.create()
|
||||
self.results['actions'].append('created %s' % self.container.name)
|
||||
self.update_container_result()
|
||||
return
|
||||
else:
|
||||
if (self.container.different or self.recreate):
|
||||
self.container.recreate()
|
||||
self.results['actions'].append('recreated %s' %
|
||||
self.container.name)
|
||||
self.update_container_result()
|
||||
return
|
||||
self.update_container_result(changed=False)
|
||||
return
|
||||
|
||||
def make_stopped(self):
|
||||
"""Run actions if desired state is 'stopped'."""
|
||||
if not self.container.exists and not self.image:
|
||||
|
@ -1448,7 +1490,8 @@ class PodmanManager:
|
|||
'present': self.make_started,
|
||||
'started': self.make_started,
|
||||
'absent': self.make_absent,
|
||||
'stopped': self.make_stopped
|
||||
'stopped': self.make_stopped,
|
||||
'created': self.make_created,
|
||||
}
|
||||
process_action = states_map[self.state]
|
||||
process_action()
|
||||
|
|
|
@ -62,6 +62,10 @@ options:
|
|||
a matching container to be stopped and restarted.
|
||||
- I(stopped) - Asserts that the container is first I(present), and then
|
||||
if the container is running moves it to a stopped state.
|
||||
- I(created) - Asserts that the container exists with given configuration.
|
||||
If container doesn't exist, the module creates it and leaves it in
|
||||
'created' state. If configuration doesn't match or 'recreate' option is
|
||||
set, the container will be recreated
|
||||
type: str
|
||||
default: started
|
||||
choices:
|
||||
|
@ -69,6 +73,7 @@ options:
|
|||
- present
|
||||
- stopped
|
||||
- started
|
||||
- created
|
||||
image:
|
||||
description:
|
||||
- Repository path (or image name) and tag used to create the container.
|
||||
|
@ -901,8 +906,9 @@ def main():
|
|||
)
|
||||
|
||||
# work on input vars
|
||||
if module.params['state'] in ['started', 'present'] and \
|
||||
not module.params['image']:
|
||||
if (module.params['state'] in ['started', 'present', 'created']
|
||||
and not module.params['force_restart']
|
||||
and not module.params['image']):
|
||||
module.fail_json(msg="State '%s' required image to be configured!" %
|
||||
module.params['state'])
|
||||
|
||||
|
|
Loading…
Reference in New Issue