From 214b919659d3a1cd606308ba52ace5c6380b6df8 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Thu, 18 Jun 2020 15:19:32 -0300 Subject: Update hydra_hiera_query to version 5 --- lib/hydra/misc | 52 +++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 43 insertions(+), 9 deletions(-) (limited to 'lib') diff --git a/lib/hydra/misc b/lib/hydra/misc index 03dfd6b..75edf19 100644 --- a/lib/hydra/misc +++ b/lib/hydra/misc @@ -167,29 +167,63 @@ function hydra_hiera_query { local param="$2" # Build basic query command + # Hiera 3 version # There might be weird hiera errors, so that's why we're doing a "2> /dev/null" redirection - hiera="hiera --config $HYDRA_FOLDER/puppet/hiera.yaml" - hiera_params="settings::confdir=$HYDRA_FOLDER/puppet ::clientcert=$node" - role="`$hiera nodo::role $hiera_params 2> /dev/null`" - location="`$hiera nodo::location $hiera_params 2> /dev/null`" + #lookup="hiera --config $HYDRA_FOLDER/puppet/hiera.yaml" + #lookup_params="settings::confdir=$HYDRA_FOLDER/puppet ::clientcert=$node" + + # Build basic query command + # Hiera 5 version + lookup="puppet lookup --confdir $HYDRA_FOLDER/puppet/ --node $node nodo --render-as s" + + # Hiera 3 + #role="`$lookup $nodo::role $lookup_params 2> /dev/null`" + #location="`$lookup nodo::location $lookup_params 2> /dev/null`" + + # Hiera 5 + role="`$lookup $nodo::role 2> /dev/null`" + location="`$lookup nodo::location 2> /dev/null`" + + #role="$(grep "^nodo::role: " $FACTS/${node}.yaml | cut -d ':' -f 2 | sed -e 's/ //g' -e 's/"//g')" + #location="$(grep "^nodo::location: " $FACTS/${node}.yaml | cut -d ':' -f 2 | sed -e 's/ //g' -e 's/"//g')" virtual="$(grep "^virtual: " $FACTS/${node}.yaml | cut -d ':' -f 2 | sed -e 's/ //g' -e 's/"//g')" domain="$(grep "^domain: " $FACTS/${node}.yaml | cut -d ':' -f 2 | sed -e 's/ //g' -e 's/"//g')" if [ ! -z "$virtual" ]; then - hiera_params="$hiera_params ::virtual=$virtual" + # Hiera 3 + #lookup_params="$lookup_params ::virtual=$virtual" + + # Hiera 5 + export FACTER_virtual="$virtual" fi if [ ! -z "$role" ]; then - hiera_params="$hiera_params ::nodo::role=$role" + # Hiera 3 + #lookup_params="$lookup_params ::nodo::role=$role" + + # Hiera 5 + export FACTER_role="$role" fi if [ ! -z "$location" ]; then - hiera_params="$hiera_params ::nodo::location=$location" + # Hiera 3 + #lookup_params="$lookup_params ::nodo::location=$location" + + # Hiera 5 + export FACTER_location="$location" fi if [ ! -z "$domain" ]; then - hiera_params="$hiera_params ::domain=$domain" + # Hiera 3 + #lookup_params="$lookup_params ::domain=$domain" + + # Hiera 5 + export FACTER_domain="$domain" fi - $hiera $param $hiera_params 2> /dev/null + # Hiera 3 + #$lookup $param $lookup_params 2> /dev/null + + # Hiera 5 + $lookup $param 2> /dev/null } -- cgit v1.2.3