community.general/lib/ansible/modules/cloud/docker/docker_node_info.py

149 lines
4.0 KiB
Python
Raw Normal View History

docker_node_facts: Read information about swarm node from swarm manager (#50571) * docker_node_facts: New module to read information about swarm node from swarm manager * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * docker_node_facts: min_docker_api_version and docker updated to align with Docker documentation * docker_node_facts: Updated documentation and minimum version requirements * docker_node_facts: Updated documentation of requirements * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com>
2019-01-08 13:00:59 +00:00
#!/usr/bin/python
#
# (c) 2019 Piotr Wojciechowski <piotr@it-playground.pl>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
from __future__ import absolute_import, division, print_function
__metaclass__ = type
ANSIBLE_METADATA = {'metadata_version': '1.1',
'status': ['preview'],
'supported_by': 'community'}
DOCUMENTATION = '''
---
module: docker_node_info
docker_node_facts: Read information about swarm node from swarm manager (#50571) * docker_node_facts: New module to read information about swarm node from swarm manager * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * docker_node_facts: min_docker_api_version and docker updated to align with Docker documentation * docker_node_facts: Updated documentation and minimum version requirements * docker_node_facts: Updated documentation of requirements * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com>
2019-01-08 13:00:59 +00:00
short_description: Retrieves facts about docker swarm node from Swarm Manager
description:
- Retrieves facts about a docker node.
- Essentially returns the output of C(docker node inspect <name>).
- Must be executed on a host running as Swarm Manager, otherwise the module will fail.
version_added: "2.8"
options:
name:
description:
- The name of the node to inspect.
- The list of nodes names to inspect.
- If empty then return information of all nodes in Swarm cluster.
- When identifying the node use either the hostname of the node (as registered in Swarm) or node ID.
- If I(self) is C(true) then this parameter is ignored.
type: list
self:
description:
- If C(true), queries the node (i.e. the docker daemon) the module communicates with.
- If C(true) then I(name) is ignored.
- If C(false) then query depends on I(name) presence and value.
type: bool
default: no
docker_node_facts: Read information about swarm node from swarm manager (#50571) * docker_node_facts: New module to read information about swarm node from swarm manager * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * docker_node_facts: min_docker_api_version and docker updated to align with Docker documentation * docker_node_facts: Updated documentation and minimum version requirements * docker_node_facts: Updated documentation of requirements * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com>
2019-01-08 13:00:59 +00:00
extends_documentation_fragment:
- docker
- docker.docker_py_1_documentation
docker_node_facts: Read information about swarm node from swarm manager (#50571) * docker_node_facts: New module to read information about swarm node from swarm manager * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * docker_node_facts: min_docker_api_version and docker updated to align with Docker documentation * docker_node_facts: Updated documentation and minimum version requirements * docker_node_facts: Updated documentation of requirements * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com>
2019-01-08 13:00:59 +00:00
author:
- Piotr Wojciechowski (@wojciechowskipiotr)
docker_node_facts: Read information about swarm node from swarm manager (#50571) * docker_node_facts: New module to read information about swarm node from swarm manager * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * docker_node_facts: min_docker_api_version and docker updated to align with Docker documentation * docker_node_facts: Updated documentation and minimum version requirements * docker_node_facts: Updated documentation of requirements * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com>
2019-01-08 13:00:59 +00:00
requirements:
- "L(Docker SDK for Python,https://docker-py.readthedocs.io/en/stable/) >= 2.4.0"
- "Docker API >= 1.24"
docker_node_facts: Read information about swarm node from swarm manager (#50571) * docker_node_facts: New module to read information about swarm node from swarm manager * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * docker_node_facts: min_docker_api_version and docker updated to align with Docker documentation * docker_node_facts: Updated documentation and minimum version requirements * docker_node_facts: Updated documentation of requirements * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com>
2019-01-08 13:00:59 +00:00
'''
EXAMPLES = '''
- name: Get info on all nodes
docker_node_info:
register: result
docker_node_facts: Read information about swarm node from swarm manager (#50571) * docker_node_facts: New module to read information about swarm node from swarm manager * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * docker_node_facts: min_docker_api_version and docker updated to align with Docker documentation * docker_node_facts: Updated documentation and minimum version requirements * docker_node_facts: Updated documentation of requirements * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com>
2019-01-08 13:00:59 +00:00
- name: Get info on node
docker_node_info:
docker_node_facts: Read information about swarm node from swarm manager (#50571) * docker_node_facts: New module to read information about swarm node from swarm manager * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * docker_node_facts: min_docker_api_version and docker updated to align with Docker documentation * docker_node_facts: Updated documentation and minimum version requirements * docker_node_facts: Updated documentation of requirements * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com>
2019-01-08 13:00:59 +00:00
name: mynode
register: result
- name: Get info on list of nodes
docker_node_info:
name:
- mynode1
- mynode2
register: result
- name: Get info on host if it is Swarm Manager
docker_node_info:
self: true
register: result
docker_node_facts: Read information about swarm node from swarm manager (#50571) * docker_node_facts: New module to read information about swarm node from swarm manager * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * docker_node_facts: min_docker_api_version and docker updated to align with Docker documentation * docker_node_facts: Updated documentation and minimum version requirements * docker_node_facts: Updated documentation of requirements * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com>
2019-01-08 13:00:59 +00:00
'''
RETURN = '''
nodes:
docker_node_facts: Read information about swarm node from swarm manager (#50571) * docker_node_facts: New module to read information about swarm node from swarm manager * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * docker_node_facts: min_docker_api_version and docker updated to align with Docker documentation * docker_node_facts: Updated documentation and minimum version requirements * docker_node_facts: Updated documentation of requirements * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com>
2019-01-08 13:00:59 +00:00
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.
- If I(name) contains a list of nodes, the output will provide information on all nodes registered
at the swarm, including nodes that left the swarm but haven't been removed from the cluster on swarm
managers and nodes that are unreachable.
docker_node_facts: Read information about swarm node from swarm manager (#50571) * docker_node_facts: New module to read information about swarm node from swarm manager * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * docker_node_facts: min_docker_api_version and docker updated to align with Docker documentation * docker_node_facts: Updated documentation and minimum version requirements * docker_node_facts: Updated documentation of requirements * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com>
2019-01-08 13:00:59 +00:00
returned: always
type: list
docker_node_facts: Read information about swarm node from swarm manager (#50571) * docker_node_facts: New module to read information about swarm node from swarm manager * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * docker_node_facts: min_docker_api_version and docker updated to align with Docker documentation * docker_node_facts: Updated documentation and minimum version requirements * docker_node_facts: Updated documentation of requirements * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com>
2019-01-08 13:00:59 +00:00
'''
from ansible.module_utils.docker.swarm import AnsibleDockerSwarmClient
docker_node: Docker Swarm node operations module (#50584) * * docker_node: New module for operations on Docker Swarm node * Shared code for Docker Swarm modules * * docker_node: Removed the attribute `force` as it is not used for any operation * docker_node_facts: Update module to use client class AnsibleDockerSwarmClient instead of AnsibleDockerClient * docker_node_facts: List of nodes can be provided as input, inspect all registered nodes or manager host itself * docker_node: Update in method name called from AnsibleDockerSwarmClient * docker_node: Additional method to shared module to get formatted output list of registered nodes * docker_node: Additional method to shared module to get formatted output list of registered nodes * docker_node: removed state list (featue moved to docker_swarm_facts) * docker_node: Node labels manipulation (remove, replace, merge) * module_utils/docker_swarm: Updated output for nodes list - adding swarm leader flag * docker_node_facts: update in input and return values, update in documentation section * docker_node: Updated operations on labels, tracking if change is required * docker_node: Updated documentation, parameter 'hostname' is now required docker_node_facts: Updated documentation * * Failing Ansible tasl if not run on swarm manager - code cleanup * * docker_node: Remove the 'action' list from output * * docker_node: variable name change to be align with Python best practice, BOTMETA.yml update * * module_utils/docker_swarm.py: fix for incorrect fail() action * docker_node: documentation and code small updates * * docker_node: revised labels manipulation * docker_node_facts: Reverting to repository version, moving this change to separate PR * * docker_node: Documentation update * * docker_node: Update to node availability and role modification * * docker_node: Update to check_mode handling * * docker_node: Code cleanup * docker_node_facts: Code cleanup * docker_node_facts: Adding back the module with only update to use AnsibleDockerSwarmClient instead of AnsibleDockerClient docker_node: cosmetic code changes BOTMETA: updated on $team_docker * docker_node: BOTMETA update
2019-02-04 13:08:46 +00:00
docker_node_facts: Read information about swarm node from swarm manager (#50571) * docker_node_facts: New module to read information about swarm node from swarm manager * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * docker_node_facts: min_docker_api_version and docker updated to align with Docker documentation * docker_node_facts: Updated documentation and minimum version requirements * docker_node_facts: Updated documentation of requirements * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com>
2019-01-08 13:00:59 +00:00
try:
from docker.errors import APIError, NotFound
except ImportError:
# missing Docker SDK for Python handled in ansible.module_utils.docker.common
docker_node_facts: Read information about swarm node from swarm manager (#50571) * docker_node_facts: New module to read information about swarm node from swarm manager * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * docker_node_facts: min_docker_api_version and docker updated to align with Docker documentation * docker_node_facts: Updated documentation and minimum version requirements * docker_node_facts: Updated documentation of requirements * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com>
2019-01-08 13:00:59 +00:00
pass
def get_node_facts(client):
results = []
if client.module.params['self'] is True:
self_node_id = client.get_swarm_node_id()
node_info = client.get_node_inspect(node_id=self_node_id)
results.append(node_info)
return results
if client.module.params['name'] is None:
node_info = client.get_all_nodes_inspect()
return node_info
nodes = client.module.params['name']
if not isinstance(nodes, list):
nodes = [nodes]
for next_node_name in nodes:
next_node_info = client.get_node_inspect(node_id=next_node_name, skip_missing=True)
if next_node_info:
results.append(next_node_info)
return results
docker_node_facts: Read information about swarm node from swarm manager (#50571) * docker_node_facts: New module to read information about swarm node from swarm manager * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * docker_node_facts: min_docker_api_version and docker updated to align with Docker documentation * docker_node_facts: Updated documentation and minimum version requirements * docker_node_facts: Updated documentation of requirements * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com>
2019-01-08 13:00:59 +00:00
def main():
argument_spec = dict(
name=dict(type='list', elements='str'),
self=dict(type='bool', default=False),
docker_node_facts: Read information about swarm node from swarm manager (#50571) * docker_node_facts: New module to read information about swarm node from swarm manager * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * docker_node_facts: min_docker_api_version and docker updated to align with Docker documentation * docker_node_facts: Updated documentation and minimum version requirements * docker_node_facts: Updated documentation of requirements * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com>
2019-01-08 13:00:59 +00:00
)
docker_node: Docker Swarm node operations module (#50584) * * docker_node: New module for operations on Docker Swarm node * Shared code for Docker Swarm modules * * docker_node: Removed the attribute `force` as it is not used for any operation * docker_node_facts: Update module to use client class AnsibleDockerSwarmClient instead of AnsibleDockerClient * docker_node_facts: List of nodes can be provided as input, inspect all registered nodes or manager host itself * docker_node: Update in method name called from AnsibleDockerSwarmClient * docker_node: Additional method to shared module to get formatted output list of registered nodes * docker_node: Additional method to shared module to get formatted output list of registered nodes * docker_node: removed state list (featue moved to docker_swarm_facts) * docker_node: Node labels manipulation (remove, replace, merge) * module_utils/docker_swarm: Updated output for nodes list - adding swarm leader flag * docker_node_facts: update in input and return values, update in documentation section * docker_node: Updated operations on labels, tracking if change is required * docker_node: Updated documentation, parameter 'hostname' is now required docker_node_facts: Updated documentation * * Failing Ansible tasl if not run on swarm manager - code cleanup * * docker_node: Remove the 'action' list from output * * docker_node: variable name change to be align with Python best practice, BOTMETA.yml update * * module_utils/docker_swarm.py: fix for incorrect fail() action * docker_node: documentation and code small updates * * docker_node: revised labels manipulation * docker_node_facts: Reverting to repository version, moving this change to separate PR * * docker_node: Documentation update * * docker_node: Update to node availability and role modification * * docker_node: Update to check_mode handling * * docker_node: Code cleanup * docker_node_facts: Code cleanup * docker_node_facts: Adding back the module with only update to use AnsibleDockerSwarmClient instead of AnsibleDockerClient docker_node: cosmetic code changes BOTMETA: updated on $team_docker * docker_node: BOTMETA update
2019-02-04 13:08:46 +00:00
client = AnsibleDockerSwarmClient(
docker_node_facts: Read information about swarm node from swarm manager (#50571) * docker_node_facts: New module to read information about swarm node from swarm manager * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * docker_node_facts: min_docker_api_version and docker updated to align with Docker documentation * docker_node_facts: Updated documentation and minimum version requirements * docker_node_facts: Updated documentation of requirements * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com>
2019-01-08 13:00:59 +00:00
argument_spec=argument_spec,
supports_check_mode=True,
min_docker_version='2.4.0',
docker_node_facts: Read information about swarm node from swarm manager (#50571) * docker_node_facts: New module to read information about swarm node from swarm manager * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * docker_node_facts: min_docker_api_version and docker updated to align with Docker documentation * docker_node_facts: Updated documentation and minimum version requirements * docker_node_facts: Updated documentation of requirements * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com>
2019-01-08 13:00:59 +00:00
min_docker_api_version='1.24',
)
client.fail_task_if_not_swarm_manager()
nodes = get_node_facts(client)
docker_node_facts: Read information about swarm node from swarm manager (#50571) * docker_node_facts: New module to read information about swarm node from swarm manager * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * docker_node_facts: min_docker_api_version and docker updated to align with Docker documentation * docker_node_facts: Updated documentation and minimum version requirements * docker_node_facts: Updated documentation of requirements * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com>
2019-01-08 13:00:59 +00:00
client.module.exit_json(
changed=False,
nodes=nodes,
docker_node_facts: Read information about swarm node from swarm manager (#50571) * docker_node_facts: New module to read information about swarm node from swarm manager * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * docker_node_facts: min_docker_api_version and docker updated to align with Docker documentation * docker_node_facts: Updated documentation and minimum version requirements * docker_node_facts: Updated documentation of requirements * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com> * Update lib/ansible/modules/cloud/docker/docker_node_facts.py * Update lib/ansible/modules/cloud/docker/docker_node_facts.py Co-Authored-By: WojciechowskiPiotr <23406016+WojciechowskiPiotr@users.noreply.github.com>
2019-01-08 13:00:59 +00:00
)
if __name__ == '__main__':
main()