Skip to content

scotty-c/puppet-docker_swarm

Repository files navigation

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 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',
    extra_parameters => ['--restart=always'],
    }

   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',
     depends    => 'logstash',
     }
   
   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',
     depends    => 'logstash',
     }

##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.

About

A puppet module for Docker Swarm

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •