diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2018-05-24 11:15:53 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2018-05-24 11:15:53 -0300 |
commit | cabfc47ca80492033e3d0eee66e8445119a99d63 (patch) | |
tree | d30961e289697ba5c5eded40485842229548f304 /share | |
parent | 4aba33ed415df51bcb48fe011ba8f2f3e003ec1b (diff) | |
download | hydra-cabfc47ca80492033e3d0eee66e8445119a99d63.tar.gz hydra-cabfc47ca80492033e3d0eee66e8445119a99d63.tar.bz2 |
Compile: add known_hosts aliases with custom ports
Diffstat (limited to 'share')
-rwxr-xr-x | share/hydra/compile | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/share/hydra/compile b/share/hydra/compile index e653e3f..567a78f 100755 --- a/share/hydra/compile +++ b/share/hydra/compile @@ -56,6 +56,45 @@ for node in $NODES; do sshed25519key="$(grep sshed25519key: $FACTS/${node}.yaml | cut -d ':' -f 2 | sed -e 's/ //g' -e 's/"//g')" sshecdsakey="$(grep sshecdsakey: $FACTS/${node}.yaml | cut -d ':' -f 2 | sed -e 's/ //g' -e 's/"//g')" + # Determine host aliases depending on sshd::ports config + host_aliases="" + 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`" + 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" + fi + + if [ ! -z "$role" ]; then + hiera_params="$hiera_params ::nodo::role=$role" + fi + + if [ ! -z "$location" ]; then + hiera_params="$hiera_params ::nodo::location=$location" + fi + + if [ ! -z "$domain" ]; then + hiera_params="$hiera_params ::domain=$domain" + fi + + ssh_ports="`$hiera sshd::ports $hiera_params 2> /dev/null`" + + if [ "$ssh_ports" != "nil" ] && [ ! -z "$ssh_ports" ]; then + ssh_ports="`echo $ssh_ports | sed -e 's/\[//g' -e 's/\]//g' -e 's/,//g'`" + + for port in $ssh_ports; do + if [ -z "$host_aliases" ]; then + host_aliases="'[${node}]:$port'" + else + host_aliases="$host_aliases, '[${node}]:$port'" + fi + done + fi + if [ ! -z "$rsakey" ]; then #echo " $node-rsa:" >> $CONFIG echo " $node:" >> $CONFIG @@ -63,6 +102,10 @@ for node in $NODES; do echo " ensure: 'present'" >> $CONFIG echo " type : 'ssh-rsa'" >> $CONFIG echo " key : '$rsakey'" >> $CONFIG + + if [ ! -z "$host_aliases" ]; then + echo " host_aliases : [ $host_aliases ]" >> $CONFIG + fi fi # See [PUP-6589] Resource Type sshkey doesn't allow the declaration of multiple SSH host keys for one host |