Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to configure Docker daemon options #92

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ Docker Compose installation options.

A list of system users to be added to the `docker` group (so they can use Docker on the server).

docker_daemon_options:
storage-driver: "devicemapper"
log-opts:
max-size: "100m"

Custom `dockerd` options can be configured through this dictionary representing the json file `/etc/docker/daemon.json`.

## Use with Ansible (and `docker` Python library)

Many users of this role wish to also use Ansible to then _build_ Docker images and manage Docker containers on the server where Docker is installed. In this case, you can easily add in the `docker` Python library using the `geerlingguy.pip` role:
Expand Down
3 changes: 3 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ docker_yum_repo_enable_test: 0

# A list of users who will be added to the docker group.
docker_users: []

# Docker daemon options
docker_daemon_options: {}
12 changes: 12 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@
state: "{{ docker_service_state }}"
enabled: "{{ docker_service_enabled }}"

- name: Ensure /etc/docker/ directory exists.
file:
path: /etc/docker
state: directory
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The last thing I'd like to make sure to do is not touch the file if the default (docker_daemon_options: {}) is set.

That way (a) existing role users won't have that file wiped out if it currently contains things and they update the role, and (b) people can manage the file on their own simply by not setting the option in this role's vars.


- name: Configure Docker daemon options.
copy:
content: "{{ docker_daemon_options | to_nice_json }}"
dest: /etc/docker/daemon.json
mode: 0644
notify: restart docker

- name: Ensure handlers are notified now to avoid firewall conflicts.
meta: flush_handlers

Expand Down