Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gh142 support debian #151

Closed
wants to merge 52 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
7bd6893
w/managed_recommended_packages, bridge_utils present on osfamily: deb…
hesco Nov 17, 2014
9d7dc11
Add Debian os test case for contain_file('/etc/init.d/docker')
hesco Nov 17, 2014
04d8d60
.gitignore rake_test.* result files
hesco Nov 17, 2014
f645659
Refactor docker::repos and docker::repo::(deb|yum)_packages, no regre…
hesco Nov 17, 2014
082499c
add /etc/init.d/docker.io from upstream docker project, use bash for …
hesco Nov 17, 2014
b99e739
Handle $install_init_d_script; ubuntu, debian paths, in install.pp, n…
hesco Nov 21, 2014
d3efaa8
Begin testing debian path
hesco Nov 21, 2014
a3e5e53
Comment out beaker gems, use nokogiri w/ embedded xslt/xml libs
hesco Nov 21, 2014
53368fa
Resolve 'nokogiri pit of doom and despair' w/ build-essential, libxml…
hesco Nov 24, 2014
60b7043
Document debian testing dependencies in CONTRIBUTING.md
hesco Nov 24, 2014
a707971
restoring upstream Gemfile, changes to Gemfile.lock
hesco Nov 26, 2014
4e94b57
Test only ubuntu for the moment, .gitignore test results
hesco Nov 26, 2014
cd3b4bb
restore working tests, starting over
hesco Nov 30, 2014
36c55d2
provide test coverage for docker::repos refactor
hesco Nov 30, 2014
8e29570
Add context for Debian operating system, exercise /etc/init.d/docker …
hesco Nov 30, 2014
b3e8542
Service['docker'] uses provider => 'init', for Debian OS
hesco Nov 30, 2014
d5d2539
Sanity check: Docker requires a 64bit cpu and kernel
hesco Nov 30, 2014
91814c0
incorporate updates from package's init.d script
hesco Nov 30, 2014
8882a3f
Sanity check: system reboot is required to enable the new kernel
hesco Nov 30, 2014
af01564
Debian needs Package['lxc-docker'], init.d provider. all require amd64
hesco Nov 30, 2014
e09bdd7
Busr bug: Sanity check: system reboot is required to enable the new k…
hesco Nov 30, 2014
00ec9bf
Require 3.8.0+ kernel, test sanity check Notify['Reboot_required'] fo…
hesco Nov 30, 2014
aa01e20
Require minimum kernel for Debian, begin refactor from ::install to :…
hesco Nov 30, 2014
c598919
Refactor parameters from ::install to ::params, no regression
hesco Nov 30, 2014
c6572fc
w/managed_recommended_packages, bridge_utils present on osfamily: deb…
hesco Nov 17, 2014
02d2a83
Add Debian os test case for contain_file('/etc/init.d/docker')
hesco Nov 17, 2014
69deaf9
.gitignore rake_test.* result files
hesco Nov 17, 2014
e5b48c1
Refactor docker::repos and docker::repo::(deb|yum)_packages, no regre…
hesco Nov 17, 2014
d9c004e
add /etc/init.d/docker.io from upstream docker project, use bash for …
hesco Nov 17, 2014
2589e65
Handle $install_init_d_script; ubuntu, debian paths, in install.pp, n…
hesco Nov 21, 2014
05e6e6f
Begin testing debian path
hesco Nov 21, 2014
bc7b624
Comment out beaker gems, use nokogiri w/ embedded xslt/xml libs
hesco Nov 21, 2014
fd24be8
Resolve 'nokogiri pit of doom and despair' w/ build-essential, libxml…
hesco Nov 24, 2014
196925c
Document debian testing dependencies in CONTRIBUTING.md
hesco Nov 24, 2014
25c348e
restoring upstream Gemfile, changes to Gemfile.lock
hesco Nov 26, 2014
e2134f1
Test only ubuntu for the moment, .gitignore test results
hesco Nov 26, 2014
0850283
restore working tests, starting over
hesco Nov 30, 2014
00d58c6
provide test coverage for docker::repos refactor
hesco Nov 30, 2014
4dde3dc
Add context for Debian operating system, exercise /etc/init.d/docker …
hesco Nov 30, 2014
6f8c7e3
Service['docker'] uses provider => 'init', for Debian OS
hesco Nov 30, 2014
4c890a1
Sanity check: Docker requires a 64bit cpu and kernel
hesco Nov 30, 2014
35ce2df
incorporate updates from package's init.d script
hesco Nov 30, 2014
e1a776e
Sanity check: system reboot is required to enable the new kernel
hesco Nov 30, 2014
f387e4c
Debian needs Package['lxc-docker'], init.d provider. all require amd64
hesco Nov 30, 2014
f876179
Busr bug: Sanity check: system reboot is required to enable the new k…
hesco Nov 30, 2014
1e3006b
Require 3.8.0+ kernel, test sanity check Notify['Reboot_required'] fo…
hesco Nov 30, 2014
0ca3e8d
Require minimum kernel for Debian, begin refactor from ::install to :…
hesco Nov 30, 2014
d5cedea
Refactor parameters from ::install to ::params, no regression
hesco Nov 30, 2014
960fafa
Merge branch 'gh142_support_debian' of https://github.com/hesco/garet…
hesco Nov 30, 2014
3c0d350
Resolve merge conflicts in Gemfile
hesco Nov 30, 2014
2b5c235
fix linting errors failing the travis CI build
hesco Nov 30, 2014
1620ac1
document Debian support, amd64, kernel v3.8+ requirements, manage opt…
hesco Nov 30, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ spec/fixtures
.vagrant
.yardoc
doc
rake_test/
vendor/

5 changes: 5 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ Install the dependencies like so...

bundle install --path=~/.bundle

If you are testing in a Debian environment, avoid the 'nokogiri pit of doom and despair'
by installing these debian packages:

apt-get install build-essential libxml2-dev libxslt1-dev

## Syntax and style

The test suite will run [Puppet Lint](http://puppet-lint.com/) and
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Status](http://img.shields.io/badge/docs-puppet--strings-lightgrey.svg)](https:/

This module is currently tested on:

* Debian Wheezy
* Debian Jessie
* Ubuntu 12.04
* Ubuntu 14.04
* Centos 7.0
Expand All @@ -32,6 +34,10 @@ include 'docker'

By default this sets up the docker hosted repository if necessary for your OS
and installs the docker package and on Ubuntu, any required Kernel extensions.
If your kernel <3.8.0, it will install a later version of the kernel and notify
you of the need to reboot on the new kernel to support docker. If you lack the
64bit architecture required by docker, this class will simply abort with an
error message.

If you don't want this module to mess about with your Kernel then you can disable
this feature like so. It is only enabled (and supported) by default on Ubuntu:
Expand All @@ -52,6 +58,9 @@ class { 'docker':
}
```

There are also manage_recommended_packages and manage_package options
also available.

By default the docker daemon will bind to a unix socket at
/var/run/docker.sock. This can be changed, as well as binding to a tcp
socket if required.
Expand Down
146 changes: 146 additions & 0 deletions files/etc/init.d/docker.io
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
#!/bin/sh

###!/bin/bash
# https://github.com/dotcloud/docker/raw/master/contrib/init/sysvinit-debian/docker
# 2014-07-14

### BEGIN INIT INFO
# Provides: docker
# Required-Start: $syslog $remote_fs
# Required-Stop: $syslog $remote_fs
# Should-Start: cgroupfs-mount cgroup-lite
# Should-Stop: cgroupfs-mount cgroup-lite
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Create lightweight, portable, self-sufficient containers.
# Description:
# Docker is an open-source project to easily create lightweight, portable,
# self-sufficient containers from any application. The same container that a
# developer builds and tests on a laptop can run at scale, in production, on
# VMs, bare metal, OpenStack clusters, public clouds and more.
### END INIT INFO

export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin

BASE=$(basename $0)

# modify these in /etc/default/$BASE (/etc/default/docker)
DOCKER=/usr/bin/$BASE
# This is the pid file managed by docker itself
DOCKER_PIDFILE=/var/run/$BASE.pid
# This is the pid file created/managed by start-stop-daemon
DOCKER_SSD_PIDFILE=/var/run/$BASE-ssd.pid
DOCKER_LOGFILE=/var/log/$BASE.log
DOCKER_OPTS=
DOCKER_DESC="Docker"

# Get lsb functions
. /lib/lsb/init-functions

if [ -f /etc/default/$BASE ]; then
. /etc/default/$BASE
fi

# see also init_is_upstart in /lib/lsb/init-functions (which isn't available in Ubuntu 12.04, or we'd use it)
if [ -x /sbin/initctl ] && /sbin/initctl version 2>/dev/null | grep -q upstart; then
log_failure_msg "$DOCKER_DESC is managed via upstart, try using service $BASE $1"
exit 1
fi

# Check docker is present
if [ ! -x $DOCKER ]; then
log_failure_msg "$DOCKER not present or not executable"
exit 1
fi

fail_unless_root() {
if [ "$(id -u)" != '0' ]; then
log_failure_msg "$DOCKER_DESC must be run as root"
exit 1
fi
}

cgroupfs_mount() {
# see also https://github.com/tianon/cgroupfs-mount/blob/master/cgroupfs-mount
if grep -v '^#' /etc/fstab | grep -q cgroup \
|| [ ! -e /proc/cgroups ] \
|| [ ! -d /sys/fs/cgroup ]; then
return
fi
if ! mountpoint -q /sys/fs/cgroup; then
mount -t tmpfs -o uid=0,gid=0,mode=0755 cgroup /sys/fs/cgroup
fi
(
cd /sys/fs/cgroup
for sys in $(awk '!/^#/ { if ($4 == 1) print $1 }' /proc/cgroups); do
mkdir -p $sys
if ! mountpoint -q $sys; then
if ! mount -n -t cgroup -o $sys cgroup $sys; then
rmdir $sys || true
fi
fi
done
)
}

case "$1" in
start)
fail_unless_root

cgroupfs_mount

touch "$DOCKER_LOGFILE"
chgrp docker "$DOCKER_LOGFILE"

ulimit -n 1048576
if [ "$BASH" ]; then
ulimit -u 1048576
else
ulimit -p 1048576
fi

log_begin_msg "Starting $DOCKER_DESC: $BASE"
start-stop-daemon --start --background \
--no-close \
--exec "$DOCKER" \
--pidfile "$DOCKER_SSD_PIDFILE" \
--make-pidfile \
-- \
-d -p "$DOCKER_PIDFILE" \
$DOCKER_OPTS \
>> "$DOCKER_LOGFILE" 2>&1
log_end_msg $?
;;

stop)
fail_unless_root
log_begin_msg "Stopping $DOCKER_DESC: $BASE"
start-stop-daemon --stop --pidfile "$DOCKER_SSD_PIDFILE"
log_end_msg $?
;;

restart)
fail_unless_root
docker_pid=`cat "$DOCKER_SSD_PIDFILE" 2>/dev/null`
[ -n "$docker_pid" ] \
&& ps -p $docker_pid > /dev/null 2>&1 \
&& $0 stop
$0 start
;;

force-reload)
fail_unless_root
$0 restart
;;

status)
status_of_proc -p "$DOCKER_SSD_PIDFILE" "$DOCKER" "$DOCKER_DESC"
;;

*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
;;
esac

exit 0
14 changes: 12 additions & 2 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@
# [*docker_command*]
# Specify a custom docker command name
# Default is set on a per system basis in docker::params
#

class docker(

$version = $docker::params::version,
$ensure = $docker::params::ensure,
$prerequired_packages = $docker::params::prerequired_packages,
Expand All @@ -113,15 +114,24 @@
$package_name = $docker::params::package_name,
$service_name = $docker::params::service_name,
$docker_command = $docker::params::docker_command,
$ensure_recommended = $docker::params::ensure_recommended,
$recommended_packages = $docker::params::recommended_packages,
$manage_recommended_packages = $docker::params::manage_recommended_packages,

) inherits docker::params {

validate_string($version)
validate_re($::osfamily, '^(Debian|RedHat|Archlinux)$', 'This module only works on Debian and Red Hat based systems.')
validate_re($::architecture, '^amd64$', 'Docker requires a 64bit cpu and kernel')
validate_bool($manage_kernel)
validate_bool($manage_package)

anchor { 'docker::begin': } ->
class { 'docker::repos': } ->
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change will generate the following error message because the mirror is defined before the package apt-transport-https is installed.

==> default: Notice: /Stage[main]/Apt::Update/Exec[apt_update]/returns: E: The method driver /usr/lib/apt/methods/https could not be found.

class { 'docker::install': } ->
class { 'docker::config': } ~>
class { 'docker::service': } ->
Class['docker']
anchor { 'docker::end': }

}

80 changes: 34 additions & 46 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,21 @@
# Module to install an up-to-date version of Docker from a package repository.
# This module currently works only on Debian, Red Hat
# and Archlinux based distributions.
#
class docker::install {
validate_string($docker::version)
validate_re($::osfamily, '^(Debian|RedHat|Archlinux)$', 'This module only works on Debian, Red Hat and Archlinux based systems.')
$compatibility_error_message = 'This module only works on Debian, Red Hat and Archlinux based systems.'
validate_re($::osfamily, '^(Debian|RedHat|Archlinux)$', $compatibility_error_message)
validate_string($::kernelrelease)
validate_bool($docker::use_upstream_package_source)

$kernelpackage = getvar('docker::params::kernelpackage')
$manage_kernel = getvar('docker::manage_kernel')
$install_init_d_script = getvar('docker::params::install_init_d_script')

case $::osfamily {
'Debian': {
ensure_packages($docker::prerequired_packages)

if $docker::manage_package {
Package['apt-transport-https'] -> Package['docker']
}
Expand All @@ -23,46 +28,14 @@
$dockerpackage = $docker::package_name
}

if ($docker::use_upstream_package_source) {
include apt
apt::source { 'docker':
location => $docker::package_source_location,
release => 'docker',
repos => 'main',
required_packages => 'debian-keyring debian-archive-keyring',
key => 'A88D21E9',
key_source => 'https://get.docker.io/gpg',
pin => '10',
include_src => false,
}
if $docker::manage_package {
Apt::Source['docker'] -> Package['docker']
}
} else {
if (! $docker::use_upstream_package_source) {
if $docker::version and $docker::ensure != 'absent' {
$ensure = $docker::version
} else {
$ensure = $docker::ensure
}
}

if $::operatingsystem == 'Ubuntu' {
case $::operatingsystemrelease {
# On Ubuntu 12.04 (precise) install the backported 13.10 (saucy) kernel
'12.04': { $kernelpackage = [
'linux-image-generic-lts-trusty',
'linux-headers-generic-lts-trusty'
]
}
# determine the package name for 'linux-image-extra-$(uname -r)' based
# on the $::kernelrelease fact
default: { $kernelpackage = "linux-image-extra-${::kernelrelease}" }
}
$manage_kernel = $docker::manage_kernel
} else {
# Debian does not need extra kernel packages
$manage_kernel = false
}
}
'RedHat': {
if $::operatingsystem == 'Amazon' {
Expand All @@ -74,31 +47,39 @@
fail('Docker needs RedHat/CentOS version to be at least 6.5.')
}

$manage_kernel = false

if $docker::version {
$dockerpackage = "${docker::package_name}-${docker::version}"
} else {
$dockerpackage = $docker::package_name
}
if $::operatingsystem != 'Amazon' {
if ($docker::use_upstream_package_source) {
include 'epel'
if $docker::manage_package {
Class['epel'] -> Package['docker']
}
}
}
}
'Archlinux': {
$manage_kernel = false

if $docker::version {
notify { 'docker::version unsupported on Archlinux':
message => 'Versions other than latest are not supported on Arch Linux. This setting will be ignored.'
}
}
}
default: {}
}

if $install_init_d_script {
if $::operatingsystem == 'Ubuntu' {
file { '/etc/init.d/docker':
ensure => 'link',
target => '/lib/init/upstart-job',
force => true,
notify => Service['docker'],
}
} elsif $::operatingsystem == 'Debian' {
file { '/etc/init.d/docker':
source => 'puppet:///modules/docker/etc/init.d/docker.io',
owner => root,
group => root,
mode => '0754',
}
}
}

if $manage_kernel {
Expand All @@ -116,4 +97,11 @@
name => $dockerpackage,
}
}

$recommended_packages = $docker::recommended_packages
if $docker::manage_recommended_packages {
ensure_resource('package',$recommended_packages,{ ensure => $docker::ensure_recommended })
}

}

Loading