aboutsummaryrefslogtreecommitdiff
path: root/manifests/nas/share.pp
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2013-04-05 15:38:08 -0300
committerSilvio Rhatto <rhatto@riseup.net>2013-04-05 15:38:08 -0300
commitd1013475b2f21ea80a9f8bdb87e43f13bc275204 (patch)
treefe53c1435ee9ea66fb5ed12eae8f4a291e4a5cf8 /manifests/nas/share.pp
parent9025a40e886cf0b4b6187dfedac9badd613842f8 (diff)
downloadpuppet-nodo-d1013475b2f21ea80a9f8bdb87e43f13bc275204.tar.gz
puppet-nodo-d1013475b2f21ea80a9f8bdb87e43f13bc275204.tar.bz2
Adding basic NAS class
Diffstat (limited to 'manifests/nas/share.pp')
-rw-r--r--manifests/nas/share.pp59
1 files changed, 59 insertions, 0 deletions
diff --git a/manifests/nas/share.pp b/manifests/nas/share.pp
new file mode 100644
index 0000000..e29ecbe
--- /dev/null
+++ b/manifests/nas/share.pp
@@ -0,0 +1,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,
+ }
+ }
+}