docker_swarm_facts: New module to retrieve Docker Swarm information (#50622)

* docker_swarm_facts: PR cleanup after rebasing

* docker_swarm_facts: Adding the features similar to docker_host_facts

* docker_swarm_facts: Minor documentation and documentation updates

* docker_swarm_facts: Minor documentation and documentation adjustments to changes in #51700

* docker_swarm_facts: Using AnsibleDockerSwarmClient class method to fail module if not run on swarm manager
module_utils\docker\swarm.py: Adjustment of error message to me bore descriptive if module fails because it is not run on swarm manager node
This commit is contained in:
Piotr Wojciechowski 2019-02-12 06:59:31 +01:00 committed by ansibot
parent ea72f7001c
commit 42f20091dd
2 changed files with 308 additions and 1 deletions

View file

@ -92,7 +92,7 @@ class AnsibleDockerSwarmClient(AnsibleDockerClient):
If host is not a swarm manager then Ansible task on this host should end with 'failed' state
"""
if not self.check_if_swarm_manager():
self.fail(msg="This node is not a manager.")
self.fail(msg="Error running docker swarm module: must run on swarm manager node")
def check_if_swarm_worker(self):
"""
@ -216,3 +216,6 @@ class AnsibleDockerSwarmClient(AnsibleDockerClient):
return None
return nodes_list
def get_node_name_by_id(self, nodeid):
return self.get_node_inspect(nodeid)['Description']['Hostname']