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

RHEL7/CentOS7 support + 5 more #30

Open
wants to merge 6 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
26 changes: 26 additions & 0 deletions manifests/common.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# == Define: common::mkdir_p
#
# Provide `mkdir -p` functionality for a directory
#
# Idea is to use this mkdir_p in conjunction with a file resource
#
# Example usage:
#
# common::mkdir_p { '/some/dir/structure': }
#
# file { '/some/dir/structure':
# ensure => directory,
# require => Common::Mkdir_p['/some/dir/structure'],
# }
#
define mesos::common::mkdir_p () {

validate_absolute_path($name)

exec { "mkdir_p-${name}":
creates => "${name}",
command => "mkdir -p ${name}",
unless => "test -d ${name}",
path => '/bin:/usr/bin',
}
}
13 changes: 5 additions & 8 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,24 @@
){
validate_bool($manage_zk_file)

File {
owner => $owner,
group => $group,
}

if $log_dir {
file { $log_dir:
ensure => directory,
owner => $owner,
group => $group,
}
}

file { $conf_dir:
ensure => directory,
owner => $owner,
group => $group,
}

file { $conf_file:
ensure => 'present',
content => template('mesos/default.erb'),
owner => $owner,
group => $group,
mode => '0644',
require => Package['mesos'],
}
Expand All @@ -57,8 +56,6 @@
false => present,
},
content => $zookeeper_url,
owner => $owner,
group => $group,
}
}

Expand Down
29 changes: 17 additions & 12 deletions manifests/master.pp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
$enable = true,
$cluster = 'mesos',
$conf_dir = '/etc/mesos-master',
$work_dir = '/var/lib/mesos', # registrar directory, since 0.19
$work_dir = '/var/lib/mesos/master', # registrar directory, since 0.19
$conf_file = '/etc/default/mesos-master',
$acls_file = '/etc/mesos/acls',
$credentials_file = '/etc/mesos/master-credentials',
Expand All @@ -41,6 +41,7 @@
$credentials = [],
$syslog_logger = true,
$force_provider = undef, #temporary workaround for starting services
$quorum = $mesos::quorum,
$use_hiera = $mesos::use_hiera,
$single_role = $mesos::single_role,
) inherits mesos {
Expand Down Expand Up @@ -91,35 +92,42 @@
$zookeeper_url = zookeeper_servers_url($zookeeper, $zk_path, $zk_default_port)
}

file { $conf_dir:
ensure => directory,
File {
owner => $owner,
group => $group,
}

# TODO this duplicated in master / slave. move up
common::mkdir_p { $work_dir: } ->
file { $conf_dir:
ensure => directory,
}

# TODO this duplicated in master / slave. move up
common::mkdir_p { $conf_dir: } ->
file { $conf_dir:
ensure => directory,
recurse => true,
purge => true,
force => true,
require => Class['::mesos::install'],
}

# TODO this duplicated in master / slave. move up
common::mkdir_p { $work_dir: } ->
file { $work_dir:
ensure => directory,
owner => $owner,
group => $group,
}

file { $acls_file:
ensure => $acls_ensure,
content => $acls_content,
owner => $owner,
group => $group,
mode => '0444',
}

file { $credentials_file:
ensure => $credentials_ensure,
content => $credentials_content,
owner => $owner,
group => $group,
mode => '0400',
}

Expand All @@ -145,10 +153,7 @@
)

file { $conf_file:
ensure => present,
content => template('mesos/master.erb'),
owner => $owner,
group => $group,
mode => '0644',
require => [File[$conf_dir], Package['mesos']],
}
Expand Down
5 changes: 5 additions & 0 deletions manifests/repo.pp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@
}
case $osrel {
'6', '7': {
exec { 'yum-clean-expire-cache':
user => 'root',
path => '/usr/bin',
command => 'yum clean expire-cache',
} ->
package { 'mesosphere-el-repo':
ensure => present,
provider => 'rpm',
Expand Down
16 changes: 16 additions & 0 deletions manifests/service.pp
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,24 @@
$manage = true,
) {

if $::osfamily == 'RedHat' and $::operatingsystemmajrelease >= 7 {
notice("Installing mesos-${name} service")
file { "/etc/systemd/system/mesos-${name}.service":
path => "/etc/systemd/system/mesos-${name}.service",
content => template('mesos/service/systemd/mesos.service.erb'),
backup => false,
ensure => file,
owner => $owner,
group => $group,
mode => 755
}->Exec["systemd_reload_${name}"]
include ::mesos

exec { "systemd_reload_${name}":
command => '/bin/systemctl daemon-reload',
}
}
$zk = $mesos::zk
if $manage {
if $enable {
$ensure_service = 'running'
Expand Down
22 changes: 9 additions & 13 deletions manifests/slave.pp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
class mesos::slave (
$enable = true,
$port = 5051,
$work_dir = '/tmp/mesos',
$work_dir = '/var/lib/mesos/slave',
$checkpoint = false,
$isolation = '',
$conf_dir = '/etc/mesos-slave',
Expand All @@ -75,6 +75,7 @@
$secret = undef,
$syslog_logger = true,
$force_provider = undef, #temporary workaround for starting services
$containerizers = "docker,mesos",
$use_hiera = $mesos::use_hiera,
$single_role = $mesos::single_role,
) inherits mesos {
Expand All @@ -99,28 +100,28 @@
$zookeeper_url = zookeeper_servers_url($zookeeper, $zk_path, $zk_default_port)
}

file { $conf_dir:
ensure => directory,
File {
owner => $owner,
group => $group,
}

common::mkdir_p { $conf_dir: } ->
file { $conf_dir:
ensure => directory,
recurse => true,
purge => true,
force => true,
}

file { "${conf_dir}/resources":
ensure => directory,
owner => $owner,
group => $group,
require => File[$conf_dir],
recurse => true,
purge => true,
}

file { "${conf_dir}/attributes":
ensure => directory,
owner => $owner,
group => $group,
require => File[$conf_dir],
recurse => true,
purge => true,
Expand Down Expand Up @@ -174,17 +175,14 @@
notify => Service['mesos-slave'],
}

common::mkdir_p { $work_dir: } ->
file { $work_dir:
ensure => directory,
owner => $owner,
group => $group,
}

file { $credentials_file:
ensure => $credentials_ensure,
content => $credentials_content,
owner => $owner,
group => $group,
mode => '0400',
}

Expand Down Expand Up @@ -221,8 +219,6 @@
file { $conf_file:
ensure => 'present',
content => template('mesos/slave.erb'),
owner => $owner,
group => $group,
mode => '0644',
require => [Class['mesos::config'], File[$conf_dir], Package['mesos']],
}
Expand Down
31 changes: 12 additions & 19 deletions templates/master.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/bin/sh
# Managed by Puppet
#
# A list of the available options can be seen by running `mesos-master --help`. Each
Expand All @@ -11,24 +10,18 @@
# Configuration values are searched for first in the environment, thus values set
# in here precede those loaded from /etc/mesos-master (passed as command line arguments).

# ZooKeeper URL (used for leader election amongst masters)
export MESOS_ZK="<%= @zookeeper_url %>"
MESOS_WORK_DIR="<%= @work_dir %>"
MESOS_ZK="<%= @zookeeper %>"
MESOS_QUORUM=<%= @quorum %>
<% if @listen_address && @listen_address != "" %>
MESOS_IP="<%= @listen_address %>"
<% end %>
MESOS_PORT=<%= @master_port %>
MESOS_CLUSTER="<%= @cluster %>"
MESOS_LOG_DIR="<%= @log_dir %>"
MESOS_LOGBUFSECS=1
MESOS_LOGGING_LEVEL="INFO"

# Human readable name for the cluster, displayed in the webui
export MESOS_CLUSTER="<%= @cluster %>"

# IP address to listen on (in case that you start master
# on this node, it will bind to this address)
<% if @listen_address -%>
export MESOS_IP="<%= @listen_address %>"
<% else -%>
#export MESOS_IP=""
<% end -%>

# Port to listen on (default: 5050)
export MESOS_PORT=<%= @master_port %>

# master environment variables
<% @env_var.sort.each do |key,val| -%>
export <%= key %>="<%= val %>"
<%= key %>="<%= val %>"
<% end if @env_var -%>
25 changes: 25 additions & 0 deletions templates/service/systemd/mesos.service.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[Unit]
Description=Mesos <%= @name %>
After=network.target
Wants=network.target

[Service]
Delegate=yes
ExecStart=/usr/sbin/mesos-<%= @name %> <% if @name=='slave' -%>-containerizers=docker,mesos<% end -%>
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're using Mesosphere packages it would be easier to use:

ExecStart=/usr/bin/mesos-init-wrapper <%= @name %>

if you want to execute directly mesos binaries, we have to make sure, that all environment variables are defined.
Either way -containerizers=docker,mesos should not be hardcoded.


EnvironmentFile=/etc/default/mesos-<%= @name %>
ExecReload=/bin/kill -HUP $MAINPID
User=root
Restart=always
; TODO check if 16K is enough
LimitNOFILE=16384

<% if @name=='slave' -%>
Slice=mesos
CPUAccounting=true
CPUShares=1024
MemoryAccounting=true
<% end -%>

[Install]
WantedBy=multi-user.target
34 changes: 27 additions & 7 deletions templates/slave.erb
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,46 @@
# If zookeeper URL is not specified, slaves will connect directly
# to specified master (not a fault-tolerant mode)
<% if !@zookeeper_url.nil? && !@zookeeper_url.empty? -%>
export MESOS_MASTER="<%= @zookeeper_url %>"
MESOS_MASTER="<%= @zookeeper_url %>"
<% else -%>
export MESOS_MASTER="<%= @master %>:<%= @master_port %>"
MESOS_MASTER="<%= @master %>:<%= @master_port %>"
<% end -%>

# public slave's ip, must be unique in mesos cluster
<% if @listen_address -%>
export MESOS_IP="<%= @listen_address %>"
MESOS_IP="<%= @listen_address %>"
<% else -%>
#export MESOS_IP=""
#MESOS_IP=""
<% end -%>

# Port to listen on (default: 5051)
export MESOS_PORT=<%= @port %>
MESOS_PORT=<%= @port %>

<% @cgroups.sort.each do |key, val| -%>
export MESOS_CGROUPS_<%= key.upcase %>="<%= val %>"
MESOS_CGROUPS_<%= key.upcase %>="<%= val %>"
<% end if @isolation == 'cgroups' -%>


MESOS_isolation='cgroups/cpu,cgroups/mem'
MESOS_cgroups_root='system.slice/mesos-slave.service'
MESOS_cgroups_hierarchy=/sys/fs/cgroup
MESOS_slave_subsystems=cpu,memory
MESOS_gc_delay=1days

MESOS_executor_registration_timeout=5mins

<% if @listen_address && @listen_address != "" %>
MESOS_ip="<%= @listen_address %>"
<% end %>
MESOS_port=<%= @port %>
MESOS_log_dir="<%= @log_dir %>"
MESOS_logbufsecs=1
MESOS_logging_level="INFO"
#TODO(clehene) note that we're also passing -containerizers to mesos-slave as this doesn't seem to be working
MESOS_containerizers=<%= @containerizers %>
MESOS_hadoop_home=$HADOOP_HOME

# slave environment variables
<% @env_var.sort.each do |key,val| -%>
export <%= key %>="<%= val %>"
<%= key %>="<%= val %>"
<% end if @env_var -%>