install docker on a largest number of linux distribution (based on https://github.com/marklee77/ansible-role-docker)
This commit is contained in:
parent
005ddedb94
commit
9f07f2a951
18 changed files with 273 additions and 89 deletions
20
roles/common/defaults/main.yml
Normal file
20
roles/common/defaults/main.yml
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
---
|
||||||
|
etcd_version: v2.2.2
|
||||||
|
flannel_version: 0.5.5
|
||||||
|
|
||||||
|
kube_version: v1.1.3
|
||||||
|
kubectl_checksum: "01b9bea18061a27b1cf30e34fd8ab45cfc096c9a9d57d0ed21072abb40dd3d1d"
|
||||||
|
kubelet_checksum: "62191c66f2d670dd52ddf1d88ef81048977abf1ffaa95ee6333299447eb6a482"
|
||||||
|
|
||||||
|
calico_version: v0.13.0
|
||||||
|
calico_plugin_version: v0.7.0
|
||||||
|
|
||||||
|
etcd_download_url: "https://github.com/coreos/etcd/releases/download"
|
||||||
|
flannel_download_url: "https://github.com/coreos/flannel/releases/download"
|
||||||
|
kube_download_url: "https://storage.googleapis.com/kubernetes-release/release/{{ kube_version }}/bin/linux/amd64"
|
||||||
|
calico_download_url: "https://github.com/Metaswitch/calico-docker/releases/download"
|
||||||
|
calico_plugin_download_url: "https://github.com/projectcalico/calico-kubernetes/releases/download/{{calico_plugin_version}}/calico_kubernetes"
|
||||||
|
|
||||||
|
ansible_python_interpreter: PATH="{{ ansible_user_dir }}"/bin:$PATH python
|
||||||
|
pip_python_modules:
|
||||||
|
- httplib2
|
27
roles/common/tasks/calico.yml
Normal file
27
roles/common/tasks/calico.yml
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
---
|
||||||
|
- name: Create calico release directory
|
||||||
|
local_action: file
|
||||||
|
path={{ local_release_dir }}/calico/bin
|
||||||
|
recurse=yes
|
||||||
|
state=directory
|
||||||
|
delegate_to: "{{ groups['kube-master'][0] }}"
|
||||||
|
|
||||||
|
- name: Check if calicoctl has been downloaded
|
||||||
|
local_action: stat
|
||||||
|
path={{ local_release_dir }}/calico/bin/calicoctl
|
||||||
|
register: c_tar
|
||||||
|
delegate_to: "{{ groups['kube-master'][0] }}"
|
||||||
|
|
||||||
|
# issues with get_url module and redirects, to be tested again in the near future
|
||||||
|
- name: Download calico
|
||||||
|
local_action: shell
|
||||||
|
curl -o {{ local_release_dir }}/calico/bin/calicoctl -Ls {{ calico_download_url }}/{{ calico_version }}/calicoctl
|
||||||
|
when: not c_tar.stat.exists
|
||||||
|
register: dl_calico
|
||||||
|
delegate_to: "{{ groups['kube-master'][0] }}"
|
||||||
|
|
||||||
|
|
||||||
|
- name: Download calico-kubernetes-plugin
|
||||||
|
local_action: get_url
|
||||||
|
url="{{calico_plugin_download_url}}"
|
||||||
|
dest="{{ local_release_dir }}/calico/bin/calico"
|
39
roles/common/tasks/flannel.yml
Normal file
39
roles/common/tasks/flannel.yml
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
---
|
||||||
|
- name: Create flannel release directory
|
||||||
|
local_action: file
|
||||||
|
path={{ local_release_dir }}/flannel
|
||||||
|
recurse=yes
|
||||||
|
state=directory
|
||||||
|
delegate_to: "{{ groups['kube-master'][0] }}"
|
||||||
|
|
||||||
|
- name: Check if flannel release archive has been downloaded
|
||||||
|
local_action: stat
|
||||||
|
path={{ local_release_dir }}/flannel/flannel-{{ flannel_version }}-linux-amd64.tar.gz
|
||||||
|
register: f_tar
|
||||||
|
delegate_to: "{{ groups['kube-master'][0] }}"
|
||||||
|
|
||||||
|
# issues with get_url module and redirects, to be tested again in the near future
|
||||||
|
- name: Download flannel
|
||||||
|
local_action: shell
|
||||||
|
curl -o {{ local_release_dir }}/flannel/flannel-{{ flannel_version }}-linux-amd64.tar.gz -Ls {{ flannel_download_url }}/v{{ flannel_version }}/flannel-{{ flannel_version }}-linux-amd64.tar.gz
|
||||||
|
when: not f_tar.stat.exists
|
||||||
|
register: dl_flannel
|
||||||
|
delegate_to: "{{ groups['kube-master'][0] }}"
|
||||||
|
|
||||||
|
- name: Extract flannel archive
|
||||||
|
local_action: unarchive
|
||||||
|
src={{ local_release_dir }}/flannel/flannel-{{ flannel_version }}-linux-amd64.tar.gz
|
||||||
|
dest={{ local_release_dir }}/flannel copy=no
|
||||||
|
when: dl_flannel|changed
|
||||||
|
delegate_to: "{{ groups['kube-master'][0] }}"
|
||||||
|
|
||||||
|
- name: Pick up only flannel binaries
|
||||||
|
local_action: copy
|
||||||
|
src={{ local_release_dir }}/flannel/flannel-{{ flannel_version }}/flanneld
|
||||||
|
dest={{ local_release_dir }}/flannel/bin
|
||||||
|
when: dl_flannel|changed
|
||||||
|
|
||||||
|
- name: Delete unused flannel files
|
||||||
|
local_action: file
|
||||||
|
path={{ local_release_dir }}/flannel/flannel-{{ flannel_version }} state=absent
|
||||||
|
when: dl_flannel|changed
|
17
roles/common/tasks/kubernetes.yml
Normal file
17
roles/common/tasks/kubernetes.yml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
---
|
||||||
|
- name: Create kubernetes binary directory
|
||||||
|
local_action: file
|
||||||
|
path="{{ local_release_dir }}/kubernetes/bin"
|
||||||
|
state=directory
|
||||||
|
recurse=yes
|
||||||
|
|
||||||
|
- name: Download kubelet and kubectl
|
||||||
|
local_action: get_url
|
||||||
|
url="{{ kube_download_url }}/{{ item.name }}"
|
||||||
|
dest="{{ local_release_dir }}/kubernetes/bin"
|
||||||
|
sha256sum="{{ item.checksum }}"
|
||||||
|
with_items:
|
||||||
|
- name: kubelet
|
||||||
|
checksum: "{{ kubelet_checksum }}"
|
||||||
|
- name: kubectl
|
||||||
|
checksum: "{{ kubectl_checksum }}"
|
12
roles/common/tasks/main.yml
Normal file
12
roles/common/tasks/main.yml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
---
|
||||||
|
- include: download.yml
|
||||||
|
delegate_to: localhost
|
||||||
|
when: inventory_hostname == "{{ groups['kube-master'][0] }}"
|
||||||
|
|
||||||
|
- include: pip-bootstrap.yml
|
||||||
|
|
||||||
|
- name: Install httplib2 python module
|
||||||
|
pip:
|
||||||
|
executable: "{{ ansible_user_dir }}/bin/pip"
|
||||||
|
name: "{{ item }}"
|
||||||
|
with_items: pip_python_modules
|
2
roles/docker/.gitignore
vendored
Normal file
2
roles/docker/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
.*.swp
|
||||||
|
.vagrant
|
|
@ -1,17 +0,0 @@
|
||||||
[Unit]
|
|
||||||
Description=Docker Application Container Engine
|
|
||||||
Documentation=https://docs.docker.com
|
|
||||||
After=network.target docker.socket
|
|
||||||
Requires=docker.socket
|
|
||||||
|
|
||||||
[Service]
|
|
||||||
EnvironmentFile=-/etc/default/docker
|
|
||||||
Type=notify
|
|
||||||
ExecStart=/usr/bin/docker daemon -H fd:// $DOCKER_OPTS
|
|
||||||
MountFlags=slave
|
|
||||||
LimitNOFILE=1048576
|
|
||||||
LimitNPROC=1048576
|
|
||||||
LimitCORE=infinity
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
|
@ -1,12 +0,0 @@
|
||||||
---
|
|
||||||
- name: restart docker
|
|
||||||
command: /bin/true
|
|
||||||
notify:
|
|
||||||
- reload systemd
|
|
||||||
- restart docker service
|
|
||||||
|
|
||||||
- name: reload systemd
|
|
||||||
shell: systemctl daemon-reload
|
|
||||||
|
|
||||||
- name: restart docker service
|
|
||||||
service: name=docker state=restarted
|
|
|
@ -1,16 +0,0 @@
|
||||||
---
|
|
||||||
- name: enable docker
|
|
||||||
service:
|
|
||||||
name: docker
|
|
||||||
enabled: yes
|
|
||||||
state: started
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
#- name: login to arkena's docker registry
|
|
||||||
# shell : >
|
|
||||||
# docker login --username={{ dockerhub_user }}
|
|
||||||
# --password={{ dockerhub_pass }}
|
|
||||||
# --email={{ dockerhub_email }}
|
|
||||||
|
|
||||||
- meta: flush_handlers
|
|
|
@ -1,24 +0,0 @@
|
||||||
---
|
|
||||||
- name: Install prerequisites for https transport
|
|
||||||
apt: pkg={{ item }} state=present update_cache=yes
|
|
||||||
with_items:
|
|
||||||
- apt-transport-https
|
|
||||||
- ca-certificates
|
|
||||||
|
|
||||||
- name: Configure docker apt repository
|
|
||||||
template: src=docker.list.j2 dest=/etc/apt/sources.list.d/docker.list backup=yes
|
|
||||||
|
|
||||||
- name: Install docker-engine
|
|
||||||
apt: pkg={{ item }} state=present force=yes update_cache=yes
|
|
||||||
with_items:
|
|
||||||
- aufs-tools
|
|
||||||
- cgroupfs-mount
|
|
||||||
- docker-engine=1.9.1-0~{{ ansible_distribution_release }}
|
|
||||||
|
|
||||||
- name: Copy default docker configuration
|
|
||||||
template: src=default-docker.j2 dest=/etc/default/docker backup=yes
|
|
||||||
notify: restart docker
|
|
||||||
|
|
||||||
- name: Copy Docker systemd unit file
|
|
||||||
copy: src=systemd-docker.service dest=/lib/systemd/system/docker.service backup=yes
|
|
||||||
notify: restart docker
|
|
|
@ -1,3 +1,53 @@
|
||||||
---
|
---
|
||||||
- include: install.yml
|
- name: gather os specific variables
|
||||||
- include: configure.yml
|
include_vars: "{{ item }}"
|
||||||
|
with_first_found:
|
||||||
|
- files:
|
||||||
|
- "{{ ansible_distribution|lower }}-{{ ansible_distribution_version|lower|replace('/', '_') }}.yml"
|
||||||
|
- "{{ ansible_distribution|lower }}-{{ ansible_distribution_release }}.yml"
|
||||||
|
- "{{ ansible_distribution|lower }}-{{ ansible_distribution_major_version|lower|replace('/', '_') }}.yml"
|
||||||
|
- "{{ ansible_distribution|lower }}.yml"
|
||||||
|
- "{{ ansible_os_family|lower }}.yml"
|
||||||
|
- defaults.yml
|
||||||
|
paths:
|
||||||
|
- ../vars
|
||||||
|
|
||||||
|
- name: check for minimum kernel version
|
||||||
|
fail:
|
||||||
|
msg: >
|
||||||
|
docker requires a minimum kernel version of
|
||||||
|
{{ docker_kernel_min_version }} on
|
||||||
|
{{ ansible_distribution }}-{{ ansible_distribution_version }}
|
||||||
|
when: ansible_kernel|version_compare(docker_kernel_min_version, "<")
|
||||||
|
|
||||||
|
- name: ensure docker requirements packages are installed
|
||||||
|
action: "{{ docker_package_info.pkg_mgr }}"
|
||||||
|
args: docker_package_info.args
|
||||||
|
with_items: docker_package_info.pre_pkgs
|
||||||
|
when: docker_package_info.pre_pkgs|length > 0
|
||||||
|
|
||||||
|
- name: ensure docker repository public key is installed
|
||||||
|
action: "{{ docker_repo_key_info.pkg_key }}"
|
||||||
|
args: docker_repo_key_info.args
|
||||||
|
with_items: docker_repo_key_info.repo_keys
|
||||||
|
when: docker_repo_key_info.repo_keys|length > 0
|
||||||
|
|
||||||
|
- name: ensure docker repository is enabled
|
||||||
|
action: "{{ docker_repo_info.pkg_repo }}"
|
||||||
|
args: docker_repo_info.args
|
||||||
|
with_items: docker_repo_info.repos
|
||||||
|
when: docker_repo_info.repos|length > 0
|
||||||
|
|
||||||
|
- name: ensure docker packages are installed
|
||||||
|
action: "{{ docker_package_info.pkg_mgr }}"
|
||||||
|
args: docker_package_info.args
|
||||||
|
with_items: docker_package_info.pkgs
|
||||||
|
when: docker_package_info.pkgs|length > 0
|
||||||
|
|
||||||
|
- name: ensure docker service is started and enabled
|
||||||
|
service:
|
||||||
|
name: "{{ item }}"
|
||||||
|
enabled: yes
|
||||||
|
state: started
|
||||||
|
with_items:
|
||||||
|
- docker
|
||||||
|
|
|
@ -1,13 +0,0 @@
|
||||||
# Docker Upstart and SysVinit configuration file
|
|
||||||
|
|
||||||
# Customize location of Docker binary (especially for development testing).
|
|
||||||
#DOCKER="/usr/local/bin/docker"
|
|
||||||
|
|
||||||
# Use DOCKER_OPTS to modify the daemon startup options.
|
|
||||||
#DOCKER_OPTS=""
|
|
||||||
|
|
||||||
# If you need Docker to use an HTTP proxy, it can also be specified here.
|
|
||||||
#export http_proxy="http://127.0.0.1:3128/"
|
|
||||||
|
|
||||||
# This is also a handy place to tweak where Docker's temporary files go.
|
|
||||||
#export TMPDIR="/mnt/bigdrive/docker-tmp"
|
|
|
@ -1 +0,0 @@
|
||||||
deb https://apt.dockerproject.org/repo {{ansible_distribution|lower}}-{{ ansible_distribution_release}} main
|
|
24
roles/docker/vars/centos-6.yml
Normal file
24
roles/docker/vars/centos-6.yml
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
docker_kernel_min_version: '2.6.32-431'
|
||||||
|
|
||||||
|
docker_package_info:
|
||||||
|
pkg_mgr: yum
|
||||||
|
args:
|
||||||
|
name: "{{ item }}"
|
||||||
|
state: latest
|
||||||
|
update_cache: yes
|
||||||
|
pre_pkgs:
|
||||||
|
- epel-release
|
||||||
|
- curl
|
||||||
|
- device-mapper-libs
|
||||||
|
pkgs:
|
||||||
|
- docker-io
|
||||||
|
|
||||||
|
docker_repo_key_info:
|
||||||
|
pkg_key: ''
|
||||||
|
args: {}
|
||||||
|
repo_keys: []
|
||||||
|
|
||||||
|
docker_repo_info:
|
||||||
|
pkg_repo: ''
|
||||||
|
args: {}
|
||||||
|
repos: []
|
36
roles/docker/vars/debian.yml
Normal file
36
roles/docker/vars/debian.yml
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
docker_kernel_min_version: '3.2'
|
||||||
|
|
||||||
|
docker_package_info:
|
||||||
|
pkg_mgr: apt
|
||||||
|
args:
|
||||||
|
pkg: "{{ item }}"
|
||||||
|
update_cache: yes
|
||||||
|
cache_valid_time: 600
|
||||||
|
state: latest
|
||||||
|
pre_pkgs:
|
||||||
|
- apt-transport-https
|
||||||
|
- curl
|
||||||
|
- software-properties-common
|
||||||
|
pkgs:
|
||||||
|
- docker-engine
|
||||||
|
|
||||||
|
docker_repo_key_info:
|
||||||
|
pkg_key: apt_key
|
||||||
|
args:
|
||||||
|
id: "{{ item }}"
|
||||||
|
keyserver: hkp://p80.pool.sks-keyservers.net:80
|
||||||
|
state: present
|
||||||
|
repo_keys:
|
||||||
|
- 58118E89F3A912897C070ADBF76221572C52609D
|
||||||
|
|
||||||
|
docker_repo_info:
|
||||||
|
pkg_repo: apt_repository
|
||||||
|
args:
|
||||||
|
repo: "{{ item }}"
|
||||||
|
update_cache: yes
|
||||||
|
state: present
|
||||||
|
repos:
|
||||||
|
- >
|
||||||
|
deb https://apt.dockerproject.org/repo
|
||||||
|
{{ ansible_distribution|lower }}-{{ ansible_distribution_release|lower }}
|
||||||
|
main
|
22
roles/docker/vars/fedora-20.yml
Normal file
22
roles/docker/vars/fedora-20.yml
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
docker_kernel_min_version: '0'
|
||||||
|
|
||||||
|
docker_package_info:
|
||||||
|
pkg_mgr: yum
|
||||||
|
args:
|
||||||
|
name: "{{ item }}"
|
||||||
|
state: latest
|
||||||
|
update_cache: yes
|
||||||
|
pre_pkgs:
|
||||||
|
- curl
|
||||||
|
pkgs:
|
||||||
|
- docker-io
|
||||||
|
|
||||||
|
docker_repo_key_info:
|
||||||
|
pkg_key: ''
|
||||||
|
args: {}
|
||||||
|
repo_keys: []
|
||||||
|
|
||||||
|
docker_repo_info:
|
||||||
|
pkg_repo: ''
|
||||||
|
args: {}
|
||||||
|
repos: []
|
|
@ -1,4 +0,0 @@
|
||||||
---
|
|
||||||
#dockerhub_user:
|
|
||||||
#dockerhub_pass:
|
|
||||||
#dockerhub_email:
|
|
22
roles/docker/vars/redhat.yml
Normal file
22
roles/docker/vars/redhat.yml
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
docker_kernel_min_version: '0'
|
||||||
|
|
||||||
|
docker_package_info:
|
||||||
|
pkg_mgr: yum
|
||||||
|
args:
|
||||||
|
name: "{{ item }}"
|
||||||
|
state: latest
|
||||||
|
update_cache: yes
|
||||||
|
pre_pkgs:
|
||||||
|
- curl
|
||||||
|
pkgs:
|
||||||
|
- docker
|
||||||
|
|
||||||
|
docker_repo_key_info:
|
||||||
|
pkg_key: ''
|
||||||
|
args: {}
|
||||||
|
repo_keys: []
|
||||||
|
|
||||||
|
docker_repo_info:
|
||||||
|
pkg_repo: ''
|
||||||
|
args: {}
|
||||||
|
repos: []
|
Loading…
Reference in a new issue