diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2020-06-18 15:19:32 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2020-06-18 15:19:32 -0300 |
commit | 214b919659d3a1cd606308ba52ace5c6380b6df8 (patch) | |
tree | bf762fa94fbb524b64a0fffb9a272bf388ea78ba | |
parent | 7374858737554f60b03e8235010391b4f8c10df3 (diff) | |
download | hydra-214b919659d3a1cd606308ba52ace5c6380b6df8.tar.gz hydra-214b919659d3a1cd606308ba52ace5c6380b6df8.tar.bz2 |
Update hydra_hiera_query to version 5
-rw-r--r-- | lib/hydra/misc | 52 | ||||
-rwxr-xr-x | share/hydra/compile | 5 |
2 files changed, 47 insertions, 10 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 } diff --git a/share/hydra/compile b/share/hydra/compile index 14dd68c..8734f81 100755 --- a/share/hydra/compile +++ b/share/hydra/compile @@ -73,13 +73,16 @@ echo "sshkeys:" >> $CONFIG for node in $NODES; do if [ -e "$FACTS/${node}.yaml" ]; then + echo "Processing $node..." + + # Get key info rsakey="`hydractl_get_yaml_ssh_key $FACTS/${node}.yaml rsa`" sshed25519key="`hydractl_get_yaml_ssh_key $FACTS/${node}.yaml ed25519`" sshecdsakey="`hydractl_get_yaml_ssh_key $FACTS/${node}.yaml ecdsa`" + # SSH ports host_aliases="" ssh_ports="`hydra_hiera_query $node sshd::ports`" - echo $ssh_ports if [ "$ssh_ports" != "nil" ] && [ ! -z "$ssh_ports" ]; then ssh_ports="`echo $ssh_ports | sed -e 's/\[//g' -e 's/\]//g' -e 's/,//g'`" |