Skip to content
This repository has been archived by the owner on May 22, 2018. It is now read-only.

Commit

Permalink
Merge pull request #135 from blackjid/merge_hierarchy
Browse files Browse the repository at this point in the history
Adds option to merge data from hiera hierarchical data sources
  • Loading branch information
rafaelfranca committed May 29, 2015
2 parents eb5d450 + f6fa705 commit 2a6a71f
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 8 deletions.
1 change: 1 addition & 0 deletions data/common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ boxen::config::srcdir: "%{::boxen_srcdir}"
boxen::config::login: "%{::github_login}"
boxen::config::repo_url_template: "%{::boxen_repo_url_template}"
boxen::config::download_url_base: "%{::boxen_download_url_base}"
boxen::config::hiera_merge_hierarchy: false
1 change: 1 addition & 0 deletions manifests/config.pp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
$login = undef,
$repo_url_template = undef,
$download_url_base = undef,
$hiera_merge_hierarchy = undef
) {
validate_string(
$home,
Expand Down
45 changes: 37 additions & 8 deletions manifests/personal.pp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

$manifests = "${boxen::config::repodir}/modules/people/manifests"
$login = regsubst($boxen::config::login, '-','_', 'G')
$merge_hierarchy = $boxen::config::hiera_merge_hierarchy

if $login != $boxen::config::login {
notice("Changed boxen::personal login to ${login}")
Expand All @@ -40,19 +41,39 @@
# If $projects looks like ['foo', 'bar'], behaves like:
# include projects::foo
# include projects::bar
$project_classes = prefix($projects, 'projects::')
$_projects = $merge_hierarchy ? {
true => hiera_array("${name}::projects",[]),
default => $projects
}
$project_classes = prefix($_projects, 'projects::')
ensure_resource('class', $project_classes)

# If $includes looks like ['foo', 'bar'], behaves like:
# class { 'foo': }
# class { 'bar': }
ensure_resource('class', $includes)
$_includes = $merge_hierarchy ? {
true => hiera_array("${name}::includes",undef),
default => $includes
}
ensure_resource('class', $_includes)

# $casks and $osx_apps are synonyms. $osx_apps takes precedence
$_casks = $osx_apps ? {
undef => $casks,
default => $osx_apps
if $merge_hierarchy {
$merged_osx_apps = hiera_array("${name}::osx_apps",undef)
$merged_casks = hiera_array("${name}::casks",undef)

$_casks = $merged_osx_apps ? {
undef => $merged_casks,
default => $merged_osx_apps
}
}
else {
# $casks and $osx_apps are synonyms. $osx_apps takes precedence
$_casks = $osx_apps ? {
undef => $casks,
default => $osx_apps
}
}

# If any casks/osx_apps are specified, declare them as brewcask packages
if count($_casks) > 0 { include brewcask }
ensure_resource('package', $_casks, {
Expand All @@ -62,7 +83,11 @@
})

# If any homebrew packages are specified , declare them
ensure_resource('package', $homebrew_packages, {
$_homebrew_packages = $merge_hierarchy ? {
true => hiera_array("${name}::homebrew_packages",undef),
default => $homebrew_packages
}
ensure_resource('package', $_homebrew_packages, {
'provider' => 'homebrew',
})

Expand All @@ -77,5 +102,9 @@
# }
#
# Multiple projects may be specified in the $custom_projects hash.
create_resources(boxen::project, $custom_projects)
$_custom_projects = $merge_hierarchy ? {
true => hiera_array("${name}::custom_projects",{}),
default => $custom_projects
}
create_resources(boxen::project, $_custom_projects)
}

0 comments on commit 2a6a71f

Please sign in to comment.