Skip to content
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
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Manage cgroups configuration service and files.

- /etc/cgconfig.conf
- /etc/cgconfig.d/*.conf
- /etc/cgconfig.d/*.conf (EL only)

# Compatibility

Expand All @@ -15,6 +15,7 @@ using Ruby versions 1.8.7 (Puppet v3 only), 1.9.3, 2.0.0, 2.1.0 and 2.3.1.
* EL 7
* SLED 11 SP2
* SLES 11 SP2
* SLES 12 SP1

[![Build Status](https://travis-ci.org/Ericsson/puppet-module-cgroups.png?branch=master)](https://travis-ci.org/Ericsson/puppet-module-cgroups)

Expand Down Expand Up @@ -108,6 +109,12 @@ Absolute path to set 0775 permissions on when defined. This is a fix for Suse th

- *Default*: undef

---
#### create_default_cgroup (string)
Suse 12 will create a default cgroup called 'sysdefault'. Disable this by default. Set to 'yes' if you really want it. Only available on Suse.

- *Default*: 'no'

---

## Defined type `cgroups::group`
Expand Down
45 changes: 35 additions & 10 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
# Manage cgroups configuration service and files.
#
class cgroups (
$config_file_path = '/etc/cgconfig.conf',
$service_name = 'cgconfig',
$package_name = undef,
$cgconfig_content = undef,
$user_path_fix = undef,
$mounts = {},
$groups = {},
$config_file_path = '/etc/cgconfig.conf',
$service_name = 'cgconfig',
$package_name = undef,
$cgconfig_content = undef,
$user_path_fix = undef,
$create_default_cgroup = 'no',
$mounts = {},
$groups = {},
) {

# variables preparation
Expand All @@ -26,7 +27,7 @@
}
'Suse': {
case $::operatingsystemrelease {
/11\.[2-9]/: {
/12|11\.[2-9]/: {
$package_name_default = 'libcgroup1'
}
default: {
Expand Down Expand Up @@ -63,6 +64,10 @@
validate_absolute_path($user_path_fix)
}

if is_string($create_default_cgroup) == false {
fail('cgroups::create_default_cgroup is not a string.')
}

validate_hash($mounts)
validate_hash($groups)

Expand All @@ -71,10 +76,19 @@
ensure => present,
}

# Suse 12 does not support /etc/cgconfig.d
if (($::osfamily == 'Suse') and (scanf("${::operatingsystemmajrelease}", "%i")[0] >= 12)) {
$config_file_template = 'cgroups/cgroup.conf-Suse.erb'
}
else {
$config_file_template = 'cgroups/cgroup.conf.erb'
create_resources('cgroups::group', $groups)
}

file { $config_file_path:
ensure => file,
notify => Service[$service_name],
content => template('cgroups/cgroup.conf.erb'),
content => template($config_file_template),
require => Package[$package_name_real],
}

Expand All @@ -84,7 +98,18 @@
require => Package[$package_name_real],
}

create_resources('cgroups::group', $groups)
# Suse 12 - do we create the sysdefault/ default cgroup? No by default
if ($::osfamily == 'Suse') {
file { '/etc/sysconfig/cgconfig':
ensure => file,
owner => root,
group => root,
mode => '0644',
content => "CREATE_DEFAULT=$create_default_cgroup\n",
notify => Service[$service_name],
require => Package[$package_name_real],
}
}

if ($user_path_fix != undef) and ($::osfamily == 'Suse') {
file { 'cgroups_path_fix':
Expand Down
41 changes: 41 additions & 0 deletions templates/cgroup.conf-Suse.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# This file is being maintained by Puppet.
# DO NOT EDIT
<% unless @mounts.empty? -%>

mount {
<% @mounts.sort.each do |p,v| -%>
<%= p %> = <%= v %>;
<% end -%>
}
<% end -%>
<% unless @cgconfig_content.nil? -%>

<%= @cgconfig_content %>
<% end -%>


<% @groups.sort.each do |groupname,grouphash| -%>
group <%= groupname %> {
<% unless grouphash['permissions'].nil? -%>

perm {
<% grouphash['permissions'].sort.each do |type, params| -%>
<%= type %> {
<% params.sort.each do |p,v| -%>
<%= p %> = <%= v %>;
<% end -%>
}
<% end -%>
}
<% end -%>
<% grouphash['controllers'].sort.each do |controller, params| -%>

<%= controller %> {
<% params.sort.each do |p,v| -%>
<%= p %> = <%= v %>;
<% end -%>
}
<% end -%>

}
<% end -%>