Quantcast
Channel: Java mon amour
Viewing all articles
Browse latest Browse all 1124

Puppet: mount a SAMBA share at boot

$
0
0
First, create a credentials file in your acme module:
acme\files\samba\myshare.smb.credentials
and inside put:

username=myuser
password=mypassword

I was unable to make it mount an unprotected share..... so just have it protected by username/password.

Then in your acme init.pp read a boolean

$acme_install_sambamyshare = any2bool(hiera('acme_install_sambamyshare', false)),

Create a samba.pp class (file):


# == Class: acme::samba
#
# Manages samba mounts
#
class acme::samba {
if $acme::acme_install_sambamyshare {
file { '/data/myshare/':
ensure => directory,
owner =>"soa",
group =>'soa',
mode =>'0775',
}

file { '/etc/myshare.smb.credentials': source =>'puppet:///modules/acme/samba/myshare.smb.credentials',
owner => root,
mode =>'0700', } ->
mount { 'myshare':
name =>'/data/myshare/',
atboot =>'true',
device =>'//windowshost/sharedfolder',
ensure =>'mounted',
fstype =>'cifs',
options =>"credentials=/etc/myshare.smb.credentials,rw,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777",
require => [Package['samba-client'], File['/data/myshare/'], File['/etc/myshare.smb.credentials']],
}
}

}



Don't forget to declare the samba class in your init.pp!

If you do cat /etc/fstab you should see something like this:

//windowshost/sharedfolder /data/myshare/ cifs credentials=/etc/myshare.smb.credentials,rw,nounix,iocharset=utf8,file_mode=0777,dir_mode=0777 0 0

See also here

Viewing all articles
Browse latest Browse all 1124

Trending Articles