diff --git a/README.md b/README.md index 95df42c..2cf1524 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ Manage cgroups configuration service and files. - /etc/cgconfig.conf -- /etc/cgconfig.d/*.conf +- /etc/cgconfig.d/*.conf (EL only) # Compatibility @@ -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) @@ -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` diff --git a/manifests/init.pp b/manifests/init.pp index a22dac9..05b2d3b 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -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 @@ -26,7 +27,7 @@ } 'Suse': { case $::operatingsystemrelease { - /11\.[2-9]/: { + /12|11\.[2-9]/: { $package_name_default = 'libcgroup1' } default: { @@ -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) @@ -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], } @@ -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': diff --git a/templates/cgroup.conf-Suse.erb b/templates/cgroup.conf-Suse.erb new file mode 100644 index 0000000..32eed92 --- /dev/null +++ b/templates/cgroup.conf-Suse.erb @@ -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 -%>