# Share a folder pubicly using FTP, Samba, NFS, DLNA, etc. define nodo::nas::share( $description, $folder, $owner = '', $group = '', $mode = '', $dlna_type = '', $nfs_export_target = '127.0.0.1', $nfs_export_options = 'ro,sync,no_subtree_check', $samba_guest_only = true, $samba_guest_ok = true, $samba_guest_account = '', $samba_force_user = '', $samba_force_group = '', $samba_read_only = '', $samba_writable = '', $samba_create_mask = '0644', $samba_directory_mask = '0755', $manage_folder = true ) { # DLNA share if $dlna_type != '' { minidlna::share { $folder: type => $dlna_type ? { 'all' => undef, default => $dlna_type, }, } } # Samba share samba::server::share { $name: comment => $description, path => $folder, guest_only => $samba_guest_only, guest_ok => $samba_guest_ok, guest_account => $samba_guest_account, force_user => $samba_force_user ? { '' => undef, default => $samba_force_user, }, force_group => $samba_force_group ? { '' => undef, default => $samba_force_group, }, read_only => $samba_read_only ? { '' => undef, default => $samba_read_only, }, writable => $samba_writable ? { '' => undef, default => $samba_writable, }, create_mask => $samba_create_mask ? { '' => undef, default => $samba_create_mask, }, directory_mask => $samba_directory_mask ? { '' => undef, default => $samba_directory_mask, }, browsable => true, } # 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::subsystem::media::folders::base', '/var/cache/media') if $cache != '' and $manage_folder != false { file { [ "${cache}/${name}" ]: ensure => directory, owner => $owner ? { '' => undef, default => $owner, }, group => $group ? { '' => undef, default => $group, }, mode => $mode ? { '' => undef, default => $mode, }, } } }