2015-06-07 23:07:20 -04:00
|
|
|
<!--[metadata]>
|
|
|
|
+++
|
2016-01-23 23:36:40 -05:00
|
|
|
aliases = ["/engine/articles/puppet/"]
|
2015-06-07 23:07:20 -04:00
|
|
|
title = "Using Puppet"
|
|
|
|
description = "Installing and using Puppet"
|
|
|
|
keywords = ["puppet, installation, usage, docker, documentation"]
|
|
|
|
[menu.main]
|
2016-01-23 23:36:40 -05:00
|
|
|
parent = "engine_admin"
|
2016-07-19 00:40:07 -04:00
|
|
|
weight="12"
|
2015-06-07 23:07:20 -04:00
|
|
|
+++
|
|
|
|
<![end-metadata]-->
|
2014-04-15 20:53:12 -04:00
|
|
|
|
|
|
|
# Using Puppet
|
|
|
|
|
2014-04-23 16:48:28 -04:00
|
|
|
> *Note:* Please note this is a community contributed installation path. The
|
|
|
|
> only `official` installation is using the
|
2016-01-23 23:36:40 -05:00
|
|
|
> [*Ubuntu*](../installation/linux/ubuntulinux.md) installation
|
2014-04-15 20:53:12 -04:00
|
|
|
> path. This version may sometimes be out of date.
|
|
|
|
|
|
|
|
## Requirements
|
|
|
|
|
2014-04-23 16:48:28 -04:00
|
|
|
To use this guide you'll need a working installation of Puppet from
|
2014-05-14 13:22:49 -04:00
|
|
|
[Puppet Labs](https://puppetlabs.com) .
|
2014-04-15 20:53:12 -04:00
|
|
|
|
|
|
|
The module also currently uses the official PPA so only works with
|
|
|
|
Ubuntu.
|
|
|
|
|
|
|
|
## Installation
|
|
|
|
|
|
|
|
The module is available on the [Puppet
|
|
|
|
Forge](https://forge.puppetlabs.com/garethr/docker/) and can be
|
|
|
|
installed using the built-in module tool.
|
|
|
|
|
2014-05-01 10:13:34 -04:00
|
|
|
$ puppet module install garethr/docker
|
2014-04-15 20:53:12 -04:00
|
|
|
|
|
|
|
It can also be found on
|
2014-05-14 13:22:49 -04:00
|
|
|
[GitHub](https://github.com/garethr/garethr-docker) if you would rather
|
|
|
|
download the source.
|
2014-04-15 20:53:12 -04:00
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
The module provides a puppet class for installing Docker and two defined
|
|
|
|
types for managing images and containers.
|
|
|
|
|
|
|
|
### Installation
|
|
|
|
|
|
|
|
include 'docker'
|
|
|
|
|
|
|
|
### Images
|
|
|
|
|
|
|
|
The next step is probably to install a Docker image. For this, we have a
|
|
|
|
defined type which can be used like so:
|
|
|
|
|
|
|
|
docker::image { 'ubuntu': }
|
|
|
|
|
|
|
|
This is equivalent to running:
|
|
|
|
|
2015-03-26 14:12:37 -04:00
|
|
|
$ docker pull ubuntu
|
2014-04-15 20:53:12 -04:00
|
|
|
|
|
|
|
Note that it will only be downloaded if an image of that name does not
|
|
|
|
already exist. This is downloading a large binary so on first run can
|
|
|
|
take a while. For that reason this define turns off the default 5 minute
|
|
|
|
timeout for the exec type. Note that you can also remove images you no
|
|
|
|
longer need with:
|
|
|
|
|
|
|
|
docker::image { 'ubuntu':
|
|
|
|
ensure => 'absent',
|
|
|
|
}
|
|
|
|
|
|
|
|
### Containers
|
|
|
|
|
|
|
|
Now you have an image where you can run commands within a container
|
|
|
|
managed by Docker.
|
|
|
|
|
|
|
|
docker::run { 'helloworld':
|
|
|
|
image => 'ubuntu',
|
|
|
|
command => '/bin/sh -c "while true; do echo hello world; sleep 1; done"',
|
|
|
|
}
|
|
|
|
|
|
|
|
This is equivalent to running the following command, but under upstart:
|
|
|
|
|
2015-03-26 14:12:37 -04:00
|
|
|
$ docker run -d ubuntu /bin/sh -c "while true; do echo hello world; sleep 1; done"
|
2014-04-15 20:53:12 -04:00
|
|
|
|
|
|
|
Run also contains a number of optional parameters:
|
|
|
|
|
|
|
|
docker::run { 'helloworld':
|
|
|
|
image => 'ubuntu',
|
|
|
|
command => '/bin/sh -c "while true; do echo hello world; sleep 1; done"',
|
|
|
|
ports => ['4444', '4555'],
|
|
|
|
volumes => ['/var/lib/couchdb', '/var/log'],
|
|
|
|
volumes_from => '6446ea52fbc9',
|
|
|
|
memory_limit => 10485760, # bytes
|
|
|
|
username => 'example',
|
|
|
|
hostname => 'example.com',
|
|
|
|
env => ['FOO=BAR', 'FOO2=BAR2'],
|
|
|
|
dns => ['8.8.8.8', '8.8.4.4'],
|
|
|
|
}
|
|
|
|
|
2014-05-14 13:22:49 -04:00
|
|
|
> *Note:*
|
|
|
|
> The `ports`, `env`, `dns` and `volumes` attributes can be set with either a single
|
|
|
|
> string or as above with an array of values.
|