Skip to content

Commit

Permalink
Use hiera lookup function with feature toggle to merge resource hashes.
Browse files Browse the repository at this point in the history
Addresses Issue voxpupuli#614 (voxpupuli#614).
  • Loading branch information
archii committed Aug 25, 2017
1 parent 8866297 commit d701a8b
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
### END Service Configuration ###

### START Hiera Lookups ###
$hiera_merge = false,
$geo_mappings = {},
$string_mappings = {},
$nginx_locations = {},
Expand All @@ -171,11 +172,23 @@
contain '::nginx::config'
contain '::nginx::service'

create_resources('nginx::resource::upstream', $nginx_upstreams)
create_resources('nginx::resource::server', $nginx_servers, $nginx_servers_defaults)
create_resources('nginx::resource::location', $nginx_locations, $nginx_locations_defaults)
if $hiera_merge {
$merged_nginx_upstreams = lookup('nginx::nginx_upstreams', Hash, 'hash')
$merged_nginx_servers = lookup('nginx::nginx_servers', Hash, 'hash')
$merged_nginx_locations = lookup('nginx::nginx_locations', Hash, 'hash')
$merged_nginx_streamhosts = lookup('nginx::nginx_streamhosts', Hash, 'hash')
create_resources('nginx::resource::upstream', $merged_nginx_upstreams, $nginx_servers_defaults)
create_resources('nginx::resource::server', $merged_nginx_servers, $nginx_servers_defaults)
create_resources('nginx::resource::location', $merged_nginx_locations, $nginx_servers_defaults)
create_resources('nginx::resource::streamhost', $merged_nginx_streamhosts)
} else {
create_resources('nginx::resource::upstream', $nginx_upstreams)
create_resources('nginx::resource::server', $nginx_servers, $nginx_servers_defaults)
create_resources('nginx::resource::location', $nginx_locations, $nginx_locations_defaults)
create_resources('nginx::resource::streamhost', $nginx_streamhosts)
}

create_resources('nginx::resource::mailhost', $nginx_mailhosts, $nginx_mailhosts_defaults)
create_resources('nginx::resource::streamhost', $nginx_streamhosts)
create_resources('nginx::resource::map', $string_mappings)
create_resources('nginx::resource::geo', $geo_mappings)

Expand Down

0 comments on commit d701a8b

Please sign in to comment.