Created
September 5, 2014 15:32
-
-
Save rockpapergoat/f89c0e5384578b46d95f to your computer and use it in GitHub Desktop.
puppet defined type + hiera hash data
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define samba::config($includeconf = '', $log_level = '2') { | |
include samba | |
if $::operatingsystemrelease =~ /^6/ { | |
$smb_config='smb.conf_el6.erb' | |
} | |
elsif $::operatingsystemrelease =~ /^5/ { | |
$smb_config='smb.conf_el6.erb' | |
} | |
file { '/etc/samba/smb.conf': | |
content => template("samba/${smb_config}"), | |
owner => root, | |
group => root, | |
mode => '0664', | |
require => Class['samba::install'], | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
smb_config: | |
- one | |
- two | |
- three | |
smb_shares: | |
one: | |
name: one | |
two: | |
name: two | |
three: | |
name: three |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class profile::storage { | |
# more details are omitted above. this is the relevant bit. | |
# add smb_shares hash to hiera for given host | |
# this bit will create the shares | |
$smb_shares = hiera('smb_shares') | |
if ($smb_shares) { | |
$share_names = $smb_shares['name'] | |
unless (is_hash($smb_shares)) { fail("${smb_shares} is not a valid hash")} | |
create_resources('samba::share',$smb_shares) | |
} | |
$smb_config = hiera_array('smb_config') | |
if ($smb_config) { | |
include ::samba | |
unless (is_array($smb_config)) { fail("${smb_config} is not a valid array")} | |
ensure_resource('samba::config',[ ::hostname ], { includeconf => $smb_config}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment