community.docker.docker_context_info module – Retrieve information on Docker contexts for the current user
Note
This module is part of the community.docker collection (version 4.6.0).
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install community.docker
.
To use it in a playbook, specify: community.docker.docker_context_info
.
New in community.docker 4.4.0
Synopsis
Return information on Docker contexts.
This includes some generic information, as well as a
contexts[].config
dictionary that can be used for module defaults for all community.docker modules that use thecommunity.docker.docker
module defaults group.
Parameters
Parameter |
Comments |
---|---|
Override for the default context’s name. This is preferably used for context selection when |
|
A specific Docker CLI context to query. The module will fail if this context does not exist. If you simply want to query whether a context exists, do not specify this parameter and use Jinja2 to search the resulting list for a context of the given name instead. Mutually exclusive with |
|
Attributes
Attribute |
Support |
Description |
---|---|---|
Support: full This action does not modify state. |
Can run in |
|
Support: N/A This action does not modify state. |
Will return details on what has changed (or possibly needs changing in |
|
Support: full This action does not modify state. |
When run twice in a row outside check mode, with the same arguments, the second invocation indicates no change. This assumes that the system controlled/queried by the module has not changed in a relevant way. |
Examples
- name: Get infos on contexts
community.docker.docker_context_info:
register: result
- name: Show all contexts
ansible.builtin.debug:
msg: "{{ result.contexts }}"
- name: Get current context
community.docker.docker_context_info:
only_current: true
register: docker_current_context
- name: Run community.docker modules with current context
module_defaults:
group/community.docker.docker: "{{ docker_current_context.contexts[0].config }}"
block:
- name: Task using the current context
community.docker.docker_container:
image: ubuntu:latest
name: ubuntu
state: started
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
A list of all contexts ( Returned: success |
|
In case the context is for Docker, contains option values to configure the community.docker modules to use this context. Note that the exact values returned here and their values might change over time if incompatibilities to existing modules are found. The goal is that this configuration works fine with all modules in this collection, but we do not have the capabilities to test all possible configuration options at the moment. Returned: success Sample: |
|
The CA certificate used to validate the Docker daemon’s certificate. Returned: success, context is for Docker, TLS config is present, and CA cert is present Sample: |
|
The client certificate to authenticate with to the Docker daemon. Returned: success, context is for Docker, TLS config is present, and client cert info is present Sample: |
|
The client certificate’s key to authenticate with to the Docker daemon. Returned: success, context is for Docker, TLS config is present, and client cert info is present Sample: |
|
The Docker daemon to connect to. Returned: success and context is for Docker Sample: |
|
Whether the Docker context should use an unvalidated TLS connection. Returned: success and context is for Docker Sample: |
|
Whether the Docker context should use a validated TLS connection. Returned: success, context is for Docker, and TLS config is present Sample: |
|
Whether this context is the current one. Returned: success Sample: |
|
The context’s description, if available. Returned: success Sample: |
|
The path to the context’s meta directory. Not present for Returned: success Sample: |
|
The context’s name. Returned: success Sample: |
|
The path to the context’s TLS config directory. Not present for Returned: success Sample: |
|
The name of the current Docker context. Returned: success Sample: |