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'),
|
name=dict(required=True, type='str'),
|
||||||
executable=dict(default='podman', type='str'),
|
executable=dict(default='podman', type='str'),
|
||||||
state=dict(type='str', default='started', choices=[
|
state=dict(type='str', default='started', choices=[
|
||||||
'absent', 'present', 'stopped', 'started']),
|
'absent', 'present', 'stopped', 'started', 'created']),
|
||||||
image=dict(type='str'),
|
image=dict(type='str'),
|
||||||
annotation=dict(type='dict'),
|
annotation=dict(type='dict'),
|
||||||
authfile=dict(type='path'),
|
authfile=dict(type='path'),
|
||||||
|
@ -1273,6 +1273,8 @@ class PodmanContainer:
|
||||||
self.version,
|
self.version,
|
||||||
self.module,
|
self.module,
|
||||||
).construct_command_from_params()
|
).construct_command_from_params()
|
||||||
|
if action == 'create':
|
||||||
|
b_command.remove(b'--detach=True')
|
||||||
full_cmd = " ".join([self.module_params['executable']]
|
full_cmd = " ".join([self.module_params['executable']]
|
||||||
+ [to_native(i) for i in b_command])
|
+ [to_native(i) for i in b_command])
|
||||||
self.actions.append(full_cmd)
|
self.actions.append(full_cmd)
|
||||||
|
@ -1317,6 +1319,15 @@ class PodmanContainer:
|
||||||
|
|
||||||
def recreate(self):
|
def recreate(self):
|
||||||
"""Recreate the container."""
|
"""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.delete()
|
||||||
self.run()
|
self.run()
|
||||||
|
|
||||||
|
@ -1379,9 +1390,20 @@ class PodmanManager:
|
||||||
|
|
||||||
def make_started(self):
|
def make_started(self):
|
||||||
"""Run actions if desired state is 'started'."""
|
"""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 \
|
if self.container.running and \
|
||||||
(self.container.different or self.recreate):
|
(self.container.different or self.recreate):
|
||||||
self.container.recreate()
|
self.container.recreate_run()
|
||||||
self.results['actions'].append('recreated %s' %
|
self.results['actions'].append('recreated %s' %
|
||||||
self.container.name)
|
self.container.name)
|
||||||
self.update_container_result()
|
self.update_container_result()
|
||||||
|
@ -1401,7 +1423,7 @@ class PodmanManager:
|
||||||
self.update_container_result()
|
self.update_container_result()
|
||||||
return
|
return
|
||||||
elif self.container.stopped and self.container.different:
|
elif self.container.stopped and self.container.different:
|
||||||
self.container.recreate()
|
self.container.recreate_run()
|
||||||
self.results['actions'].append('recreated %s' %
|
self.results['actions'].append('recreated %s' %
|
||||||
self.container.name)
|
self.container.name)
|
||||||
self.update_container_result()
|
self.update_container_result()
|
||||||
|
@ -1412,6 +1434,26 @@ class PodmanManager:
|
||||||
self.update_container_result()
|
self.update_container_result()
|
||||||
return
|
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):
|
def make_stopped(self):
|
||||||
"""Run actions if desired state is 'stopped'."""
|
"""Run actions if desired state is 'stopped'."""
|
||||||
if not self.container.exists and not self.image:
|
if not self.container.exists and not self.image:
|
||||||
|
@ -1448,7 +1490,8 @@ class PodmanManager:
|
||||||
'present': self.make_started,
|
'present': self.make_started,
|
||||||
'started': self.make_started,
|
'started': self.make_started,
|
||||||
'absent': self.make_absent,
|
'absent': self.make_absent,
|
||||||
'stopped': self.make_stopped
|
'stopped': self.make_stopped,
|
||||||
|
'created': self.make_created,
|
||||||
}
|
}
|
||||||
process_action = states_map[self.state]
|
process_action = states_map[self.state]
|
||||||
process_action()
|
process_action()
|
||||||
|
|
|
@ -62,6 +62,10 @@ options:
|
||||||
a matching container to be stopped and restarted.
|
a matching container to be stopped and restarted.
|
||||||
- I(stopped) - Asserts that the container is first I(present), and then
|
- I(stopped) - Asserts that the container is first I(present), and then
|
||||||
if the container is running moves it to a stopped state.
|
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
|
type: str
|
||||||
default: started
|
default: started
|
||||||
choices:
|
choices:
|
||||||
|
@ -69,6 +73,7 @@ options:
|
||||||
- present
|
- present
|
||||||
- stopped
|
- stopped
|
||||||
- started
|
- started
|
||||||
|
- created
|
||||||
image:
|
image:
|
||||||
description:
|
description:
|
||||||
- Repository path (or image name) and tag used to create the container.
|
- Repository path (or image name) and tag used to create the container.
|
||||||
|
@ -901,8 +906,9 @@ def main():
|
||||||
)
|
)
|
||||||
|
|
||||||
# work on input vars
|
# work on input vars
|
||||||
if module.params['state'] in ['started', 'present'] and \
|
if (module.params['state'] in ['started', 'present', 'created']
|
||||||
not module.params['image']:
|
and not module.params['force_restart']
|
||||||
|
and not module.params['image']):
|
||||||
module.fail_json(msg="State '%s' required image to be configured!" %
|
module.fail_json(msg="State '%s' required image to be configured!" %
|
||||||
module.params['state'])
|
module.params['state'])
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue