Update role to allow docker volumes creation

This commit is contained in:
Catalina Sindrilaru 2024-03-18 12:57:45 +02:00
parent dc1c9a1606
commit 4e899dac5d
4 changed files with 27 additions and 0 deletions

View File

@ -1,5 +1,7 @@
# Ansible Role: Docker
Forked by Catalina Sindrilaru (Eau de Web) to allow the creation of volumes using the docker_volumes variable (see defaults/main.yml for an example).
[![CI](https://github.com/geerlingguy/ansible-role-docker/workflows/CI/badge.svg?event=push)](https://github.com/geerlingguy/ansible-role-docker/actions?query=workflow%3ACI)
An Ansible Role that installs [Docker](https://www.docker.com) on Linux.

View File

@ -56,3 +56,16 @@ docker_users: []
# Docker daemon options as a dict
docker_daemon_options: {}
# A list of docker volumes that will be created
docker_volumes: []
# Example:
# ---
# docker_volumes:
# - name: data
# driver_options:
# type: nfs
# o: addr=10.0.2.2,rw,nfsvers=4
# device: ":/data/"

9
tasks/docker-volumes.yml Normal file
View File

@ -0,0 +1,9 @@
---
- name: Create volumes with options
docker_volume:
name: "{{ item.name }}"
driver_options:
type: "{{ item.driver_options.type }}"
o: "{{ item.driver_options.o | default(omit) }}"
device: "{{ item.driver_options.device }}"
with_items: "{{ docker_volumes }}"

View File

@ -96,3 +96,6 @@
- include_tasks: docker-users.yml
when: at_least_one_user_to_modify is defined
- include_tasks: docker-volumes.yml
when: docker_volumes | length > 0