Defined Type: asterisk::dotd::file

Defined in:
manifests/dotd/file.pp

Summary

Create a file inside a .d directory and set its permissions correctly.

Overview

This defined type is not intended to be used directly.

Parameters:

  • dotd_dir (String)

    Path of the .d directory, relative to asterisk's configuration directory, in which the file should be created.

  • ensure (Enum['present', 'absent']) (defaults to: present)

    Set to absent to remove the file

  • source (Optional[Stdlib::Filesource]) (defaults to: undef)

    Puppet file source where the contents can be found.

  • content (Optional[String]) (defaults to: undef)

    Textual contents of the file. This option is mutually exclusive with $source.

  • filename (String) (defaults to: $name)

    Can be used to override the name of the file created. Otherwise, $name is used as the file name.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'manifests/dotd/file.pp', line 21

define asterisk::dotd::file (
  String                       $dotd_dir,
  Enum['present', 'absent']    $ensure   = present,
  Optional[String]             $content  = undef,
  Optional[Stdlib::Filesource] $source   = undef,
  String                       $filename = $name,
) {
  assert_private()

  include asterisk::config
  include asterisk::service

  $nb_set = count([$content, $source])
  if $nb_set == 0 {
    fail('One of $content or $source need to be defined, none were set')
  }
  if $nb_set == 2 {
    fail('Please provide either a $source or a $content, but not both.')
  }

  file { "/etc/asterisk/${dotd_dir}/${filename}":
    ensure  => $ensure,
    owner   => 'root',
    group   => 'asterisk',
    mode    => '0640',
    require => Class['asterisk::config'],
    notify  => Class['asterisk::service'],
  }

  if $content =~ String {
    File["/etc/asterisk/${dotd_dir}/${filename}"] {
      content => $content,
    }
  } else {
    File["/etc/asterisk/${dotd_dir}/${filename}"] {
      source => $source,
    }
  }
}