community.docker.docker_swarm (3.5.0) — inventory

Ansible dynamic inventory plugin for Docker swarm nodes.

Authors: Stefan Heitmüller (@morph027) <stefan.heitmueller@gmx.com>

Install collection

Install with ansible-galaxy collection install community.docker:==3.5.0


Add to requirements.yml

  collections:
    - name: community.docker
      version: 3.5.0

Description

Reads inventories from the Docker swarm API.

Uses a YAML configuration file docker_swarm.[yml|yaml].

The plugin returns following groups of swarm nodes: C(all) - all hosts; C(workers) - all worker nodes; C(managers) - all manager nodes; C(leader) - the swarm leader node; C(nonleaders) - all nodes except the swarm leader.


Requirements

Inputs

    
tls:
    default: false
    description: Connect using TLS without verifying the authenticity of the Docker host
      server.
    type: bool

groups:
    default: {}
    description: Add hosts to group based on Jinja2 conditionals.
    type: dict

plugin:
    choices:
    - docker_swarm
    - community.docker.docker_swarm
    description: The name of this plugin, it should always be set to V(community.docker.docker_swarm)
      for this plugin to recognize it as it's own.
    required: true
    type: str

strict:
    default: false
    description:
    - If V(yes) make invalid entries a fatal error, otherwise skip and continue.
    - Since it is possible to use facts in the expressions they might not always be available
      and we ignore those errors by default.
    type: bool

ca_cert:
    aliases:
    - tls_ca_cert
    - cacert_path
    description: Use a CA certificate when performing server verification by providing
      the path to a CA certificate file.
    type: path

compose:
    default: {}
    description: Create vars from jinja2 expressions.
    type: dict

timeout:
    aliases:
    - time_out
    default: 60
    description:
    - The maximum amount of time in seconds to wait on a response from the API.
    - If the value is not specified in the task, the value of environment variable E(DOCKER_TIMEOUT).
      will be used instead. If the environment variable is not set, the default value
      will be used.
    type: int

client_key:
    aliases:
    - tls_client_key
    - key_path
    description: Path to the client's TLS key file.
    type: path

api_version:
    aliases:
    - docker_api_version
    description:
    - The version of the Docker API running on the Docker Host.
    - Defaults to the latest version of the API supported by Docker SDK for Python.
    type: str

client_cert:
    aliases:
    - tls_client_cert
    - cert_path
    description: Path to the client's TLS certificate file.
    type: path

docker_host:
    aliases:
    - docker_url
    description:
    - Socket of a Docker swarm manager node (C(tcp), C(unix)).
    - Use V(unix://var/run/docker.sock) to connect via local socket.
    required: true
    type: str

ssl_version:
    description:
    - Provide a valid SSL version number. Default value determined by L(SSL Python module,
      https://docs.python.org/3/library/ssl.html).
    type: str

keyed_groups:
    default: []
    description: Add hosts to group based on the values of a variable.
    elements: dict
    suboptions:
      default_value:
        description:
        - The default value when the host variable's value is an empty string.
        - This option is mutually exclusive with O(keyed_groups[].trailing_separator).
        type: str
        version_added: '2.12'
        version_added_collection: ansible.builtin
      key:
        description:
        - The key from input dictionary used to generate groups
        type: str
      parent_group:
        description: parent group for keyed group
        type: str
      prefix:
        default: ''
        description: A keyed group name will start with this prefix
        type: str
      separator:
        default: _
        description: separator used to build the keyed group name
        type: str
      trailing_separator:
        default: true
        description:
        - Set this option to V(False) to omit the O(keyed_groups[].separator) after the
          host variable when the value is an empty string.
        - This option is mutually exclusive with O(keyed_groups[].default_value).
        type: bool
        version_added: '2.12'
        version_added_collection: ansible.builtin
    type: list

tls_hostname:
    description: When verifying the authenticity of the Docker host server, provide the
      expected name of the server.
    type: str

use_extra_vars:
    default: false
    description: Merge extra vars into the available variables for composition (highest
      precedence).
    env:
    - name: ANSIBLE_INVENTORY_USE_EXTRA_VARS
    ini:
    - key: use_extra_vars
      section: inventory_plugins
    type: bool
    version_added: '2.11'
    version_added_collection: ansible.builtin

use_ssh_client:
    default: false
    description:
    - For SSH transports, use the C(ssh) CLI tool instead of paramiko.
    - Requires Docker SDK for Python 4.4.0 or newer.
    type: bool
    version_added: 1.5.0
    version_added_collection: community.docker

validate_certs:
    aliases:
    - tls_verify
    default: false
    description: Toggle if connecting using TLS with or without verifying the authenticity
      of the Docker host server.
    type: bool

verbose_output:
    default: true
    description: Toggle to (not) include all available nodes metadata (for example C(Platform),
      C(Architecture), C(OS), C(EngineVersion)).
    type: bool

include_host_uri:
    default: false
    description: Toggle to return the additional attribute C(ansible_host_uri) which contains
      the URI of the swarm leader in format of V(tcp://172.16.0.1:2376). This value may
      be used without additional modification as value of option O(docker_host) in Docker
      Swarm modules when connecting via API. The port always defaults to V(2376).
    type: bool

leading_separator:
    default: true
    description:
    - Use in conjunction with keyed_groups.
    - By default, a keyed group that does not have a prefix or a separator provided will
      have a name that starts with an underscore.
    - This is because the default prefix is "" and the default separator is "_".
    - Set this option to False to omit the leading underscore (or other separator) if
      no prefix is given.
    - If the group name is derived from a mapping the separator is still used to concatenate
      the items.
    - To not use a separator in the group name at all, set the separator for the keyed
      group to an empty string instead.
    type: boolean
    version_added: '2.11'
    version_added_collection: ansible.builtin

include_host_uri_port:
    description: Override the detected port number included in C(ansible_host_uri).
    type: int