Defined Type: psick::services::systemd_script

Defined in:
manifests/services/systemd_script.pp

Overview

Define psick::services::systemd_script

This define manages the creation of a systemd script and of the relevant service.

Parameters:

  • ensure (Enum['present','absent']) (defaults to: present)
  • source (Optional[String]) (defaults to: undef)
  • content (Optional[String]) (defaults to: undef)
  • template (Optional[String]) (defaults to: undef)
  • epp (Optional[String]) (defaults to: undef)
  • path (String) (defaults to: "/usr/local/sbin/${title}")
  • service_ensure (Optional[String]) (defaults to: undef)
  • service_enable (Variant[Undef,Boolean,String]) (defaults to: undef)
  • systemd_template (String) (defaults to: 'psick/services/systemd.erb')
  • systemd_after (Optional[String]) (defaults to: 'network.target')
  • systemd_before (Optional[String]) (defaults to: undef)


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'manifests/services/systemd_script.pp', line 6

define psick::services::systemd_script (
  Enum['present','absent'] $ensure = present,
  Optional[String] $source = undef,
  Optional[String] $content = undef,
  Optional[String] $template = undef,
  Optional[String] $epp = undef,
  String $path = "/usr/local/sbin/${title}",
  Optional[String] $service_ensure = undef,
  Variant[Undef,Boolean,String] $service_enable = undef,
  String $systemd_template = 'psick/services/systemd.erb',
  Optional[String] $systemd_after    = 'network.target', # lint:ignore:optional_default
  Optional[String] $systemd_before   = undef,
) {
  $manage_content = tp_content($content, $template, $epp)
  file { $path:
    ensure  => $ensure,
    content => $manage_content,
    source  => $source,
    mode    => '0755',
    owner   => 'root',
    group   => 'root',
  }
  file { "/etc/systemd/system/${title}.service":
    ensure  => $ensure,
    content => template($systemd_template),
    mode    => '0644',
    owner   => 'root',
    group   => 'root',
  }
  if ($service_ensure or $service_enable)
  and $ensure == 'present' {
    service { $title:
      ensure    => $service_ensure,
      enable    => $service_enable,
      subscribe => [File["/etc/systemd/system/${title}.service"],File[$path]],
    }
  }
}