#!/bin/bash # # Create keys for new nodes. # function hydra_newkeys { # Generates ssh and gpg keys for new nodes # GPG keys should be manually imported in the nodes for host in `hydra $HYDRA nodes`; do node="`echo $host | cut -d . -f 1`" privkey="$PUPPET_KEYS/"$node"_id_rsa" pubkey="$privkey.pub" if [ "$1" == "all" ]; then hydra_genpairs elif [ ! -e "$privkey" ] || [ ! -e "$pubkey" ]; then hydra_genpairs fi done } function hydra_genpairs { keyringer $HYDRA genpair ssh $node/ssh/id_rsa $host $privkey keyringer $HYDRA genpair gpg $node/gpg/key $host # Add key into puppet git repository. ( cd $PUPPET_KEYS && git add $(basename $privkey) $(basename $pubkey) ) } # Load. source $APP_BASE/lib/hydra/functions || exit 1 hydra_config_load # Check for keyringer. if ! which keyringer &> /dev/null; then echo "Error: please install keyringer." exit 1 fi hydra_newkeys $*