aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2020-06-18 15:19:32 -0300
committerSilvio Rhatto <rhatto@riseup.net>2020-06-18 15:19:32 -0300
commit214b919659d3a1cd606308ba52ace5c6380b6df8 (patch)
treebf762fa94fbb524b64a0fffb9a272bf388ea78ba /lib
parent7374858737554f60b03e8235010391b4f8c10df3 (diff)
downloadhydra-214b919659d3a1cd606308ba52ace5c6380b6df8.tar.gz
hydra-214b919659d3a1cd606308ba52ace5c6380b6df8.tar.bz2
Update hydra_hiera_query to version 5
Diffstat (limited to 'lib')
-rw-r--r--lib/hydra/misc52
1 files changed, 43 insertions, 9 deletions
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
}