Forge Home

docker_swarm

A module for Docker Swarm

21,430 downloads

15,272 latest version

4.2 quality score

We run a couple of automated
scans to help you access a
module's quality. Each module is
given a score based on how well
the author has formatted their
code and documentation and
modules are also checked for
malware using VirusTotal.

Please note, the information below
is for guidance only and neither of
these methods should be considered
an endorsement by Puppet.

Version information

  • 1.0.2 (latest)
  • 1.0.1
  • 1.0.0
  • 0.0.8
  • 0.0.7
  • 0.0.6
  • 0.0.5
  • 0.0.4
  • 0.0.3
  • 0.0.2
  • 0.0.1
released Mar 28th 2016
This version is compatible with:
  • ,

Start using this module

  • r10k or Code Manager
  • Bolt
  • Manual installation
  • Direct download

Add this module to your Puppetfile:

mod 'scottyc-docker_swarm', '1.0.2'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add scottyc-docker_swarm
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install scottyc-docker_swarm --version 1.0.2

Direct download is not typically how you would use a Puppet module to manage your infrastructure, but you may want to download the module in order to inspect the code.

Download
Tags: docker, swarm

Documentation

scottyc/docker_swarm — version 1.0.2 Mar 28th 2016

Docker Swarm

Build Status PuppetForge Puppet Forge Downloads

Table of Contents

  1. Overview
  2. Module Description
  3. Usage
  4. Dependencies
  5. Development

Overview

A module to install aand configure Docker Swarm.

Module Description

This module installs Docker Swarm from source, The module has the option to configure Docker and Golang for you. (Note it takes about 5 mins for the first puppet run as it compiles both swarm and golang) The module has support for all the back ends that Docker Swarm supports (consul, etcd, mesos or zookepper) or you can create a native swarm cluster This is the first release of the module so if there are any feature request please log them in the issue page. I will try to get to as many as possible.

The module is compatible with :

RHEL 7 family

Ubuntu 14.04

Usage

For basic usage:

include docker_swarm

To customize the install with a third party back end:

class {'docker_swarm':}

swarm_cluster {'cluster 1':
  ensure       => present,
  backend      => 'consul',
  cluster_type => 'join',
  port         => '8500',
  address      => '172.17.8.101',
  path         => 'swarm'
  } 

The provider allows the following types

backend this can be consul, etcd, mesos or zookepper

cluster_type this can be either join, manage or swarm

port this the port for connection to the backend. For example consul would be 8500

address this is the address of the backend

path this is the path for the key/value store

To customize the install using the native swarm discovery service:

class {'docker_swarm':}

swarm_cluster {'cluster 1':
  ensure       => present,
  backend      => 'swarm',
  cluster_type => 'create',
  } 

To manage the the cluster with a third party back end, if you have more than one master the module will configure master replication. Port 4000 will need to be open between the masters and set the interface you would like to advertise for replication with the advertise param:

class {'docker_swarm':}

swarm_cluster {'cluster 1':
  ensure       => present,
  backend      => 'consul',
  cluster_type => 'manage',
  port         => '8500',
  advertise    => 'eth0', 
  address      => '172.17.8.101',
  path         => 'swarm', 
  } 

The module now supports running your containers natively into your Swarm cluster. Please see the below example.


 swarm_run {'logstash':
    ensure     => present,
    image      => 'scottyc/logstash',
    network    => 'swarm-private',
    ports      => ['9998:9998', '9999:9999/udp', '5000:5000', '5000:5000/udp'],
    env        => ['ES_HOST=elasticsearch', 'ES_PORT=9200'],
    command    => 'logstash -f /opt/logstash/conf.d/logstash.conf --debug',
    require    => Class['config::swarm'] 
    }

   swarm_run {'elasticsearch':
     ensure     => present,
     image      => 'elasticsearch:2.1.0',
     network    => 'swarm-private',
     volumes    => ['/etc/esdata:/usr/share/elasticsearch/data'],
     command    => 'elasticsearch -Des.network.host=0.0.0.0',
     log_driver => 'syslog',
     log_opt    => 'syslog-address=tcp://logstash-5000.service.consul:5000',
     depends    => 'logstash',
     require    => Class['config::swarm'] 
     }
   
   swarm_run {'kibana':
     ensure     => present,
     image      => 'kibana:4.3.0',
     network    => 'swarm-private',
     ports      => ['80:5601'],
     env        => ['ELASTICSEARCH_URL=http://elasticsearch:9200', 'reschedule:on-node-failure'],
     log_driver => 'syslog',
     log_opt    => 'syslog-address=tcp://logstash-5000.service.consul:5000',
     depends    => 'logstash',
     require    => Class['config::swarm'] 
     }

##Dependencies

This module needs :

scottyc/golang

garethr/docker

puppetlabs/stdlib

puppetlabs/vcsrepo

Demo Lab

If you want to test Docker Swarm, I built a test lab for PuppetConf 2015. You can find that here

Swarm Demo Lab

Development

Pull request welcome. Just hit me up.