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

Support for docker-ce and docker-ee #740

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
53 changes: 23 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Puppet module for installing, configuring and managing
[Docker](https://github.com/docker/docker) from the [official repository](https://docs.docker.com/installation/) or alternatively from [EPEL on RedHat](https://docs.docker.io/en/latest/installation/rhel/) based distributions.
[Docker](https://github.com/docker/docker) from the [official repository](https://docs.docker.com/engine/installation/)

[![Puppet
Forge](https://img.shields.io/puppetforge/v/garethr/docker.svg)](https://forge.puppetlabs.com/garethr/docker) [![Build
Expand All @@ -20,6 +20,7 @@ This module is currently tested on:
* Centos 7.0
* Centos 6.6


It may work on other distros and additional operating systems will be
supported in the future. It's definitely been used with the following
too:
Expand Down Expand Up @@ -53,7 +54,7 @@ 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.
and installs the docker-ce package and on Ubuntu, any required Kernel extensions.

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 @@ -74,29 +75,21 @@ class { 'docker':
}
```

Docker recently [launched new official
repositories](https://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 repositories 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',
}
```

Docker also provide a [commercially
supported](https://docs.docker.com/docker-trusted-registry/install/install-csengine/)
version of the Docker Engine, called Docker CS, available from a separate repository.
This can be installed with the module using the following:
Docker recently split docker into a Community Edition (docker-ce) and
a commercially supported Enterprise Edition (docker-ee). This module
supports installing the CE version out of the box. You can also use
the commercial version by setting the docker_cs flag to true. However
you also need to set package_source_location, package_release,
package_repos, package_key and package_key_source must be set
accordingly to the OS requirements.

```puppet
class { 'docker':
docker_cs => true,
package_source_location => '<DOCKER-EE-URL>',
package_key_source => '<DOCKER-EE-URL>/gpg',
package_key => '<DOCKER-EE-GPG-KEY-FINGERPRINT-FOR-THE-OS>
package_release => 'stable-<YY.MM>
}
```

Expand Down Expand Up @@ -420,7 +413,7 @@ file.
Before using the docker_compose type make sure the docker-compose utility is installed:

```puppet
class {'docker::compose':
class {'docker::compose':
ensure => present,
}
```
Expand Down Expand Up @@ -475,10 +468,10 @@ For a swarm manager:
docker::swarm {'cluster_manager':
init => true,
advertise_addr => '192.168.1.1',
listen_addr => '192.168.1.1',
}
listen_addr => '192.168.1.1',
}
```
In the above example we have configured a swarm manager with ```init => true``` then set the ```advertise_addr``` and ```listen_addr```. Both the ```advertise_addr``` and ```listen_addr``` are set for the cluster communications between nodes. Please note the ```advertise_addr``` and ```listen_addr``` must be set for a multihomed server. For more advance flags to configure raft snapshots etc please read the readme at the top of the ```docker::swarm``` class.
In the above example we have configured a swarm manager with ```init => true``` then set the ```advertise_addr``` and ```listen_addr```. Both the ```advertise_addr``` and ```listen_addr``` are set for the cluster communications between nodes. Please note the ```advertise_addr``` and ```listen_addr``` must be set for a multihomed server. For more advance flags to configure raft snapshots etc please read the readme at the top of the ```docker::swarm``` class.

For a swarm worker:
```puppet
Expand All @@ -488,7 +481,7 @@ advertise_addr => '192.168.1.2',
listen_addr => '192.168.1.2,
manager_ip => '192.168.1.1',
token => 'SWMTKN-1-2lw8bnr57qsu74d6iq2q1wr2wq2i334g7425dfr3zucimvh4bl-2vwn6gysbdj605l37c61iixie'
}
}
```

In this example we have joined a node to the cluster using ```join => true```. For a worker node or second manager you need to pass a current managers ip address ```manager_ip => '192.168.1.1'```
Expand All @@ -507,18 +500,18 @@ To configure a service with Puppet code please see the following examples
To create a service
```puppet
docker::services {'redis':
create => true,
create => true,
service_name => 'redis',
image => 'redis:latest',
publish => '6379:639',
replicas => '5',
replicas => '5',
extra_params => ['--update-delay 1m', '--restart-window 30s']
}
```
In this example we are creating a service called `redis`, as it is a new service we have set `create => true`. The `service_name` resource is the name which Docker knows the service as. The `image` resource is the image you want to base the service off, `publish` is the ports that want exposed to the outside world for the service to be consumed, `replicas` sets the amount of tasks (containers) that you want running in the service, `extra_params` allows you to configure any of the other flags that Docker gives you when you create a service for more info see `docker service create --help`

To update the service
```puppet
```puppet
docker::services {'redis_update':
create => false,
update => true,
Expand All @@ -534,7 +527,7 @@ docker::services {'redis_scale':
create => false,
scale => true,
service_name => 'redis',
replicas => '10',
replicas => '10',
}
```
In this example we have used the command `docker service scale` with Puppet code. We have taken our service `redis` set the `create => false` and `scale => true` When using scale you have to declare your `service_name` then the number of replicas that you want. In this example we are going to scale to `10`
Expand Down
34 changes: 28 additions & 6 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,16 @@
# An array of additional packages that need to be installed to support
# docker. Defaults change depending on the operating system.
#
# [*purge_packages*]
# An array of packages that need to be removed not to conflict with
# docker. Set to undef to avoud purging packages.
# Defaults to old docker packages, fx. docker.io and docker-engine
#
# [*docker_cs*]
# Whether or not to use the CS (Commercial Support) Docker packages.
# If commercial support packages are used the parameters
# package_source_location, package_release, package_repos, package_key
# and package_key_source must be set accordingly to the OS requirements.
# Defaults to false.
#
# [*tcp_bind*]
Expand Down Expand Up @@ -174,6 +182,14 @@
# If you're using an upstream package source, what is it's
# location. Defaults to http://get.docker.com/ubuntu on Debian
#
# [*package_repos*]
# Which package repository to use.
# For CE: edge, stable, test
# Defaults to stable
# For EE: fx. stable-17.09
# Defaults to undefined. This parameter must be set explictly if
# using commercially suported Docker (ie docker_cs flag is true)
#
# [*service_state*]
# Whether you want to docker daemon to start up
# Defaults to running
Expand Down Expand Up @@ -295,8 +311,8 @@
# Specify a custom docker command name
# Default is set on a per system basis in docker::params
#
# [*daemon_subcommand*]
# Specify a subcommand/flag for running docker as daemon
# [*docker_daemon_command*]
# Specify a command for running docker as daemon
# Default is set on a per system basis in docker::params
#
# [*docker_users*]
Expand Down Expand Up @@ -348,9 +364,8 @@
$version = $docker::params::version,
$ensure = $docker::params::ensure,
$prerequired_packages = $docker::params::prerequired_packages,
$purge_packages = $docker::params::purge_packages,
$docker_cs = $docker::params::docker_cs,
$package_cs_source_location = $docker::params::package_cs_source_location,
$package_cs_key_source = $docker::params::package_cs_key_source,
$tcp_bind = $docker::params::tcp_bind,
$tls_enable = $docker::params::tls_enable,
$tls_verify = $docker::params::tls_verify,
Expand Down Expand Up @@ -379,6 +394,7 @@
$package_repos = $docker::params::package_repos,
$package_key = $docker::params::package_key,
$package_key_source = $docker::params::package_key_source,
$package_name = $docker::params::package_name,
$service_state = $docker::params::service_state,
$service_enable = $docker::params::service_enable,
$manage_service = $docker::params::manage_service,
Expand Down Expand Up @@ -412,10 +428,9 @@
$manage_package = $docker::params::manage_package,
$package_source = $docker::params::package_source,
$manage_epel = $docker::params::manage_epel,
$package_name = $docker::params::package_name,
$service_name = $docker::params::service_name,
$docker_command = $docker::params::docker_command,
$daemon_subcommand = $docker::params::daemon_subcommand,
$docker_daemon_command = $docker::params::docker_daemon_command,
$docker_users = [],
$docker_group = $docker::params::docker_group,
$daemon_environment_files = [],
Expand Down Expand Up @@ -448,6 +463,13 @@
validate_bool($manage_kernel)
validate_bool($manage_package)
validate_bool($docker_cs)
if ($package_repos and $use_upstream_package_source) {
if ($docker_cs) {
validate_re($package_repos, '^stable-\d{2}\.\d{2}$')
} else {
validate_re($package_repos, '^(stable|edge|test)$')
}
}
validate_bool($manage_service)
validate_array($docker_users)
validate_array($daemon_environment_files)
Expand Down
6 changes: 6 additions & 0 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
$ensure = $docker::ensure
}

if ($docker::purge_packages) {
ensure_resource('package', $docker::purge_packages, {
ensure => absent,
before => Package['docker'],
})
}
case $::osfamily {
'Debian': {
if $::operatingsystem == 'Ubuntu' {
Expand Down
Loading