Revert "Add puppet/archive module"
[mirror/dsa-puppet.git] / 3rdparty / modules / systemd / manifests / tmpfile.pp
1 # Creates a systemd tmpfile
2 #
3 # @api public
4 #
5 # @see systemd-tmpfiles(8)
6 #
7 # @attr name [String]
8 #   The name of the tmpfile to create
9 #
10 #   * May not contain ``/``
11 #
12 # @param $ensure
13 #   Whether to drop a file or remove it
14 #
15 # @param path
16 #   The path to the main systemd tmpfiles directory
17 #
18 # @param content
19 #   The literal content to write to the file
20 #
21 #   * Mutually exclusive with ``$source``
22 #
23 # @param source
24 #   A ``File`` resource compatible ``source``
25 #
26 #  * Mutually exclusive with ``$limits``
27 #
28 define systemd::tmpfile(
29   Enum['present', 'absent', 'file'] $ensure  = 'file',
30   Stdlib::Absolutepath              $path    = '/etc/tmpfiles.d',
31   Optional[String]                  $content = undef,
32   Optional[String]                  $source  = undef,
33 ) {
34   include systemd::tmpfiles
35
36   if $name =~ Pattern['/'] {
37     fail('$name may not contain a forward slash "(/)"')
38   }
39
40   $_tmp_file_ensure = $ensure ? {
41     'present' => 'file',
42     default   => $ensure,
43   }
44
45   file { "${path}/${name}":
46     ensure  => $_tmp_file_ensure,
47     content => $content,
48     source  => $source,
49     owner   => 'root',
50     group   => 'root',
51     mode    => '0444',
52     notify  => Class['systemd::tmpfiles'],
53   }
54 }