From 324bc4109751c8a0776f0d93a423c3840bee2fa0 Mon Sep 17 00:00:00 2001 From: rptaylor Date: Mon, 8 Jul 2019 06:44:35 -0700 Subject: [PATCH] Add support for Docker plugins (#4934) * Add support for Docker plugins * support multiple Docker plugins using looped include * fix yamllint error --- docs/vars.md | 1 + roles/container-engine/docker/tasks/docker_plugin.yml | 8 ++++++++ roles/container-engine/docker/tasks/main.yml | 6 ++++++ roles/kubespray-defaults/defaults/main.yaml | 4 ++++ 4 files changed, 19 insertions(+) create mode 100644 roles/container-engine/docker/tasks/docker_plugin.yml diff --git a/docs/vars.md b/docs/vars.md index b01dafd18..38d66bcd3 100644 --- a/docs/vars.md +++ b/docs/vars.md @@ -98,6 +98,7 @@ Stack](https://github.com/kubernetes-sigs/kubespray/blob/master/docs/dns-stack.m * *docker_options* - Commonly used to set ``--insecure-registry=myregistry.mydomain:5000`` +* *docker_plugins* - This list can be used to define [Docker plugins](https://docs.docker.com/engine/extend/) to install. * *http_proxy/https_proxy/no_proxy* - Proxy variables for deploying behind a proxy. Note that no_proxy defaults to all internal cluster IPs and hostnames that correspond to each node. diff --git a/roles/container-engine/docker/tasks/docker_plugin.yml b/roles/container-engine/docker/tasks/docker_plugin.yml new file mode 100644 index 000000000..8ee530e95 --- /dev/null +++ b/roles/container-engine/docker/tasks/docker_plugin.yml @@ -0,0 +1,8 @@ +--- +- name: Install Docker plugin + command: docker plugin install --grant-all-permissions {{ docker_plugin | quote }} + when: docker_plugin is defined + register: docker_plugin_status + failed_when: + - docker_plugin_status.failed + - '"already exists" not in docker_plugin_status.stderr' diff --git a/roles/container-engine/docker/tasks/main.yml b/roles/container-engine/docker/tasks/main.yml index 74f99c7d7..e44dca8d6 100644 --- a/roles/container-engine/docker/tasks/main.yml +++ b/roles/container-engine/docker/tasks/main.yml @@ -235,6 +235,12 @@ resolvconf_mode == 'docker_dns' and installed_docker_version.stdout is version('1.12', '<') +# Install each plugin using a looped include to make error handling in the included task simpler. +- include_tasks: docker_plugin.yml + loop: "{{ docker_plugins }}" + loop_control: + loop_var: docker_plugin + - name: Set docker systemd config import_tasks: systemd.yml diff --git a/roles/kubespray-defaults/defaults/main.yaml b/roles/kubespray-defaults/defaults/main.yaml index 76f863730..3f135c4de 100644 --- a/roles/kubespray-defaults/defaults/main.yaml +++ b/roles/kubespray-defaults/defaults/main.yaml @@ -256,6 +256,10 @@ docker_options: >- --userland-proxy-path=/usr/libexec/docker/docker-proxy-current --signature-verification=false {%- endif -%} +## A list of plugins to install using 'docker plugin install --grant-all-permissions' +## Empty by default so no plugins will be installed. +docker_plugins: [] + # Experimental kubeadm etcd deployment mode. Available only for new deployment etcd_kubeadm_enabled: false