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
|
# Share a folder pubicly using FTP, Samba, NFS, DLNA, etc.
define share(
$description,
$folder,
$dlna_type = '',
$nfs_export_target = '127.0.0.1',
$nfs_export_options = 'ro,sync,no_subtree_check'
) {
# DLNA share
if $dlna_type != '' {
minidlna::share { $folder:
type => $dlna_type,
}
}
# Samba share
samba::server::share { $name:
comment => $description,
path => $folder,
guest_only => true,
guest_ok => true,
browsable => true,
create_mask => 0777,
directory_mask => 0777,
}
# NFS export
nfs::export { $name:
export_directory => $folder,
export_target => $nfs_export_target,
export_options => $nfs_export_options,
}
# HTTP and FTP symlinks to media assets
file { [ "/var/www/data/${name}", "/home/ftp/${name}" ]:
ensure => $folder,
require => File['/var/www/data', '/home/ftp'],
}
# Avahi service
file { "/etc/avahi/services/nfs-${name}.service":
ensure => present,
owner => root,
group => root,
mode => 0644,
source => "puppet:///modules/site_avahi/services/nfs-${name}.service",
notify => Service['avahi-daemon'],
}
# Make sure basic media exist, no matter which disk is attached
$cache = hiera('nodo::media::folders', '')
if $cache != '' {
file { [ "${cache}/${name}" ]:
ensure => directory,
}
}
}
|