Community Docker Collection for Ansible: modules and plugins for working with Docker
Go to file
András Maróy b481fa4801
Add support for rotating docker secrets (#293)
* Add parameters for rolling updates to `docker_secret`

* Extract `remove_secrets` to its own function in `docker_secret`

* Store existing secrets in a list instead of a single secret

With this change `docker_secret` now supports the case where we store
multiple versions of a secret with the `_v123` postfix.

`absent` state implicitly handles removing these this way.

* When using `rolling_versions` don't automatically remove current secret

To make rolling updates actually work instead of failing on trying to
remove a secret that is attached to a service, use the
`versions_to_keep` parameter to remove old versions of the secret after
creating the new one. This way the secret with the new data is created
with a different name and can be attached to the service by its ID
without having to delete the previous one first which would fail if it
is already attached to a service.

* Add version numbers to newly created secrets

Attach the incremental version number to the secret name as a `_v123`
postfix where `123` is replaced with an incremental counter starting
from 1.
A label with the numeric version is also attached to the secret to ease
calculating the new version number upon change with the name
`ansible_version`.

* Return `secret_name` for docker secrets as well

* Add integration test for rolling secrets

* Update `docker_secret` documentation as per review comments

* Correctly return `docker_secret` version number as int

* Use template string for naming `docker_secrets` instead of concatenation

* Return the correct secret name on deletion failure

* Simplify `docker_secret` creation

* Add missing comma for `docker_secret` schema

* Only remove old docker secrets if `rolling_versions` is set

* Add check in `docker_secret` version parsing to handle NaNs

* Add newly created `docker_secret` to internal secret list to avoid additional deletions

* Add changelog fragment for `docker_secret` `rolling_versions` feature

* Update changelogs/fragments/270-rolling-secrets.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

Co-authored-by: Felix Fontein <felix@fontein.de>
2022-02-12 08:29:49 +01:00
.azure-pipelines Replace RHEL 8.4 by RHEL 8.5 for devel. (#237) 2021-11-17 07:17:26 +01:00
.github Revert "[TEMPORARY - will be reverted soon] Use docs build workflow from my branch." 2022-01-10 06:44:09 +01:00
changelogs Add support for rotating docker secrets (#293) 2022-02-12 08:29:49 +01:00
docs/docsite Fix URL to docker inventory script. (#148) 2021-06-03 21:37:59 +02:00
meta Looks like we forgot to add the new modules to the action_group. (#209) 2021-09-18 17:07:35 +02:00
plugins Add support for rotating docker secrets (#293) 2022-02-12 08:29:49 +01:00
tests Add support for rotating docker secrets (#293) 2022-02-12 08:29:49 +01:00
.gitignore Initial commit 2020-10-30 07:05:51 +01:00
CHANGELOG.rst Release 2.1.1. 2022-01-05 22:33:40 +01:00
COPYING Initial cleanup. 2020-10-30 07:05:51 +01:00
galaxy.yml Next expected release is 2.2.0. 2022-01-06 13:11:24 +01:00
README.md Update CI matrix to include ansible-core's stable-2.12 branch (#215) 2021-09-27 19:45:54 +02:00

Docker Community Collection

Doc Build Status Codecov

This repo contains the community.docker Ansible Collection. The collection includes many modules and plugins to work with Docker.

Please note that this collection does not support Windows targets. The connection plugins included in this collection support Windows targets on a best-effort basis, but we are not testing this in CI.

Tested with Ansible

Tested with the current Ansible 2.9, ansible-base 2.10, ansible-core 2.11 and ansible-core 2.12 releases and the current development version of ansible-core. Ansible versions before 2.9.10 are not supported.

External requirements

Most modules and plugins require the Docker SDK for Python. For Python 2.6 support, use the deprecated docker-py library instead.

Both libraries cannot be installed at the same time. If you accidentally did install them simultaneously, you have to uninstall both before re-installing one of them.

Included content

  • Connection plugins:
    • community.docker.docker: use Docker containers as remotes
  • Inventory plugins:
    • community.docker.docker_machine: collect Docker machines as inventory
    • community.docker.docker_swarm: collect Docker Swarm nodes as inventory
  • Modules:
    • Docker:
      • community.docker.docker_container: manage Docker containers
      • community.docker.docker_container_exec: run commands in Docker containers
      • community.docker.docker_container_info: retrieve information on Docker containers
      • community.docker.docker_host_info: retrieve information on the Docker daemon
      • community.docker.docker_image: manage Docker images
      • community.docker.docker_image_info: retrieve information on Docker images
      • community.docker.docker_image_load: load Docker images from archives
      • community.docker.docker_login: log in and out to/from registries
      • community.docker.docker_network: manage Docker networks
      • community.docker.docker_network_info: retrieve information on Docker networks
      • community.docker.docker_plugin: manage Docker plugins
      • community.docker.docker_prune: prune Docker containers, images, networks, volumes, and build data
      • community.docker.docker_volume: manage Docker volumes
      • community.docker.docker_volume_info: retrieve information on Docker volumes
    • Docker Compose:
      • community.docker.docker_compose: manage Docker Compose files
    • Docker Swarm:
      • community.docker.docker_config: manage configurations
      • community.docker.docker_node: manage Docker Swarm nodes
      • community.docker.docker_node_info: retrieve information on Docker Swarm nodes
      • community.docker.docker_secret: manage secrets
      • community.docker.docker_swarm: manage Docker Swarm
      • community.docker.docker_swarm_info: retrieve information on Docker Swarm
      • community.docker.docker_swarm_service: manage Docker Swarm services
      • community.docker.docker_swarm_service_info: retrieve information on Docker Swarm services
    • Docker Stack:
      • community.docker.docker_stack: manage Docker Stacks
      • community.docker.docker_stack_info: retrieve information on Docker Stacks
      • community.docker.docker_stack_task_info: retrieve information on tasks in Docker Stacks
    • Other:
      • current_container_facts: return facts about whether the module runs in a Docker container

Using this collection

Before using the General community collection, you need to install the collection with the ansible-galaxy CLI:

ansible-galaxy collection install community.docker

You can also include it in a requirements.yml file and install it via ansible-galaxy collection install -r requirements.yml using the format:

collections:
- name: community.docker

See Ansible Using collections for more details.

Contributing to this collection

If you want to develop new content for this collection or improve what is already here, the easiest way to work on the collection is to clone it into one of the configured COLLECTIONS_PATH, and work on it there.

You can find more information in the developer guide for collections, and in the Ansible Community Guide.

Release notes

See the changelog.

More information

Licensing

GNU General Public License v3.0 or later.

See COPYING to see the full text.