From 868a8ec5c50150e6ec8ae8f40325018c53ed4baf Mon Sep 17 00:00:00 2001 From: Paul Belanger Date: Tue, 28 Jun 2016 17:07:49 -0400 Subject: [PATCH] Add systemd scripts for cgroups This is needed for Ubuntu Xenial. Change-Id: Ibe7d18f10aa48222b8bc08fd6f56cc9cd2790232 Signed-off-by: Paul Belanger --- files/cgroups/cgconfig.service | 17 +++++++++++++++++ files/cgroups/cgred.service | 11 +++++++++++ manifests/cgroups.pp | 32 ++++++++++++++++++++------------ manifests/params.pp | 4 ++-- 4 files changed, 50 insertions(+), 14 deletions(-) create mode 100644 files/cgroups/cgconfig.service create mode 100644 files/cgroups/cgred.service diff --git a/files/cgroups/cgconfig.service b/files/cgroups/cgconfig.service new file mode 100644 index 0000000..9b546a6 --- /dev/null +++ b/files/cgroups/cgconfig.service @@ -0,0 +1,17 @@ +[Unit] +Description=Control Group configuration service + +# The service should be able to start as soon as possible, +# before any 'normal' services: +DefaultDependencies=no +Conflicts=shutdown.target +Before=basic.target shutdown.target + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/usr/sbin/cgconfigparser -l /etc/cgconfig.conf -s 1664 +ExecStop=/usr/sbin/cgclear -l /etc/cgconfig.conf -e + +[Install] +WantedBy=sysinit.target diff --git a/files/cgroups/cgred.service b/files/cgroups/cgred.service new file mode 100644 index 0000000..7280b6e --- /dev/null +++ b/files/cgroups/cgred.service @@ -0,0 +1,11 @@ +[Unit] +Description=CGroups Rules Engine Daemon +After=syslog.target + +[Service] +Type=forking +EnvironmentFile=-/etc/sysconfig/cgred +ExecStart=/usr/sbin/cgrulesengd $OPTIONS + +[Install] +WantedBy=multi-user.target diff --git a/manifests/cgroups.pp b/manifests/cgroups.pp index 4e9fa02..e0e1814 100644 --- a/manifests/cgroups.pp +++ b/manifests/cgroups.pp @@ -33,15 +33,14 @@ class jenkins::cgroups { source => 'puppet:///modules/jenkins/cgroups/cgrules.conf', } - # Starting with Ubuntu Quantal (12.10) cgroup-bin dropped its upstart jobs. if $::osfamily == 'Debian' { - - if $::operatingsystem == 'Ubuntu' and versioncmp($::operatingsystemrelease, '12.10') >= 0 { - - file { '/etc/init/cgconfig.conf': + # 14.04 and below is using upstart. + if $::operatingsystem == 'Ubuntu' and versioncmp($::operatingsystemrelease, '14.04') <= 0 { + file { 'cgconfig.service': ensure => present, replace => true, owner => 'root', + path => '/etc/init/cgconfig.conf', group => 'root', mode => '0644', source => 'puppet:///modules/jenkins/cgroups/upstart_cgconfig', @@ -52,10 +51,11 @@ class jenkins::cgroups { target => '/lib/init/upstart-job', } - file { '/etc/init/cgred.conf': + file { 'cgred.service': ensure => present, replace => true, owner => 'root', + path => '/etc/init/cgred.conf', group => 'root', mode => '0644', source => 'puppet:///modules/jenkins/cgroups/upstart_cgred', @@ -65,19 +65,27 @@ class jenkins::cgroups { ensure => link, target => '/lib/init/upstart-job', } - } else { - - file { '/etc/init/cgconfig.conf': + file { 'cgred.service': ensure => present, + replace => true, + owner => 'root', + path => '/etc/systemd/system/cgred.service', + group => 'root', + mode => '0644', + source => 'puppet:///modules/jenkins/cgroups/cgred.service', } - file { '/etc/init/cgred.conf': + file { 'cgconfig.service': ensure => present, + replace => true, + owner => 'root', + path => '/etc/systemd/system/cgconfig.service', + group => 'root', + mode => '0644', + source => 'puppet:///modules/jenkins/cgroups/cgconfig.service', } - } - } service { 'cgconfig': diff --git a/manifests/params.pp b/manifests/params.pp index f7c8637..f96ca3c 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -48,11 +48,11 @@ class jenkins::params { $cgroups_tools_package = '' $cgconfig_require = [ Package['cgroups'], - File['/etc/init/cgconfig.conf'], + File['cgconfig.service'], ] $cgred_require = [ Package['cgroups'], - File['/etc/init/cgred.conf'], + File['cgred.service'], ] # ruby packages # ruby1.9.1 is not present in Debian Jessie, use ruby instead