]> gitweb.fluxo.info Git - puppet-nodo.git/commitdiff
Conditionals for nodo::subsystem::nas:share
authorSilvio Rhatto <rhatto@riseup.net>
Sun, 13 Sep 2015 21:49:59 +0000 (18:49 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Sun, 13 Sep 2015 21:49:59 +0000 (18:49 -0300)
manifests/subsystem/nas/share.pp

index 43922b7ef31acfa166f16c68fc328f6b8a554659..aee32f2b57093475dd3d9882a6640f14df31e4d7 100644 (file)
@@ -18,9 +18,12 @@ define nodo::subsystem::nas::share(
   $samba_directory_mask = '0755',
   $manage_folder        = true
 ) {
-
+  #
   # DLNA share
-  if $dlna_type != '' {
+  #
+  $dlna = hiera('nodo::role::nas::dlna', false)
+
+  if $dlna == true and $dlna_type != '' {
     minidlna::share { $folder:
       type => $dlna_type ? {
         'all'   => undef,
@@ -29,61 +32,85 @@ define nodo::subsystem::nas::share(
     }
   }
 
+  #
   # 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,
+  #
+  $samba = hiera('nodo::role::nas::samba', false)
+
+  if $samba == true {
+    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,
+  #
+  $nfs = hiera('nodo::role::nas::nfs', false)
+
+  if $nfs == true {
+    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'],
+  #
+  $http = hiera('nodo::role::nas::http', false)
+
+  if $http == true {
+    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'],
+  #
+  $avahi = hiera('nodo::role::nas::avahi', false)
+
+  if $avahi == true {
+    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