From d5e959d15cf0d1140b20e7318427b47be744edb1 Mon Sep 17 00:00:00 2001 From: Bill Metangmo Date: Tue, 17 Nov 2020 18:07:33 +0100 Subject: [PATCH] Added capabilty to configure docker/containerd root path --- defaults/main.yml | 6 ++++++ tasks/main.yml | 16 ++++++++++++++++ templates/config.toml.j2 | 31 +++++++++++++++++++++++++++++++ templates/daemon.json.j2 | 4 ++++ 4 files changed, 57 insertions(+) create mode 100644 templates/config.toml.j2 create mode 100644 templates/daemon.json.j2 diff --git a/defaults/main.yml b/defaults/main.yml index fc8d79e..772ca7a 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -29,3 +29,9 @@ docker_yum_gpg_key: https://download.docker.com/linux/centos/gpg # A list of users who will be added to the docker group. docker_users: [] + +# configuration +docker_default_config: true +docker_root_path: "" +containerd_root_path: "" +docker_native_cgroup: "" diff --git a/tasks/main.yml b/tasks/main.yml index 56449ef..18c7193 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -25,3 +25,19 @@ - include_tasks: docker-users.yml when: docker_users | length > 0 + +- name: Configure docker + template: + src: daemon.json.j2 + dest: /etc/docker/daemon.json + mode: 0666 + notify: restart docker + when: not docker_default_config + +- name: Configure containerd + template: + src: config.toml.j2 + dest: /etc/containerd/config.toml + mode: 0666 + notify: restart docker + when: not docker_default_config diff --git a/templates/config.toml.j2 b/templates/config.toml.j2 new file mode 100644 index 0000000..254424b --- /dev/null +++ b/templates/config.toml.j2 @@ -0,0 +1,31 @@ +# Copyright 2018-2020 Docker Inc. + +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +disabled_plugins = ["cri"] + +root = "{{ containerd_root_path }}" +#state = "/run/containerd" +#subreaper = true +#oom_score = 0 + +#[grpc] +# address = "/run/containerd/containerd.sock" +# uid = 0 +# gid = 0 + +#[debug] +# address = "/run/containerd/debug.sock" +# uid = 0 +# gid = 0 +# level = "info" \ No newline at end of file diff --git a/templates/daemon.json.j2 b/templates/daemon.json.j2 new file mode 100644 index 0000000..71a6b9e --- /dev/null +++ b/templates/daemon.json.j2 @@ -0,0 +1,4 @@ +{ + "data-root": "{{docker_root_path}}", + "exec-opts": ["native.cgroupdriver={{docker_native_cgroup}}"] +} \ No newline at end of file