From 2e651d6756810651c654a0e5ced7ebfdde93d0f0 Mon Sep 17 00:00:00 2001 From: Tollef Fog Heen Date: Fri, 2 Feb 2018 07:42:38 +0100 Subject: [PATCH] Refactor hiera lookup for security mirrors slightly Since the structure is a list of hashes (for vaguely historical reasons), we need to unpack the result from hiera before doing the filtering and selection of the backends. --- modules/roles/manifests/security_mirror.pp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/roles/manifests/security_mirror.pp b/modules/roles/manifests/security_mirror.pp index 9122ea282..472a1458e 100644 --- a/modules/roles/manifests/security_mirror.pp +++ b/modules/roles/manifests/security_mirror.pp @@ -36,12 +36,12 @@ class roles::security_mirror { content => template('roles/security_mirror/security.debian.org.erb') } - $mirrors = hiera_hash('roles::security_mirror',[]) - notify { "Mirrors: ${mirrors}": } - $fastly_mirrors = $mirrors.filter |$h| { $h[1]['fastly-backend'] } - notify { "Fastly Mirrors: ${fastly_mirrors}": } - $hosts_to_check = $fastly_mirrors.map |$h| { $h[1]['service-hostname'] } - notify {" Actual hosts to check Mirrors: ${hosts_to_check}": } + # roles is a list of hashes, which needs to be unpacked into a regular hash + $mirrors = hiera('roles.security_mirror', []) + # unpack $mirrors and construct a hash + $m2 = Hash($mirrors.map |$h| { $h.map |$k, $v| { [$k, $v] }[0]}) + $fastly_mirrors = $m2.filter |$h| { $h[1]['fastly-backend'] } + $hosts_to_check = $fastly_mirrors.map |$h| { $h[1]['service-hostname'] } roles::mirror_health { 'security': check_hosts => $hosts_to_check, -- 2.20.1