community / community.general / 0.2.1 / module / docker_host_info Retrieves facts about docker host and lists of objects of the services. Authors: Piotr Wojciechowski (@WojciechowskiPiotr)community.general.docker_host_info (0.2.1) — module
Install with ansible-galaxy collection install community.general:==0.2.1
collections: - name: community.general version: 0.2.1
Retrieves facts about a docker host.
Essentially returns the output of C(docker system info).
The module also allows to list object names for containers, images, networks and volumes. It also allows to query information on disk usage.
The output differs depending on API version of the docker daemon.
If the docker daemon cannot be contacted or does not meet the API version requirements, the module will fail.
- name: Get info on docker host docker_host_info: register: result
- name: Get info on docker host and list images docker_host_info: images: yes register: result
- name: Get info on docker host and list images matching the filter docker_host_info: images: yes images_filters: label: "mylabel" register: result
- name: Get info on docker host and verbose list images docker_host_info: images: yes verbose_output: yes register: result
- name: Get info on docker host and used disk space docker_host_info: disk_usage: yes register: result
- debug: var: result.host_info
tls: default: false description: - Secure the connection to the API by using TLS without verifying the authenticity of the Docker host server. Note that if I(validate_certs) is set to C(yes) as well, it will take precedence. - If the value is not specified in the task, the value of environment variable C(DOCKER_TLS) will be used instead. If the environment variable is not set, the default value will be used. type: bool debug: default: false description: - Debug mode type: bool images: default: false description: - Whether to list images. 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. - If the value is not specified in the task and the environment variable C(DOCKER_CERT_PATH) is set, the file C(ca.pem) from the directory specified in the environment variable C(DOCKER_CERT_PATH) will be used. type: path timeout: 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 C(DOCKER_TIMEOUT) will be used instead. If the environment variable is not set, the default value will be used. type: int volumes: default: false description: - Whether to list volumes. type: bool networks: default: false description: - Whether to list networks. type: bool client_key: aliases: - tls_client_key - key_path description: - Path to the client's TLS key file. - If the value is not specified in the task and the environment variable C(DOCKER_CERT_PATH) is set, the file C(key.pem) from the directory specified in the environment variable C(DOCKER_CERT_PATH) will be used. type: path containers: default: false description: - Whether to list containers. type: bool disk_usage: default: false description: - Summary information on used disk space by all Docker layers. - The output is a sum of images, volumes, containers and build cache. type: bool api_version: aliases: - docker_api_version default: auto 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 and the docker daemon. - If the value is not specified in the task, the value of environment variable C(DOCKER_API_VERSION) will be used instead. If the environment variable is not set, the default value will be used. type: str client_cert: aliases: - tls_client_cert - cert_path description: - Path to the client's TLS certificate file. - If the value is not specified in the task and the environment variable C(DOCKER_CERT_PATH) is set, the file C(cert.pem) from the directory specified in the environment variable C(DOCKER_CERT_PATH) will be used. type: path docker_host: aliases: - docker_url default: unix://var/run/docker.sock description: - The URL or Unix socket path used to connect to the Docker API. To connect to a remote host, provide the TCP connection string. For example, C(tcp://192.0.2.23:2376). If TLS is used to encrypt the connection, the module will automatically replace C(tcp) in the connection URL with C(https). - If the value is not specified in the task, the value of environment variable C(DOCKER_HOST) will be used instead. If the environment variable is not set, the default value will be used. type: str ssl_version: description: - Provide a valid SSL version number. Default value determined by ssl.py module. - If the value is not specified in the task, the value of environment variable C(DOCKER_SSL_VERSION) will be used instead. type: str tls_hostname: default: localhost description: - When verifying the authenticity of the Docker Host server, provide the expected name of the server. - If the value is not specified in the task, the value of environment variable C(DOCKER_TLS_HOSTNAME) will be used instead. If the environment variable is not set, the default value will be used. type: str images_filters: description: - A dictionary of filter values used for selecting images to list. - 'For example, C(dangling: true).' - See L(the docker documentation,https://docs.docker.com/engine/reference/commandline/image_prune/#filtering) for more information on possible filters. type: dict validate_certs: aliases: - tls_verify default: false description: - Secure the connection to the API by using TLS and verifying the authenticity of the Docker host server. - If the value is not specified in the task, the value of environment variable C(DOCKER_TLS_VERIFY) will be used instead. If the environment variable is not set, the default value will be used. type: bool verbose_output: default: false description: - When set to C(yes) and I(networks), I(volumes), I(images), I(containers) or I(disk_usage) is set to C(yes) then output will contain verbose information about objects matching the full output of API method. For details see the documentation of your version of Docker API at L(https://docs.docker.com/engine/api/). - The verbose output in this module contains only subset of information returned by I(_info) module for each type of the objects. type: bool volumes_filters: description: - A dictionary of filter values used for selecting volumes to list. - See L(the docker documentation,https://docs.docker.com/engine/reference/commandline/volume_prune/#filtering) for more information on possible filters. type: dict networks_filters: description: - A dictionary of filter values used for selecting networks to list. - See L(the docker documentation,https://docs.docker.com/engine/reference/commandline/network_prune/#filtering) for more information on possible filters. type: dict containers_filters: description: - A dictionary of filter values used for selecting containers to list. - 'For example, C(until: 24h).' - See L(the docker documentation,https://docs.docker.com/engine/reference/commandline/container_prune/#filtering) for more information on possible filters. type: dict
can_talk_to_docker: description: - Will be C(true) if the module can talk to the docker daemon. returned: both on success and on error type: bool 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). elements: dict returned: When I(containers) is C(yes) type: list 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). returned: When I(disk_usage) is C(yes) type: dict host_info: description: - Facts representing the basic state of the docker host. Matches the C(docker system info) output. returned: always type: dict 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). elements: dict returned: When I(images) is C(yes) type: 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). elements: dict returned: When I(networks) is C(yes) type: 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). elements: dict returned: When I(volumes) is C(yes) type: list