Browse Source

Merge "Conform cgroups to systemd based services"

Jenkins 2 years ago
parent
commit
7dc2405d31

+ 66
- 0
deployment/puppet/cgroups/files/cgconfig.init View File

@@ -0,0 +1,66 @@
1
+#!/bin/sh
2
+### BEGIN INIT INFO
3
+# Provides:          cgconfig
4
+# Required-Start:    $remote_fs $syslog
5
+# Required-Stop:     $remote_fs $syslog
6
+# Should-Start:
7
+# Should-Stop:
8
+# Default-Start:     2 3 4 5
9
+# Default-Stop:      0 1 6
10
+# Short-Description: Configures CGroups
11
+### END INIT INFO
12
+
13
+start_service() {
14
+  if is_running; then
15
+    echo "cgrulesengd is running already!"
16
+    return 1
17
+  else
18
+    echo "Processing /etc/cgconfig.conf ..."
19
+    cgconfigparser -l /etc/cgconfig.conf
20
+    echo "Processing /etc/cgrules.conf ..."
21
+    cgrulesengd -vvv --logfile=/var/log/cgrulesengd.log
22
+    return 0
23
+  fi
24
+}
25
+
26
+stop_service() {
27
+  if is_running; then
28
+    echo "Stopping cgrulesengd ..."
29
+    pkill cgrulesengd
30
+  else
31
+    echo "cgrulesengd is not running!"
32
+    return 1
33
+  fi
34
+}
35
+
36
+status() {
37
+  if pgrep cgrulesengd > /dev/null; then
38
+    echo "cgrulesengd is running"
39
+    return 0
40
+  else
41
+    echo "cgrulesengd is not running!"
42
+    return 3
43
+  fi
44
+}
45
+
46
+is_running() {
47
+  status >/dev/null 2>&1
48
+}
49
+
50
+case "${1:-}" in
51
+  start)
52
+    start_service
53
+    ;;
54
+  stop)
55
+    stop_service
56
+    ;;
57
+  status)
58
+    status
59
+    ;;
60
+  *)
61
+    echo "Usage: /etc/init.d/cgconfig {start|stop|restart|status}"
62
+    exit 2
63
+    ;;
64
+esac
65
+
66
+exit $?

+ 11
- 22
deployment/puppet/cgroups/manifests/init.pp View File

@@ -13,51 +13,40 @@
13 13
 class cgroups(
14 14
   $cgroups_set = {},
15 15
   $packages    = $cgroups::params::packages,
16
-)
17
-  inherits cgroups::params
18
-{
16
+) inherits cgroups::params {
17
+
19 18
   validate_hash($cgroups_set)
20 19
   ensure_packages($packages, { tag => 'cgroups' })
21 20
 
22
-
23 21
   File {
24 22
     ensure => file,
25 23
     owner  => 'root',
26 24
     group  => 'root',
27 25
     mode   => '0644',
26
+    notify => Service['cgconfig'],
28 27
   }
29 28
 
30 29
   file { '/etc/cgconfig.conf':
31 30
     content => template('cgroups/cgconfig.conf.erb'),
32
-    notify  => Service['cgconfigparser'],
33 31
     tag     => 'cgroups',
34 32
   }
35 33
 
36 34
   file { '/etc/cgrules.conf':
37 35
     content => template('cgroups/cgrules.conf.erb'),
38
-    notify  => Service['cgrulesengd'],
39 36
     tag     => 'cgroups',
40 37
   }
41 38
 
39
+  file { '/etc/init.d/cgconfig':
40
+    mode   => '0755',
41
+    source => "puppet:///modules/${module_name}/cgconfig.init",
42
+    tag    => 'cgroups',
43
+  }
44
+
42 45
   class { '::cgroups::service':
43 46
     cgroups_settings => $cgroups_set,
44 47
   }
45 48
 
46
-  Package <| tag == 'cgroups' |> ~>
47
-  Service['cgrulesengd']
48
-
49
-  Package <| tag == 'cgroups' |> ->
50
-  File <| tag == 'cgroups' |>
51
-
52
-  File <| tag == 'cgroups' |> ->
53
-  Service['cgroup-lite']
54
-
55
-  Service['cgroup-lite'] ->
56
-  Service['cgconfigparser']
57
-
58
-  Service['cgconfigparser'] ->
59
-  Cgclassify <||>
49
+  Package <| tag == 'cgroups' |> -> File <| tag == 'cgroups' |>
50
+  Service['cgconfig'] -> Cgclassify <||>
60 51
 
61
-  Cgclassify <||> ->
62
-  Service['cgrulesengd']
63 52
 }

+ 2
- 1
deployment/puppet/cgroups/manifests/params.pp View File

@@ -2,10 +2,11 @@ class cgroups::params {
2 2
 
3 3
   case $::osfamily {
4 4
     'Debian': {
5
-      $packages = ['cgroup-bin', 'libcgroup1', 'cgroup-upstart']
5
+      $packages = ['cgroup-bin', 'libcgroup1']
6 6
     }
7 7
     default: {
8 8
       fail("Unsupported platform")
9 9
     }
10 10
   }
11
+
11 12
 }

+ 6
- 16
deployment/puppet/cgroups/manifests/service.pp View File

@@ -1,26 +1,16 @@
1 1
 class cgroups::service (
2 2
   $cgroups_settings = {},
3
-)
4
-{
5
-  service { 'cgroup-lite':
6
-    ensure => running,
7
-    enable => true,
8
-  }
9
-
10
-  service { 'cgconfigparser':
11
-    ensure    => running,
12
-    hasstatus => false,
13
-    status    => '/bin/true',
14
-    restart   => 'service cgconfigparser restart',
15
-    require   => Service['cgroup-lite'],
16
-  }
3
+) {
17 4
 
18
-  service { 'cgrulesengd':
19
-    ensure => running,
5
+  service { 'cgconfig':
6
+    ensure   => running,
7
+    enable   => true,
8
+    provider => 'init',
20 9
   }
21 10
 
22 11
   $cgclass_res = map_cgclassify_opts($cgroups_settings)
23 12
   unless empty($cgclass_res) {
24 13
     create_resources('cgclassify', $cgclass_res, { 'ensure' => present })
25 14
   }
15
+
26 16
 }

+ 3
- 3
deployment/puppet/cgroups/spec/classes/cgroups_init_spec.rb View File

@@ -15,6 +15,7 @@ describe 'cgroups', :type => :class do
15 15
         :owner   => 'root',
16 16
         :group   => 'root',
17 17
         :mode    => '0644',
18
+        :notify  => 'Service[cgconfig]',
18 19
         :tag     => 'cgroups',
19 20
       }
20 21
     end
@@ -27,7 +28,7 @@ describe 'cgroups', :type => :class do
27 28
         :cgroups_settings => params[:cgroups_set])
28 29
     }
29 30
 
30
-    %w(libcgroup1 cgroup-bin cgroup-upstart).each do |cg_pkg|
31
+    %w(libcgroup1 cgroup-bin).each do |cg_pkg|
31 32
       it { is_expected.to contain_package(cg_pkg) }
32 33
     end
33 34
 
@@ -36,7 +37,6 @@ describe 'cgroups', :type => :class do
36 37
       it { p catalogue.resource 'file', cg_file }
37 38
     end
38 39
 
39
-    it { is_expected.to contain_file('/etc/cgrules.conf').that_notifies('Service[cgrulesengd]') }
40
-    it { is_expected.to contain_file('/etc/cgconfig.conf').that_notifies('Service[cgconfigparser]') }
40
+    it { is_expected.to contain_file('/etc/init.d/cgconfig').with(file_defaults.merge({:mode => '0755'})) }
41 41
   end
42 42
 end

+ 1
- 3
deployment/puppet/cgroups/spec/classes/cgroups_service_spec.rb View File

@@ -9,8 +9,6 @@ describe 'cgroups::service', :type => :class do
9 9
       }
10 10
     end
11 11
 
12
-    %w(cgroup-lite cgconfigparser cgrulesengd).each do |cg_service|
13
-      it { is_expected.to contain_service(cg_service) }
14
-    end
12
+    it { is_expected.to contain_service('cgconfig') }
15 13
   end
16 14
 end

Loading…
Cancel
Save