Skip to content

Commit

Permalink
Merge pull request #6 from hellofresh/patch/upgrade
Browse files Browse the repository at this point in the history
Support newer versions of Ubuntu
  • Loading branch information
startnow65 authored Feb 3, 2020
2 parents c9df8d0 + f4a1eb9 commit 5d12007
Show file tree
Hide file tree
Showing 15 changed files with 89 additions and 37 deletions.
4 changes: 2 additions & 2 deletions .kitchen.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
driver :
name : <%= if ENV['TRAVIS'] then 'localhost' else 'vagrant' end %>
box : "ubuntu/trusty64"
box : "ubuntu/bionic64"
customize :
cpus : 2
memory : 2048
Expand All @@ -28,4 +28,4 @@ platforms:
suites:
- name : default
provisioner :
playbook : "test/integration/defaults/defaults.yml"
playbook : "test/integration/defaults/defaults.yml"
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ group :development do
gem 'kitchen-vagrant'
gem 'kitchen-ansiblepush'
gem 'kitchen-localhost'
gem 'net-ssh', '~> 2.0'
end
gem 'net-ssh', '~> 4.0'
end
4 changes: 2 additions & 2 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ An ansible role that installs docker host on ubuntu
### Role Variables
```yaml
dockerhost_group : "docker"
docker_compose_version : "1.6.2"
docker_compose_version : "1.25.3"
docker_compose_dir : "/opt/docker_compose"
docker_compose_install : True
```
Expand All @@ -15,4 +15,4 @@ docker_compose_install : True
MIT
### Contributors
* [Adham Helal](https://github.com/ahelal)
* [Adham Helal](https://github.com/ahelal)
6 changes: 4 additions & 2 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
---

dockerhost_group : "docker"
docker_compose_version : "1.6.2"
docker_compose_version : "1.25.3"
docker_compose_dir : "/opt/docker_compose"
docker_compose_install : True
docker_install_py_module : False
docker_install_py_module : False

docker_gpg_url : https://download.docker.com/linux/ubuntu/gpg
9 changes: 7 additions & 2 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
---
- name: restart docker
service:
name="docker"
state="restarted"
name: docker
state: restarted

- name: restart docker systemd
systemd:
name: docker
state: restarted
daemon_reload: True
8 changes: 3 additions & 5 deletions meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@
# meta file for ansible
galaxy_info:
author: Adham Helal
description: Install manage firefox
description: Install manage docker daemon
license: MIT
min_ansible_version: 1.9
platforms:
- name: Ubuntu
versions:
- all
- name: Debian
versions:
- all
- 18.04
- 16.04
categories:
- web
dependencies: []
7 changes: 3 additions & 4 deletions tasks/apt.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,19 @@
with_items:
- apt-transport-https
- ca-certificates
- "linux-image-extra-{{ ansible_kernel }}"

- name: Add apt repo GPG
apt_key:
keyserver="{{ dockerhost_keyserver }}"
id="{{ dockerhost_id }}"
url="{{ docker_gpg_url }}"

- name: Add docker apt repo
apt_repository:
repo="deb https://apt.dockerproject.org/repo ubuntu-{{ ansible_lsb.codename }} main"
repo="deb https://download.docker.com/linux/ubuntu {{ ansible_lsb.codename }} stable"
update_cache="yes"

- name: Purge the old repo (lxc-docker)
apt:
pkg="lxc-docker"
state="absent"
purge="true"
purge="true"
35 changes: 23 additions & 12 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

- name: Add docker group
group:
name="{{ dockerhost_group }}"
system="True"
state="present"
name: "{{ dockerhost_group }}"
system: True
state: present

- name: Include apt tasks
- name: Apt tasks
include: apt.yml

- name: Include docker-py
Expand All @@ -17,21 +17,32 @@

- name: Install docker engine
apt:
pkg="docker-engine"
pkg: "docker-ce"

- name: Include docker-compose.yml
include: docker-compose.yml
when: docker_compose_install

- name: Include docker conf
- name: Create docker conf
template:
src=docker_conf_ubuntu_14.04.j2
dest=/etc/default/docker
src: docker_conf.j2
dest: /etc/default/docker
when: ansible_service_mgr != 'systemd'
notify:
- restart docker
- restart docker

- name: Create docker systemd unit file
template:
src: docker_systemd_service.j2
dest: /etc/systemd/system/docker.service
when: ansible_service_mgr == 'systemd'
notify:
- restart docker systemd

- meta: flush_handlers

- name: Ensure docker is running and starts by default
service:
name="docker"
state="started"
enabled=True
name: docker
state: started
enabled: True
1 change: 0 additions & 1 deletion tasks/users.yml

This file was deleted.

File renamed without changes.
38 changes: 38 additions & 0 deletions templates/docker_systemd_service.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target docker.socket firewalld.service
Wants=network-online.target
Requires=docker.socket

[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
{% if dockerhost_docker_opts is defined %}
ExecStart=/usr/bin/dockerd -H fd:// {{dockerhost_docker_opts}}
{% else %}
ExecStart=/usr/bin/dockerd -H fd://
{% endif %}
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=1048576
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNPROC=infinity
LimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
#TasksMax=infinity
TimeoutStartSec=0
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process
# restart the docker process if it exits prematurely
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s

[Install]
WantedBy=multi-user.target
2 changes: 1 addition & 1 deletion test/integration/defaults/serverspec/default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@

# Default version
describe command('docker --version') do
its(:stdout) { should contain('1.10') }
its(:stdout) { should contain('19.03.5') }
end
2 changes: 1 addition & 1 deletion test/integration/defaults/serverspec/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ set :backend, :exec

# Default version
describe command('docker --version') do
its(:stdout) { should contain('1.9') }
its(:stdout) { should contain('19.03.5') }
end
2 changes: 1 addition & 1 deletion test/integration/docker-py/serverspec/default_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@

# Default version
describe command('docker --version') do
its(:stdout) { should contain('1.10') }
its(:stdout) { should contain('19.03.5') }
end
4 changes: 2 additions & 2 deletions vars/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---

dockerhost_keyserver : "hkps://keys.openpgp.org"
dockerhost_id : "58118E89F3A912897C070ADBF76221572C52609D"
dockerhost_keyserver : "https://download.docker.com/linux/ubuntu/gpg"
dockerhost_id : "7EA0A9C3F273FCD8"

docker_compose_file : "docker-compose-Linux-{{ ansible_userspace_architecture }}-{{ docker_compose_version }}"
docker_compose_url : "https://github.com/docker/compose/releases/download/{{ docker_compose_version }}/docker-compose-Linux-{{ ansible_userspace_architecture }}"

0 comments on commit 5d12007

Please sign in to comment.