mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-25 11:51:26 -07:00
Added actions to RETURN docs. Show actions when debug or check mode.
This commit is contained in:
parent
2860f57551
commit
e8d49261e3
1 changed files with 42 additions and 4 deletions
|
@ -139,6 +139,12 @@ options:
|
||||||
required: false
|
required: false
|
||||||
type: bool
|
type: bool
|
||||||
default: false
|
default: false
|
||||||
|
debug:
|
||||||
|
description:
|
||||||
|
- Include I(actions) in the return values.
|
||||||
|
required: false
|
||||||
|
type: bool
|
||||||
|
default: false
|
||||||
'''
|
'''
|
||||||
|
|
||||||
EXAMPLES = '''
|
EXAMPLES = '''
|
||||||
|
@ -357,6 +363,35 @@ service:
|
||||||
returned: success
|
returned: success
|
||||||
type: str
|
type: str
|
||||||
example: running
|
example: running
|
||||||
|
|
||||||
|
actions:
|
||||||
|
description: Provides the actions to be taken on each service as determined by compose.
|
||||||
|
returned: when in check mode or I(debug) true
|
||||||
|
type: complex
|
||||||
|
contains:
|
||||||
|
service_name:
|
||||||
|
description: Name of the service.
|
||||||
|
returned: always
|
||||||
|
type: complex
|
||||||
|
contains:
|
||||||
|
action:
|
||||||
|
description: A descriptive name of the action to be performed on the set of containers
|
||||||
|
within the service.
|
||||||
|
returned: always
|
||||||
|
type: list
|
||||||
|
contains:
|
||||||
|
id:
|
||||||
|
description: the container's long ID
|
||||||
|
returned: always
|
||||||
|
type: string
|
||||||
|
name:
|
||||||
|
description: the container's name
|
||||||
|
returned: always
|
||||||
|
type: string
|
||||||
|
short_id:
|
||||||
|
description: the container's short ID
|
||||||
|
returned: always
|
||||||
|
type: string
|
||||||
'''
|
'''
|
||||||
|
|
||||||
HAS_COMPOSE = True
|
HAS_COMPOSE = True
|
||||||
|
@ -475,6 +510,9 @@ class ContainerManager(DockerBaseClass):
|
||||||
self.log("removing %s" % self.project_src)
|
self.log("removing %s" % self.project_src)
|
||||||
os.rmdir(self.project_src)
|
os.rmdir(self.project_src)
|
||||||
|
|
||||||
|
if not self.check_mode and not self.debug and result.get('actions'):
|
||||||
|
result.pop('actions')
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def _get_auth_options(self):
|
def _get_auth_options(self):
|
||||||
|
@ -517,7 +555,7 @@ class ContainerManager(DockerBaseClass):
|
||||||
plan = service.convergence_plan(strategy=converge)
|
plan = service.convergence_plan(strategy=converge)
|
||||||
if plan.action != 'noop':
|
if plan.action != 'noop':
|
||||||
result['changed'] = True
|
result['changed'] = True
|
||||||
if self.debug:
|
if self.debug or self.check_mode:
|
||||||
result['actions'][service.name] = dict()
|
result['actions'][service.name] = dict()
|
||||||
result['actions'][service.name][plan.action] = []
|
result['actions'][service.name][plan.action] = []
|
||||||
for container in plan.containers:
|
for container in plan.containers:
|
||||||
|
@ -586,7 +624,7 @@ class ContainerManager(DockerBaseClass):
|
||||||
containers = service.containers(stopped=True)
|
containers = service.containers(stopped=True)
|
||||||
if len(containers):
|
if len(containers):
|
||||||
result['changed'] = True
|
result['changed'] = True
|
||||||
if self.debug:
|
if self.debug or self.check_mode:
|
||||||
result['actions'][service.name] = dict()
|
result['actions'][service.name] = dict()
|
||||||
result['actions'][service.name]['deleted'] = [container.name for container in containers]
|
result['actions'][service.name]['deleted'] = [container.name for container in containers]
|
||||||
|
|
||||||
|
@ -637,7 +675,7 @@ class ContainerManager(DockerBaseClass):
|
||||||
result['actions'][service.name]['restart'] = []
|
result['actions'][service.name]['restart'] = []
|
||||||
for container in service.containers(stopped=True):
|
for container in service.containers(stopped=True):
|
||||||
result['changed'] = True
|
result['changed'] = True
|
||||||
if self.debug:
|
if self.debug or self.check_mode:
|
||||||
result['actions'][service.name]['restart'].append(dict(
|
result['actions'][service.name]['restart'].append(dict(
|
||||||
id=container.id,
|
id=container.id,
|
||||||
name=container.name,
|
name=container.name,
|
||||||
|
@ -664,7 +702,7 @@ class ContainerManager(DockerBaseClass):
|
||||||
containers = service.containers(stopped=True)
|
containers = service.containers(stopped=True)
|
||||||
if len(containers) != self.scale[service.name]:
|
if len(containers) != self.scale[service.name]:
|
||||||
result['changed'] = True
|
result['changed'] = True
|
||||||
if self.debug:
|
if self.debug or self.check_mode:
|
||||||
result['actions'][service.name]['scale'] = self.scale[service.name] - len(containers)
|
result['actions'][service.name]['scale'] = self.scale[service.name] - len(containers)
|
||||||
if not self.check_mode:
|
if not self.check_mode:
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue