This commit is contained in:
felixfontein
2025-11-11 09:09:19 +00:00
parent 5c24cf5429
commit 993a0e6df8
41 changed files with 58 additions and 58 deletions
+4 -4
View File
@@ -193,7 +193,7 @@
</nav>
<section id="requirements">
<h2><a class="toc-backref" href="#id1" role="doc-backlink">Requirements</a><a class="headerlink" href="#requirements" title="Link to this heading"></a></h2>
<p>Most of the modules and plugins in community.docker require the <a class="reference external" href="https://docker-py.readthedocs.io/en/stable/">Docker SDK for Python</a>. The SDK needs to be installed on the machines where the modules and plugins are executed, and for the Python version(s) with which the modules and plugins are executed. You can use the <a class="reference external" href="https://docs.ansible.com/ansible/devel/collections/community/general/python_requirements_info_module.html#ansible-collections-community-general-python-requirements-info-module" title="(in Ansible vdevel)"><span>community.general.python_requirements_info module</span></a> to make sure that the Docker SDK for Python is installed on the correct machine and for the Python version used by Ansible.</p>
<p>Most of the modules and plugins in community.docker require the <a class="reference external" href="https://docker-py.readthedocs.io/en/stable/">Docker SDK for Python</a>. The SDK needs to be installed on the machines where the modules and plugins are executed, and for the Python version(s) with which the modules and plugins are executed. You can use the <a class="reference external" href="https://docs.ansible.com/projects/ansible/devel/collections/community/general/python_requirements_info_module.html#ansible-collections-community-general-python-requirements-info-module" title="(in Ansible vdevel)"><span>community.general.python_requirements_info module</span></a> to make sure that the Docker SDK for Python is installed on the correct machine and for the Python version used by Ansible.</p>
<p>Note that plugins (inventory plugins and connection plugins) are always executed in the context of Ansible itself. If you use a plugin that requires the Docker SDK for Python, you need to install it on the machine running <code class="docutils literal notranslate"><span class="pre">ansible</span></code> or <code class="docutils literal notranslate"><span class="pre">ansible-playbook</span></code> and for the same Python interpreter used by Ansible. To see which Python is used, run <code class="docutils literal notranslate"><span class="pre">ansible</span> <span class="pre">--version</span></code>.</p>
<p>You can install the Docker SDK for Python for Python 3.6 or later as follows:</p>
<div class="highlight-console notranslate"><div class="highlight"><pre><span></span><span class="gp">$ </span>pip<span class="w"> </span>install<span class="w"> </span>docker
@@ -239,7 +239,7 @@
</section>
<section id="module-default-group">
<h3>Module default group<a class="headerlink" href="#module-default-group" title="Link to this heading"></a></h3>
<p>To avoid having to specify common parameters for all the modules in every task, you can use the <code class="docutils literal notranslate"><span class="pre">community.docker.docker</span></code> <a class="reference external" href="https://docs.ansible.com/ansible/devel/playbook_guide/playbooks_module_defaults.html#module-defaults-groups" title="(in Ansible vdevel)"><span class="xref std std-ref">module defaults group</span></a>, or its short name <code class="docutils literal notranslate"><span class="pre">docker</span></code>.</p>
<p>To avoid having to specify common parameters for all the modules in every task, you can use the <code class="docutils literal notranslate"><span class="pre">community.docker.docker</span></code> <a class="reference external" href="https://docs.ansible.com/projects/ansible/devel/playbook_guide/playbooks_module_defaults.html#module-defaults-groups" title="(in Ansible vdevel)"><span class="xref std std-ref">module defaults group</span></a>, or its short name <code class="docutils literal notranslate"><span class="pre">docker</span></code>.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Module default groups only work for modules, not for plugins (connection and inventory plugins).</p>
@@ -342,11 +342,11 @@ by Docker SDK for Python.</p>
<p>For working with a plain Docker daemon, that is without Swarm, there are connection plugins, an inventory plugin, and several modules available:</p>
<blockquote>
<div><dl>
<dt>docker connection plugin</dt><dd><p>The <a class="reference internal" href="../docker_connection.html#ansible-collections-community-docker-docker-connection"><span class="std std-ref">community.docker.docker connection plugin</span></a> uses the Docker CLI utility to connect to Docker containers and execute modules in them. It essentially wraps <code class="docutils literal notranslate"><span class="pre">docker</span> <span class="pre">exec</span></code> and <code class="docutils literal notranslate"><span class="pre">docker</span> <span class="pre">cp</span></code>. This connection plugin is supported by the <a class="reference external" href="https://docs.ansible.com/ansible/devel/collections/ansible/posix/synchronize_module.html#ansible-collections-ansible-posix-synchronize-module" title="(in Ansible vdevel)"><span>ansible.posix.synchronize module</span></a>.</p>
<dt>docker connection plugin</dt><dd><p>The <a class="reference internal" href="../docker_connection.html#ansible-collections-community-docker-docker-connection"><span class="std std-ref">community.docker.docker connection plugin</span></a> uses the Docker CLI utility to connect to Docker containers and execute modules in them. It essentially wraps <code class="docutils literal notranslate"><span class="pre">docker</span> <span class="pre">exec</span></code> and <code class="docutils literal notranslate"><span class="pre">docker</span> <span class="pre">cp</span></code>. This connection plugin is supported by the <a class="reference external" href="https://docs.ansible.com/projects/ansible/devel/collections/ansible/posix/synchronize_module.html#ansible-collections-ansible-posix-synchronize-module" title="(in Ansible vdevel)"><span>ansible.posix.synchronize module</span></a>.</p>
</dd>
<dt>docker_api connection plugin</dt><dd><p>The <a class="reference internal" href="../docker_api_connection.html#ansible-collections-community-docker-docker-api-connection"><span class="std std-ref">community.docker.docker_api connection plugin</span></a> talks directly to the Docker daemon to connect to Docker containers and execute modules in them.</p>
</dd>
<dt>docker_containers inventory plugin</dt><dd><p>The <a class="reference internal" href="../docker_containers_inventory.html#ansible-collections-community-docker-docker-containers-inventory"><span class="std std-ref">community.docker.docker_containers inventory plugin</span></a> allows you to dynamically add Docker containers from a Docker Daemon to your Ansible inventory. See <a class="reference external" href="https://docs.ansible.com/ansible/devel/inventory_guide/intro_dynamic_inventory.html#dynamic-inventory" title="(in Ansible vdevel)"><span>Working with dynamic inventory</span></a> for details on dynamic inventories.</p>
<dt>docker_containers inventory plugin</dt><dd><p>The <a class="reference internal" href="../docker_containers_inventory.html#ansible-collections-community-docker-docker-containers-inventory"><span class="std std-ref">community.docker.docker_containers inventory plugin</span></a> allows you to dynamically add Docker containers from a Docker Daemon to your Ansible inventory. See <a class="reference external" href="https://docs.ansible.com/projects/ansible/devel/inventory_guide/intro_dynamic_inventory.html#dynamic-inventory" title="(in Ansible vdevel)"><span>Working with dynamic inventory</span></a> for details on dynamic inventories.</p>
<p>The <a class="reference external" href="https://github.com/ansible-community/contrib-scripts/blob/main/inventory/docker.py">docker inventory script</a> is deprecated. Please use the inventory plugin instead. The inventory plugin has several compatibility options. If you need to collect Docker containers from multiple Docker daemons, you need to add every Docker daemon as an individual inventory source.</p>
</dd>
<dt>docker_host_info module</dt><dd><p>The <a class="reference internal" href="../docker_host_info_module.html#ansible-collections-community-docker-docker-host-info-module"><span class="std std-ref">community.docker.docker_host_info module</span></a> allows you to retrieve information on a Docker daemon, such as all containers, images, volumes, networks and so on.</p>