aboutsummaryrefslogtreecommitdiff
path: root/manifests/file.pp
blob: 48a5fabf5d15afbd63f78ecb8acd05839b27b4cb (plain)
1
2
3
4
5
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# Define: tftp::file
#
# Parameters:
#
#   [*ensure*]: file type, default file.
#   [*owner*]: file owner, default tftp.
#   [*group*]: file group. default tftp.
#   [*mode*]: file mode, default 0644 (puppet will change to 0755 for directories).
#   [*content*]: file content.
#   [*source*]: file source, defaults to puppet*]:///module/${caller_module_name}/${name} for files without content.
#   [*recurse*]: directory recurse, default false.
#   [*purge*]: directory recurse and purge.
#   [*replace*]: replace directory with file or symlink, default undef,
#   [*recurselimit*]: directory recurse limit, default undef,
#
# Actions:
#
#   Deploy files into the tftp directory.
#
# Usage:
#
#   tftp::file { 'pxelinux.0':
#     source => 'puppet:///modules/acme/pxelinux.0',
#   }
#
#   tftp::file { 'pxelinux.cfg':
#     ensure => directory,
#   }
#
define tftp::file (
  $ensure       = file,
  $owner        = undef,
  $group        = undef,
  $mode         = '0644',
  $recurse      = false,
  $purge        = undef,
  $replace      = undef,
  $recurselimit = undef,
  $content      = undef,
  $source       = undef
) {
  include 'tftp'
  include 'tftp::params'

  if $owner {
    $tftp_owner = $owner
  } else {
    $tftp_owner = $tftp::params::username
  }

  if $group {
    $tftp_group = $group
  } else {
    $tftp_group = $tftp::params::username
  }

  if $source {
    $source_real = $source
  } elsif $ensure != 'directory' and ! $content {
    if $caller_module_name {
      $mod = $caller_module_name
    } else {
      $mod = $module_name
    }
    $source_real = "puppet:///modules/${mod}/${name}"
  }

  file { "${tftp::directory}/${name}":
    ensure       => $ensure,
    owner        => $tftp_owner,
    group        => $tftp_group,
    mode         => $mode,
    recurse      => $recurse,
    purge        => $purge,
    replace      => $replace,
    recurselimit => $recurselimit,
    content      => $content,
    source       => $source_real,
    require      => Class['tftp'],
  }
}