Add systemd module, required by rabbitmq
[mirror/dsa-puppet.git] / 3rdparty / modules / systemd / manifests / dropin_file.pp
1 # Creates a drop-in file for a systemd unit
2 #
3 # @api public
4 #
5 # @see systemd.unit(5)
6 #
7 # @attr name [Pattern['^.+\.conf$']]
8 #   The target unit file to create
9 #
10 #   * Must not contain ``/``
11 #
12 # @attr path
13 #   The main systemd configuration path
14 #
15 # @attr content
16 #   The full content of the unit file
17 #
18 #   * Mutually exclusive with ``$source``
19 #
20 # @attr source
21 #   The ``File`` resource compatible ``source``
22 #
23 #   * Mutually exclusive with ``$content``
24 #
25 # @attr target
26 #   If set, will force the file to be a symlink to the given target
27 #
28 #   * Mutually exclusive with both ``$source`` and ``$content``
29 #
30 define systemd::dropin_file(
31   Systemd::Unit                     $unit,
32   Systemd::Dropin                   $filename = $name,
33   Enum['present', 'absent', 'file'] $ensure   = 'present',
34   Stdlib::Absolutepath              $path     = '/etc/systemd/system',
35   Optional[String]                  $content  = undef,
36   Optional[String]                  $source   = undef,
37   Optional[Stdlib::Absolutepath]    $target   = undef,
38 ) {
39   include systemd
40
41   if $target {
42     $_ensure = 'link'
43   } else {
44     $_ensure = $ensure ? {
45       'present' => 'file',
46       default   => $ensure,
47     }
48   }
49
50   if $ensure != 'absent' {
51     ensure_resource('file', "${path}/${unit}.d", {
52       ensure => directory,
53       owner  => 'root',
54       group  => 'root',
55     })
56   }
57
58   file { "${path}/${unit}.d/${filename}":
59     ensure  => $_ensure,
60     content => $content,
61     source  => $source,
62     target  => $target,
63     owner   => 'root',
64     group   => 'root',
65     mode    => '0444',
66     notify  => Class['systemd::systemctl::daemon_reload'],
67   }
68 }