Home

Awesome

Mesos Puppet Module

Puppet
Forge Build Status Puppet Forge
Downloads

COMPATIBILITY NOTE: current version (0.6.x) requires puppetlabs-apt >= 2.1.0 which has significantly refactored API (doesn't matter if you don't wanna use Mesosphere APT repo).

deric-mesosPuppet 3.xPuppet 4.xPuppet 5.x
0.9.x:heavy_check_mark::heavy_check_mark::heavy_check_mark:
1.x.x:x::heavy_check_mark::heavy_check_mark:

For installing master

class{'mesos':
  repo => 'mesosphere',
  zookeeper => [ '192.168.1.1', '192.168.1.2', '192.168.1.3'],
}

class{'mesos::master':
  work_dir => '/var/lib/mesos',
  options => {
    quorum   => 2
  }
}

From ZooKeeper array an URI is created zk://192.168.1.1:2181,192.168.1.2:2181,192.168.1.3:2181/mesos. In order to customize this use either server:port or see zk_path and zk_default_port variable.

Example slave configuration:

class{'mesos::slave':
  attributes => {
    'env' => 'production',
  },
  resources => {
    'ports' => '[10000-65535]'
  },
  options   => {
    'isolation'      => 'cgroups/cpu,cgroups/mem',
    'containerizers' => 'docker,mesos',
    'hostname'       => $::fqdn,
  }
}

for using Hiera and other options see below.

Shared parameters

Parameters:

Master

Should be as simple as this, on master node:

class{'mesos::master': }

optionally you can specify some parameters or it is possible to configure Mesos via Hiera (see below).

class{'mesos::master':
  master_port => 5050,
  work_dir => '/var/lib/mesos',
  options => {
    quorum   => 4
  }
}

For slave you have to specify either master

class{'mesos::slave':
  master => '192.168.1.1'
}

or zookeeper node(s) to connect:

class{'mesos::slave':
  zookeeper => ['192.168.1.1:2181', '192.168.1.2:2181', '192.168.1.3:2181']
}

listen address

By default Mesos will bind to 0.0.0.0. If you want to change the IP address Mesos is binding to, you can either provide a Puppet Fact:

class{'mesos::master':
  listen_address => $::ipaddress_eth0
}

or directly use some IP address:

class{'mesos::master':
  listen_address => '192.168.1.1'
}

Note that Facter 2 will contain incorrect IP address in $::ipaddress fact when Docker is installed. See FACT-380 for more information.

By default no IP address is set, which means that Mesos will use IP to which translates hostname -f (you can influence bind address simply in /etc/hosts).

Slave

class{'mesos::slave':
  master  => '192.168.1.1',
  env_var => {
    'JAVA_HOME' => '/usr/bin/java'
  }
}

in a similar manner you can specify cgroups isolation:

class{'mesos::slave':
  zookeeper  => 'zk://192.168.1.1:2181/mesos',
  isolation  => 'cgroups/cpu,cgroups/mem',
  cgroups    => {
    'hierarchy' => '/sys/fs/cgroup',
    'root'      => 'mesos',
  }
}

File based configuration

As Mesos configuration flags changes with each version we don't provide directly a named parameter for each flag. mesos::property allows to create a parameter file. e.g. configure value in /etc/mesos-slave/hostname:

mesos::property { 'hostname':
  value  => 'mesos.hostname.com',
  dir    => '/etc/mesos-slave',
  notify => Service['mesos-slave']
}

Remove this file simply use the ensure parameter:

mesos::property { 'hostname':
  ensure => absent,
  dir    => '/etc/mesos-slave',
  notify => Service['mesos-slave']
}

This is equivalent approach to

class{'mesos::slave':
  options => {
    'hostname' => 'mesos.hostname.com'
  }
}

which will create a file /etc/mesos-slave/hostname with content mesos.hostname.com (where /etc/mesos-slave is a slave's $conf_dir).

Yet another option would be to pass this value via Hiera (see the section below).

Boolean flags

Current Mesos packages recognizes boolean flags like --[no-]quiet via files named as /etc/mesos-slave/?quiet for --quiet (true) and /etc/mesos-slave/?no-quiet for false value.

class{'mesos::slave':
  options => {
    'quiet' => true
  }
}

since 0.4.1

Mesos Standalone

Standalone mode (non-HA) is useful for testing, it does not require ZooKeeper URI, nor quorum variable. If you are running both master and slave on the same node, make sure you disable single_role parameter:

class{'::mesos':
  single_role => false,
}

Hiera support

All configuration could be handled by Hiera. Simple parameter are looked up by default in Puppet 3, however hashes won't get merged. In order to merge options from multiple Hiera files set mesos::use_hiera: true.

Either specify one master

mesos::master      : '192.168.1.1'

or Zookeeper could be use for a fault-tolerant setup (multiple instances of zookeeper are separated by comma):

mesos::zookeeper:
  - '192.168.1.1:2181'
  - '192.168.1.2:2181'
  - '192.168.1.3:2181'

Some parameters are shared between master and slave nodes:

mesos::master_port : 5050
mesos::log_dir     : '/var/log/mesos'
mesos::conf_dir    : '/etc/mesos'
mesos::owner       : 'mesos'
mesos::group       : 'mesos'

Other are master specific:

mesos::master::cluster     : 'my_mesos_cluster'
mesos::master::whitelist   : '*'

or slave specific:

mesos:slave::env_var:
  JAVA_HOME: '/usr/bin/java'

Mesos service reads configuration either from ENV variables or from configuration files wich are stored in /etc/mesos-slave resp. /etc/mesos-master. Hash passed via options will be converted to config files. Most of the options is possible to configure this way:

mesos::master::options:
  webui_dir: '/usr/local/share/mesos/webui'
  quorum: '4'

you can also use facts from Puppet:

mesos::master::options:
  hostname: "%{::fqdn}"

cgroups with Hiera:

mesos::slave::isolation: 'cgroups/cpu,cgroups/mem'
mesos::slave::cgroups:
  hierarchy: '/sys/fs/cgroup'

Limit resources used by Mesos slave:

mesos::slave::resources:
  cpus: '10'

Mesos CLI

Mesos command line interface is written in Python (currently supports 2.6 and 2.7). The CLI provides serveral useful commands like mesos ps ,mesos ls. For complete list see CLI documentation.

By default CLI is not installed with master nor slave, you should enable this manually by including

class{'mesos::cli':
  debug            => false,
  response_timeout => 5,
}

on any machine that can connect to mesos-master and mesos-slaves.

Python installation

Python is required for Mesos Web UI and for CLI as well. Installing Python with Mesos should be responsibility of binary packages (Mesos could be build without UI), therefore this behaviour is not enabled by default.

You can enable this feature with following:

class{'mesos':
  manage_python => true
}

or change Python package name, to match your needs:

class{'mesos':
  manage_python => true,
  python_package => 'python-dev'
}

Software repository

Software repositories could be enabled by defining a source:

mesos::repo: 'mesosphere'
mesos::manage_repo: true

or in Puppet code:

class{'mesos':
  repo        => 'mesosphere',
  manage_repo => true,
}

by default this feature is enabled and right we support mesosphere.io repositories for:

Feel free to send PR for other distributions/package sources.

Custom APT repository

Default APT repository is configured following way:

class{'mesos':
  repo => {
    location => "http://repos.mesosphere.io/${osfamily}",
    release  => $::lsbdistcodename,
    repos    => 'main',
    key      => {
      'id'     => '81026D0004C44CF7EF55ADF8DF7D54CBE56151BF',
      'server' => 'keyserver.ubuntu.com',
    },
    include  => {
      'src' => false
    },
  }
}

where the repo hash is passsed to apt::source (from offcial apt module).

In case you want to override some settings, only the modified values needs to be passed e.g.:

class{'mesos':
  repo => {
    location => "http://myrepo.example.com",
    key      => {
      'id'     => '{mykey}',
      'server' => 'keyserver.ubuntu.com',
    },
  }
}

since 0.8.2

Overriding service providers

Some Mesos packages does not respect conventions on given OS for starting services. For both mesos::master and mesos::slave you can specify mechanism which will be used for starting services.

class{'mesos::master':
  service_provider => 'upstart'
}

If you want to create the service resource yourself, set service_provider to none.

Some reasonable values are:

A custom systemd configuration example:

class{'mesos::master':
  service_provider    => 'systemd',
  manage_service_file => true,
  systemd_wants       => 'network.target zookeeper.service',
  systemd_after       => 'network.target zookeeper.service',
}

Packages

You can build package by yourself and upload package to your software repository. Or use packages from mesosphere.io:

Requirements

Dependencies

Installation

Preferred installation is via puppet-librarian just add to Puppetfile:

mod 'deric/mesos', '>= 0.6.0'

for latest version from git:

mod 'deric/mesos', :git => 'git://github.com/deric/puppet-mesos.git'

Acceptance testing

Fastest way is to run tests on prepared Docker images:

BEAKER_set=debian9-5.5 bundle exec rake acceptance

For examining system state set Beaker's ENV variable BEAKER_destroy=no:

BEAKER_destroy=no BEAKER_set=debian9-6.3 bundle exec rake acceptance

and after finishing tests connect to container:

Links

For more information see Mesos project

License

Apache License 2.0

Contributors

Alphabetical list of contributors (not necessarily up-to-date), generated by command git log --format='%aN' | sort -u | sed -e 's/^/\- /':