From 196995a1a75f768d52558459bd4aff76ed559454 Mon Sep 17 00:00:00 2001 From: "rong.zhang" Date: Mon, 12 Mar 2018 11:05:12 +0800 Subject: [PATCH] Fix issues#2451 Support docker-ce and docker-engine Support docker-ce and docker-engine include redhat/centos ubuntu debian --- roles/docker/defaults/main.yml | 11 +++++++++ roles/docker/tasks/main.yml | 29 ++++++++++++++++++++---- roles/docker/templates/rh_docker.repo.j2 | 12 ++++++++-- roles/docker/vars/debian.yml | 15 ++++++++++++ roles/docker/vars/redhat.yml | 6 ++++- roles/docker/vars/ubuntu.yml | 18 ++++++++++++++- 6 files changed, 83 insertions(+), 8 deletions(-) diff --git a/roles/docker/defaults/main.yml b/roles/docker/defaults/main.yml index 2bbd62835..df7b97ab4 100644 --- a/roles/docker/defaults/main.yml +++ b/roles/docker/defaults/main.yml @@ -11,6 +11,12 @@ docker_repo_key_info: docker_repo_info: repos: +dockerproject_repo_key_info: + repo_keys: + +dockerproject_repo_info: + repos: + docker_dns_servers_strict: yes docker_container_storage_setup: false @@ -24,3 +30,8 @@ docker_ubuntu_repo_gpgkey: 'https://download.docker.com/linux/ubuntu/gpg' #Debian docker-ce repo docker_debian_repo_base_url: "https://download.docker.com/linux/debian" docker_debian_repo_gpgkey: 'https://download.docker.com/linux/debian/gpg' +#dockerproject repo +dockerproject_rh_repo_base_url: 'https://yum.dockerproject.org/repo/main/centos/7' +dockerproject_rh_repo_gpgkey: 'https://yum.dockerproject.org/gpg' +dockerproject_apt_repo_base_url: 'https://apt.dockerproject.org/repo' +dockerproject_apt_repo_gpgkey: 'https://apt.dockerproject.org/gpg' diff --git a/roles/docker/tasks/main.yml b/roles/docker/tasks/main.yml index 1c95f819f..80b917114 100644 --- a/roles/docker/tasks/main.yml +++ b/roles/docker/tasks/main.yml @@ -30,7 +30,7 @@ tags: - facts -- name: ensure docker repository public key is installed +- name: ensure docker-ce repository public key is installed action: "{{ docker_repo_key_info.pkg_key }}" args: id: "{{item}}" @@ -41,15 +41,36 @@ 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"] or is_atomic) + when: not (ansible_os_family in ["CoreOS", "Container Linux by CoreOS", "RedHat"] or is_atomic) -- name: ensure docker repository is enabled +- name: ensure docker-ce repository is enabled action: "{{ docker_repo_info.pkg_repo }}" args: repo: "{{item}}" state: present with_items: "{{ docker_repo_info.repos }}" - when: not (ansible_os_family in ["CoreOS", "Container Linux by CoreOS"] or is_atomic) and (docker_repo_info.repos|length > 0) + when: not (ansible_os_family in ["CoreOS", "Container Linux by CoreOS", "RedHat"] 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 }}" + args: + id: "{{item}}" + url: "{{dockerproject_repo_key_info.url}}" + state: present + register: keyserver_task_result + until: keyserver_task_result|succeeded + 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) + +- name: ensure docker-engine repository is enabled + action: "{{ dockerproject_repo_info.pkg_repo }}" + args: + 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) - name: Configure docker repository on RedHat/CentOS template: diff --git a/roles/docker/templates/rh_docker.repo.j2 b/roles/docker/templates/rh_docker.repo.j2 index 7cb728625..fe2aeac1c 100644 --- a/roles/docker/templates/rh_docker.repo.j2 +++ b/roles/docker/templates/rh_docker.repo.j2 @@ -1,7 +1,15 @@ -[dockerrepo] -name=Docker Repository +[docker-ce] +name=Docker-CE Repository baseurl={{ docker_rh_repo_base_url }} enabled=1 gpgcheck=1 gpgkey={{ docker_rh_repo_gpgkey }} {% if http_proxy is defined %}proxy={{ http_proxy }}{% endif %} + +[docker-engine] +name=Docker-Engine Repository +baseurl={{ dockerproject_rh_repo_base_url }} +enabled=1 +gpgcheck=1 +gpgkey={{ dockerproject_rh_repo_gpgkey }} +{% if http_proxy is defined %}proxy={{ http_proxy }}{% endif %} diff --git a/roles/docker/vars/debian.yml b/roles/docker/vars/debian.yml index 0a43c7c79..a17cd7575 100644 --- a/roles/docker/vars/debian.yml +++ b/roles/docker/vars/debian.yml @@ -2,6 +2,7 @@ docker_kernel_min_version: '3.10' # https://download.docker.com/linux/debian/ +# https://apt.dockerproject.org/repo/dists/debian-wheezy/main/filelist docker_versioned_pkg: 'latest': docker-ce '1.11': docker-engine=1.11.2-0~{{ ansible_distribution_release|lower }} @@ -30,3 +31,17 @@ docker_repo_info: deb {{ docker_debian_repo_base_url }} {{ ansible_distribution_release|lower }} stable + +dockerproject_repo_key_info: + pkg_key: apt_key + url: '{{ dockerproject_apt_repo_gpgkey }}' + repo_keys: + - 58118E89F3A912897C070ADBF76221572C52609D + +dockerproject_repo_info: + pkg_repo: apt_repository + repos: + - > + deb {{ dockerproject_apt_repo_base_url }} + {{ ansible_distribution|lower }}-{{ ansible_distribution_release|lower }} + main diff --git a/roles/docker/vars/redhat.yml b/roles/docker/vars/redhat.yml index 96950719e..39ba211d8 100644 --- a/roles/docker/vars/redhat.yml +++ b/roles/docker/vars/redhat.yml @@ -3,6 +3,7 @@ docker_kernel_min_version: '0' # https://docs.docker.com/engine/installation/linux/centos/#install-from-a-package # https://download.docker.com/linux/centos/7/x86_64/stable/Packages/ +# https://yum.dockerproject.org/repo/main/centos/7 # or do 'yum --showduplicates list docker-engine' docker_versioned_pkg: 'latest': docker-ce @@ -11,10 +12,13 @@ docker_versioned_pkg: '1.13': docker-engine-1.13.1-1.el7.centos '17.03': docker-ce-17.03.2.ce-1.el7.centos 'stable': docker-ce-17.03.2.ce-1.el7.centos - 'edge': docker-ce-17.03.2.ce-1.el7.centos + 'edge': docker-ce-17.12.1.ce-1.el7.centos docker_selinux_versioned_pkg: 'latest': docker-ce-selinux + '1.11': docker-engine-selinux-1.11.2-1.el7.centos + '1.12': docker-engine-selinux-1.12.6-1.el7.centos + '1.13': docker-engine-selinux-1.13.1-1.el7.centos '17.03': docker-ce-selinux-17.03.2.ce-1.el7.centos 'stable': docker-ce-selinux-17.03.2.ce-1.el7.centos 'edge': docker-ce-selinux-17.03.2.ce-1.el7.centos diff --git a/roles/docker/vars/ubuntu.yml b/roles/docker/vars/ubuntu.yml index 897c23ce0..f4d6b1e0f 100644 --- a/roles/docker/vars/ubuntu.yml +++ b/roles/docker/vars/ubuntu.yml @@ -4,10 +4,12 @@ docker_kernel_min_version: '3.10' # https://download.docker.com/linux/ubuntu/ docker_versioned_pkg: 'latest': docker-ce - '1.11': docker-engine=1.11.1-0~{{ ansible_distribution_release|lower }} + '1.11': docker-engine=1.11.2-0~{{ ansible_distribution_release|lower }} '1.12': docker-engine=1.12.6-0~ubuntu-{{ ansible_distribution_release|lower }} '1.13': docker-engine=1.13.1-0~ubuntu-{{ ansible_distribution_release|lower }} '17.03': docker-ce=17.03.2~ce-0~ubuntu-{{ ansible_distribution_release|lower }} + 'stable': docker-ce=17.03.2~ce-0~ubuntu-{{ ansible_distribution_release|lower }} + 'edge': docker-ce=17.12.1~ce-0~ubuntu-{{ ansible_distribution_release|lower }} docker_package_info: pkg_mgr: apt @@ -28,3 +30,17 @@ docker_repo_info: deb {{ docker_ubuntu_repo_base_url }} {{ ansible_distribution_release|lower }} stable + +dockerproject_repo_key_info: + pkg_key: apt_key + url: '{{ dockerproject_apt_repo_gpgkey }}' + repo_keys: + - 58118E89F3A912897C070ADBF76221572C52609D + +dockerproject_repo_info: + pkg_repo: apt_repository + repos: + - > + deb {{ dockerproject_apt_repo_base_url }} + {{ ansible_distribution|lower }}-{{ ansible_distribution_release|lower }} + main