From 44a0626fc87e9c8d267ca17cdfd16c43ac423cf4 Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Tue, 6 Feb 2018 13:35:40 +0000 Subject: [PATCH] roles: docker: Add support for SUSE distributions Add support for installing Docker on SUSE distributions. The Docker repository at https://yum.dockerproject.org/repo/main/ does not support recent openSUSE distributions so the only alternative is to use the packages from the distro repositories. This however renders the 'docker_version' Ansible variable useless on SUSE. --- roles/docker/tasks/main.yml | 16 ++++++++++++---- roles/docker/templates/docker.service.j2 | 6 ++++++ roles/docker/vars/suse.yml | 15 +++++++++++++++ 3 files changed, 33 insertions(+), 4 deletions(-) create mode 100644 roles/docker/vars/suse.yml diff --git a/roles/docker/tasks/main.yml b/roles/docker/tasks/main.yml index 729397b44..2b5c24f5e 100644 --- a/roles/docker/tasks/main.yml +++ b/roles/docker/tasks/main.yml @@ -15,6 +15,14 @@ tags: - facts +# https://yum.dockerproject.org/repo/main/opensuse/ contains packages for an EOL +# openSUSE version so we can't use it. The only alternative is to use the docker +# packages from the distribution repositories. +- name: Warn about Docker version on SUSE + debug: + msg: "SUSE distributions always install Docker from the distro repos" + when: ansible_pkg_mgr == 'zypper' + - include_tasks: set_facts_dns.yml when: dns_mode != 'none' and resolvconf_mode == 'docker_dns' tags: @@ -43,7 +51,7 @@ retries: 4 delay: "{{ retry_stagger | random + 3 }}" with_items: "{{ docker_repo_key_info.repo_keys }}" - when: not (ansible_os_family in ["CoreOS", "Container Linux by CoreOS", "RedHat"] or is_atomic) + when: not (ansible_os_family in ["CoreOS", "Container Linux by CoreOS", "RedHat", "Suse"] or is_atomic) - name: ensure docker-ce repository is enabled action: "{{ docker_repo_info.pkg_repo }}" @@ -51,7 +59,7 @@ repo: "{{item}}" state: present with_items: "{{ docker_repo_info.repos }}" - when: not (ansible_os_family in ["CoreOS", "Container Linux by CoreOS", "RedHat"] or is_atomic) and (docker_repo_info.repos|length > 0) + when: not (ansible_os_family in ["CoreOS", "Container Linux by CoreOS", "RedHat", "Suse"] or is_atomic) and (docker_repo_info.repos|length > 0) - name: ensure docker-engine repository public key is installed action: "{{ dockerproject_repo_key_info.pkg_key }}" @@ -64,7 +72,7 @@ retries: 4 delay: "{{ retry_stagger | random + 3 }}" with_items: "{{ dockerproject_repo_key_info.repo_keys }}" - when: not (ansible_os_family in ["CoreOS", "Container Linux by CoreOS", "RedHat"] or is_atomic) + when: not (ansible_os_family in ["CoreOS", "Container Linux by CoreOS", "RedHat", "Suse"] or is_atomic) - name: ensure docker-engine repository is enabled action: "{{ dockerproject_repo_info.pkg_repo }}" @@ -72,7 +80,7 @@ repo: "{{item}}" state: present with_items: "{{ dockerproject_repo_info.repos }}" - when: not (ansible_os_family in ["CoreOS", "Container Linux by CoreOS", "RedHat"] or is_atomic) and (dockerproject_repo_info.repos|length > 0) + when: not (ansible_os_family in ["CoreOS", "Container Linux by CoreOS", "RedHat", "Suse"] or is_atomic) and (dockerproject_repo_info.repos|length > 0) - name: Configure docker repository on RedHat/CentOS template: diff --git a/roles/docker/templates/docker.service.j2 b/roles/docker/templates/docker.service.j2 index d8efe2025..8dc82bbb2 100644 --- a/roles/docker/templates/docker.service.j2 +++ b/roles/docker/templates/docker.service.j2 @@ -7,6 +7,9 @@ Wants=docker-storage-setup.service {% elif ansible_os_family == "Debian" %} After=network.target docker.socket Wants=docker.socket +{% elif ansible_os_family == "Suse" %} +After=network.target containerd.socket containerd.service +Requires=containerd.socket containerd.service {% endif %} [Service] @@ -19,6 +22,9 @@ ExecReload=/bin/kill -s HUP $MAINPID Delegate=yes KillMode=process ExecStart={{ docker_bin_dir }}/docker{% if installed_docker_version.stdout|version_compare('17.03', '<') %} daemon{% else %}d{% endif %} \ +{% if ansible_os_family == "Suse" %} + --containerd /run/containerd/containerd.sock --add-runtime oci=/usr/bin/docker-runc \ +{% endif %} $DOCKER_OPTS \ $DOCKER_STORAGE_OPTIONS \ $DOCKER_NETWORK_OPTIONS \ diff --git a/roles/docker/vars/suse.yml b/roles/docker/vars/suse.yml new file mode 100644 index 000000000..d89a50a7f --- /dev/null +++ b/roles/docker/vars/suse.yml @@ -0,0 +1,15 @@ +--- +docker_kernel_min_version: '0' + +docker_package_info: + pkg_mgr: zypper + pkgs: + - name: docker + +docker_repo_key_info: + pkg_key: '' + repo_keys: [] + +docker_repo_info: + pkg_repo: '' + repos: []