Simplify docker_*_facts return names (#51939)

* Simplify docker_*_facts return names.

* Adjust regular return values of modules to match style of docker_*_facts modules.
This commit is contained in:
Felix Fontein 2019-03-05 17:09:00 +01:00 committed by John R Barker
commit 8c628c9b2c
21 changed files with 208 additions and 208 deletions

View file

@ -873,12 +873,13 @@ EXAMPLES = '''
'''
RETURN = '''
docker_container:
container:
description:
- Before 2.3 this was 'ansible_docker_container' but was renamed due to conflicts with the connection plugin.
- Facts representing the current state of the container. Matches the docker inspection output.
- Note that facts are part of the registered vars since Ansible 2.8. For compatibility reasons, the facts
are also accessible directly. Note that the returned fact will be removed in Ansible 2.12.
are also accessible directly as C(docker_container). Note that the returned fact will be removed in Ansible 2.12.
- Before 2.3 this was C(ansible_docker_container) but was renamed in 2.3 to C(docker_container) due to
conflicts with the connection plugin.
- Empty if C(state) is I(absent)
- If detached is I(False), will include Output attribute containing any output from container run.
returned: always
@ -2253,7 +2254,7 @@ class ContainerManager(DockerBaseClass):
if self.facts:
self.results['ansible_facts'] = {'docker_container': self.facts}
self.results['docker_container'] = self.facts
self.results['container'] = self.facts
def present(self, state):
container = self._get_container(self.parameters.name)

View file

@ -56,7 +56,7 @@ EXAMPLES = '''
- name: Print information about container
debug:
var: result.docker_container
var: result.container
when: result.exists
'''
@ -67,7 +67,7 @@ exists:
type: bool
returned: always
sample: true
docker_container:
container:
description:
- Facts representing the current state of the container. Matches the docker inspection output.
- Will be C(None) if container does not exist.
@ -126,7 +126,7 @@ def main():
client.module.exit_json(
changed=False,
exists=(True if container else False),
docker_container=container,
container=container,
)

View file

@ -143,40 +143,40 @@ can_talk_to_docker:
returned: both on success and on error
type: bool
docker_host_facts:
host_facts:
description:
- Facts representing the basic state of the docker host. Matches the C(docker system info) output.
returned: always
type: dict
docker_volumes_list:
volumes:
description:
- List of dict objects containing the basic information about each volume.
Keys matches the C(docker volume ls) output unless I(verbose_output=yes).
See description for I(verbose_output).
returned: When I(volumes) is C(yes)
type: list
docker_networks_list:
networks:
description:
- List of dict objects containing the basic information about each network.
Keys matches the C(docker network ls) output unless I(verbose_output=yes).
See description for I(verbose_output).
returned: When I(networks) is C(yes)
type: list
docker_containers_list:
containers:
description:
- List of dict objects containing the basic information about each container.
Keys matches the C(docker container ls) output unless I(verbose_output=yes).
See description for I(verbose_output).
returned: When I(containers) is C(yes)
type: list
docker_images_list:
images:
description:
- List of dict objects containing the basic information about each image.
Keys matches the C(docker image ls) output unless I(verbose_output=yes).
See description for I(verbose_output).
returned: When I(images) is C(yes)
type: list
docker_disk_usage:
disk_usage:
description:
- Information on summary disk usage by images, containers and volumes on docker host
unless I(verbose_output=yes). See description for I(verbose_output).
@ -209,14 +209,14 @@ class DockerHostManager(DockerBaseClass):
listed_objects = ['volumes', 'networks', 'containers', 'images']
self.results['docker_host_facts'] = self.get_docker_host_facts()
self.results['host_facts'] = self.get_docker_host_facts()
if self.client.module.params['disk_usage']:
self.results['docker_disk_usage'] = self.get_docker_disk_usage_facts()
self.results['disk_usage'] = self.get_docker_disk_usage_facts()
for docker_object in listed_objects:
if self.client.module.params[docker_object]:
returned_name = "docker_" + docker_object + "_list"
returned_name = docker_object
filter_name = docker_object + "_filters"
filters = clean_dict_booleans_for_docker_api(client.module.params.get(filter_name))
self.results[returned_name] = self.get_docker_items_list(docker_object, filters)
@ -314,7 +314,6 @@ def main():
results = dict(
changed=False,
docker_host_facts=[]
)
DockerHostManager(client, results)

View file

@ -241,11 +241,11 @@ EXAMPLES = '''
'''
RETURN = '''
docker_network:
network:
description:
- Network inspection results for the affected network.
- Note that facts are part of the registered vars since Ansible 2.8. For compatibility reasons, the facts
are also accessible directly. Note that the returned fact will be removed in Ansible 2.12.
are also accessible directly as C(docker_network). Note that the returned fact will be removed in Ansible 2.12.
returned: success
type: dict
sample: {}
@ -575,7 +575,7 @@ class DockerNetworkManager(object):
network_facts = self.get_existing_network()
self.results['ansible_facts'] = {u'docker_network': network_facts}
self.results['docker_network'] = network_facts
self.results['network'] = network_facts
def absent(self):
self.diff_tracker.add('exists', parameter=False, active=self.existing_network is not None)

View file

@ -56,7 +56,7 @@ EXAMPLES = '''
- name: Print information about network
debug:
var: result.docker_network
var: result.network
when: result.exists
'''
@ -67,7 +67,7 @@ exists:
type: bool
returned: always
sample: true
docker_network:
network:
description:
- Facts representing the current state of the network. Matches the docker inspection output.
- Will be C(None) if network does not exist.
@ -122,7 +122,7 @@ def main():
client.module.exit_json(
changed=False,
exists=(True if network else False),
docker_network=network,
network=network,
)

View file

@ -76,7 +76,7 @@ EXAMPLES = '''
'''
RETURN = '''
nodes_facts:
nodes:
description:
- Facts representing the current state of the nodes. Matches the C(docker node inspect) output.
- Can contain multiple entries if more than one node provided in I(name), or I(name) is not provided.
@ -136,11 +136,11 @@ def main():
client.fail_task_if_not_swarm_manager()
node = get_node_facts(client)
nodes = get_node_facts(client)
client.module.exit_json(
changed=False,
nodes_facts=node,
nodes=nodes,
)

View file

@ -83,13 +83,13 @@ requirements:
'''
RETURN = '''
docker_stack_spec_diff:
stack_spec_diff:
description: |
dictionary containing the differences between the 'Spec' field
of the stack services before and after applying the new stack
definition.
sample: >
"docker_stack_specs_diff":
"stack_spec_diff":
{'test_stack_test_service': {u'TaskTemplate': {u'ContainerSpec': {delete: [u'Env']}}}}
returned: on change
type: dict
@ -277,9 +277,9 @@ def main():
else:
module.exit_json(
changed=True,
docker_stack_spec_diff=json_diff(before_stack_services,
after_stack_services,
dump=True))
stack_spec_diff=json_diff(before_stack_services,
after_stack_services,
dump=True))
else:
if docker_stack_services(module, name):

View file

@ -120,7 +120,7 @@ EXAMPLES = '''
register: result
- debug:
var: result.docker_swarm_facts
var: result.swarm_facts
'''
RETURN = '''
@ -144,27 +144,27 @@ docker_swarm_manager:
returned: both on success and on error
type: bool
docker_swarm_facts:
swarm_facts:
description:
- Facts representing the basic state of the docker Swarm cluster.
- Contains tokens to connect to the Swarm
returned: always
type: dict
docker_nodes_list:
nodes:
description:
- List of dict objects containing the basic information about each volume.
Keys matches the C(docker node ls) output unless I(verbose_output=yes).
See description for I(verbose_output).
returned: When I(nodes) is C(yes)
type: list
docker_services_list:
services:
description:
- List of dict objects containing the basic information about each volume.
Keys matches the C(docker service ls) output unless I(verbose_output=yes).
See description for I(verbose_output).
returned: When I(services) is C(yes)
type: list
docker_tasks_list:
tasks:
description:
- List of dict objects containing the basic information about each volume.
Keys matches the C(docker service ps) output unless I(verbose_output=yes).
@ -200,11 +200,11 @@ class DockerSwarmManager(DockerBaseClass):
self.client.fail_task_if_not_swarm_manager()
self.results['docker_swarm_facts'] = self.get_docker_swarm_facts()
self.results['swarm_facts'] = self.get_docker_swarm_facts()
for docker_object in listed_objects:
if self.client.module.params[docker_object]:
returned_name = "docker_" + docker_object + "_list"
returned_name = docker_object
filter_name = docker_object + "_filters"
filters = clean_dict_booleans_for_docker_api(client.module.params.get(filter_name))
self.results[returned_name] = self.get_docker_items_list(docker_object, filters)
@ -334,7 +334,6 @@ def main():
results = dict(
changed=False,
docker_swarm_facts=[],
)
DockerSwarmManager(client, results)

View file

@ -115,11 +115,11 @@ EXAMPLES = '''
'''
RETURN = '''
docker_volume:
volume:
description:
- Volume inspection results for the affected volume.
- Note that facts are part of the registered vars since Ansible 2.8. For compatibility reasons, the facts
are also accessible directly. Note that the returned fact will be removed in Ansible 2.12.
are also accessible directly as C(docker_volume). Note that the returned fact will be removed in Ansible 2.12.
returned: success
type: dict
sample: {}
@ -291,7 +291,7 @@ class DockerVolumeManager(object):
volume_facts = self.get_existing_volume()
self.results['ansible_facts'] = {u'docker_volume': volume_facts}
self.results['docker_volume'] = volume_facts
self.results['volume'] = volume_facts
def absent(self):
self.diff_tracker.add('exists', parameter=False, active=self.existing_volume is not None)

View file

@ -52,7 +52,7 @@ EXAMPLES = '''
- name: Print information about volume
debug:
var: result.docker_volume
var: result.volume
when: result.exists
'''
@ -63,7 +63,7 @@ exists:
type: bool
returned: always
sample: true
docker_volume:
volume:
description:
- Volume inspection results for the affected volume.
- Will be C(None) if volume does not exist.
@ -115,7 +115,7 @@ def main():
client.module.exit_json(
changed=False,
exists=(True if volume else False),
docker_volume=volume,
volume=volume,
)