I have this structure in my hiera file that create some rules in my smb.conf.
samba::shares:
PDF:
- comment = "PDF"
- path = /home/smb/pdf
- browseable = yes
- hide dot files = yes
- read only = no
- public = yes
- writable = yes
- create mode = 0775
- printable = no
Partage:
- comment= "Partage"
- path = /home/smb/Partage
- browseable = yes
- hide dot files = yes
- read only = no
- public = yes
- writable = yes
- create mode = 0775
- printable = no
I want to access the path of each share for create automatically the folder with the right persmissions.
I tried many solutions with hiera_hash() but I can not find the right setting. :
define create_folder{
# I want to loop on PDF, Partage, etc. and extract path
# for each one (/home/smb/pdf, /home/smb/Partage, etc.).
$path = hiera_hash('path')
file{"$path":
path => $path,
ensure => diretory,
owner => "smb",
group => "smb",
require => File["/home/smb/"],
mode => '775',
}
}
Can you help me please ?
Regards.
This is an application for the
create_resources
method.In your case, you would not fetch the hash from inside the resource, but from outside:
The 2nd argument to
hiera_hash
is a default value. I prefer to always keep an empty Hash there in order to be able to load the resource on all machines, even if only certain machines have the values defined.Finally, I add one script who's run everty time puppet run :
Regards.