Skip to content

Commit

Permalink
Support new Docker repos
Browse files Browse the repository at this point in the history
Docker have created a new set of official repositories, including adding
Yum and Debian based packages.
  • Loading branch information
garethr committed Sep 22, 2015
1 parent 7ba078b commit b546cfb
Show file tree
Hide file tree
Showing 27 changed files with 405 additions and 244 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,5 @@ run the integration tests against Centos 6.5 with:

Or with Ubuntu 14.04 with:

BEAKER_set=ubuntu-server-1404-x64 bundle exec rake beaker
BEAKER_set=ubuntu-1404-x64 bundle exec rake beaker

45 changes: 36 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Puppet module for installing, configuring and managing
[Docker](https://github.com/dotcloud/docker) from the [official repository](http://docs.docker.io/en/latest/installation/ubuntulinux/) on Ubuntu, from [EPEL on RedHat](http://docs.docker.io/en/latest/installation/rhel/) based distributions or the [standard repositories](http://docs.docker.com/installation/archlinux/) for Archlinux and Fedora.

[Docker](https://github.com/docker/docker) from the [official repository](http://docs.docker.com/installation/) or alternatively from [EPEL on RedHat](http://docs.docker.io/en/latest/installation/rhel/) based distributions.
[![Puppet
Forge](http://img.shields.io/puppetforge/v/garethr/docker.svg)](https://forge.puppetlabs.com/garethr/docker) [![Build
Status](https://secure.travis-ci.org/garethr/garethr-docker.png)](http://travis-ci.org/garethr/garethr-docker) [![Documentation
Expand All @@ -13,6 +13,8 @@ Endorsement](https://img.shields.io/puppetforge/e/garethr/docker.svg)](https://f

This module is currently tested on:

* Debian 8.0
* Debian 7.8
* Ubuntu 12.04
* Ubuntu 14.04
* Centos 7.0
Expand All @@ -25,7 +27,6 @@ too:
* Archlinux
* Amazon Linux
* Fedora
* Debian

## Examples

Expand Down Expand Up @@ -72,6 +73,32 @@ class { 'docker':
}
```

Docker recently [launched new official
repositories](http://blog.docker.com/2015/07/new-apt-and-yum-repos/#comment-247448)
which are now the default for the module from version 5. If you want to
stick with the old respoitories you can do so with the following:

```puppet
class { 'docker':
package_name => 'lxc-docker',
package_source_location => 'https://get.docker.com/ubuntu',
package_key_source => 'https://get.docker.com/gpg',
package_key => '36A1D7869245C8950F966E92D8576A8BA88D21E',
package_release => 'docker',
}
```

The module also now uses the upstream repositories by default for RHEL
based distros, including Fedora. If you want to stick with the distro packages
you should use the following:

```puppet
class { 'docker':
use_upstream_package_source => false,
package_name => 'docker',
}
```

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 All @@ -83,9 +110,10 @@ class { 'docker':
}
```

Unless specified this installs the latest version of docker from the docker inc
Unless specified this installs the latest version of docker from the docker
repository on first run. However if you want to specify a specific version you
can do so, unless you are using Archlinux which only supports the latest release:
can do so, unless you are using Archlinux which only supports the latest release.
Note that this relies on a package with that version existing in the reposiroty.

```puppet
class { 'docker':
Expand All @@ -101,7 +129,6 @@ class { 'docker':
}
```


In some cases dns resolution won't work well in the container unless you give a dns server to the docker daemon like this:

```puppet
Expand All @@ -114,7 +141,7 @@ To add users to the Docker group you can pass an array like this:

```puppet
class { 'docker':
docker_users => [ 'user1', 'user2' ],
docker_users => ['user1', 'user2'],
}
```

Expand Down Expand Up @@ -239,13 +266,13 @@ docker::run { 'helloworld':
}
```

If using hiera, there's a docker::run_instance class you can configure, for example:
If using hiera, there's a `docker::run_instance` class you can configure, for example:

```yaml
---
classes:
- docker::run_instance

docker::run_instance::instance:
helloworld:
image: 'ubuntu:precise'
Expand Down
1 change: 1 addition & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ end
PuppetLint.configuration.relative = true
PuppetLint.configuration.send("disable_80chars")
PuppetLint.configuration.log_format = "%{path}:%{linenumber}:%{check}:%{KIND}:%{message}"
PuppetLint.configuration.send('disable_case_without_default')
PuppetLint.configuration.fail_on_warnings = true

# Forsake support for Puppet 2.6.2 for the benefit of cleaner code.
Expand Down
6 changes: 6 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,10 @@
$selinux_enabled = $docker::params::selinux_enabled,
$use_upstream_package_source = $docker::params::use_upstream_package_source,
$package_source_location = $docker::params::package_source_location,
$package_release = $docker::params::package_release,
$package_repos = $docker::params::package_repos,
$package_key = $docker::params::package_key,
$package_key_source = $docker::params::package_key_source,
$service_state = $docker::params::service_state,
$service_enable = $docker::params::service_enable,
$root_dir = $docker::params::root_dir,
Expand Down Expand Up @@ -219,9 +223,11 @@
fail('You need to provide both $dm_datadev and $dm_metadatadev parameters for direct lvm.')
}

class { 'docker::repos': } ->
class { 'docker::install': } ->
class { 'docker::config': } ~>
class { 'docker::service': }
contain 'docker::repos'
contain 'docker::install'
contain 'docker::config'
contain 'docker::service'
Expand Down
60 changes: 9 additions & 51 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,14 @@
validate_string($::kernelrelease)
validate_bool($docker::use_upstream_package_source)

ensure_packages($docker::prerequired_packages)
if $docker::version and $docker::ensure != 'absent' {
$ensure = $docker::version
} else {
$ensure = $docker::ensure
}

case $::osfamily {
'Debian': {
if $docker::manage_package {
Package['apt-transport-https'] -> Package['docker']
}

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 => '36A1D7869245C8950F966E92D8576A8BA88D21E9',
key_source => 'https://get.docker.com/gpg',
pin => '10',
include_src => false,
}
if $docker::manage_package {
Apt::Source['docker'] -> Package['docker']
}
} else {
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
Expand Down Expand Up @@ -68,23 +45,10 @@
elsif versioncmp($::operatingsystemrelease, '6.5') < 0 {
fail('Docker needs RedHat/CentOS version to be at least 6.5.')
}

$manage_kernel = false

if ($::operatingsystem != 'Amazon') and ($::operatingsystem != 'Fedora') {
if ($docker::use_upstream_package_source) {
if ($docker::manage_epel == true){
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.'
Expand All @@ -102,23 +66,17 @@
}
}

if $docker::version {
$dockerpackage = "${docker::package_name}-${docker::version}"
} else {
$dockerpackage = $docker::package_name
}

if $docker::manage_package {
if $docker::repo_opt {
package { 'docker':
ensure => $docker::ensure,
name => $dockerpackage,
ensure => $ensure,
name => $docker::package_name,
install_options => $docker::repo_opt,
}
} else {
package { 'docker':
ensure => $docker::ensure,
name => $dockerpackage,
ensure => $ensure,
name => $docker::package_name,
}
}
}
Expand Down
Loading

0 comments on commit b546cfb

Please sign in to comment.