From d33c4fa00732dc024dc7f28a986891507c544e3f Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Fri, 25 Sep 2015 20:24:03 -0300 Subject: Deploy: custom facts and YAML --- share/hydra/deploy | 20 ++++++++++++++++++-- share/hydractl/deploy | 42 ++++++++++++++++++++++++++++++++++++------ 2 files changed, 54 insertions(+), 8 deletions(-) diff --git a/share/hydra/deploy b/share/hydra/deploy index 3705a9e..6b91480 100755 --- a/share/hydra/deploy +++ b/share/hydra/deploy @@ -39,14 +39,30 @@ for node in $NODES; do # Sync repository to server # Exclude eventual keys and version control files - rsync -CrltDv --no-perms --exclude=keys --delete --rsync-path "sudo rsync" $HYDRA_FOLDER/puppet/ $node:/etc/puppet/ + rsync -CrltDv --no-perms --exclude=keys --exclude=hiera --delete --rsync-path "sudo rsync" $HYDRA_FOLDER/puppet/ $node:/etc/puppet/ + + # Setup custom facts + FQDN="`$HYDRA_CONNECT $node facter fqdn`" + DOMAIN="`echo $FQDN | cut -d . -f 2-`" + ROLE="`grep "^nodo::role: " domain/$DOMAIN/$FQDN.yaml | cut -d ' ' -f 2 | sed -e "s/'//g" -e 's/"//g'`" + LOCATION="`grep "^nodo::location: " domain/$DOMAIN/$FQDN.yaml | cut -d ' ' -f 2 | sed -e "s/'//g" -e 's/"//g'`" + + # Check for manifest + if [ ! -e "$HYDRA_FOLDER/puppet/manifests/nodes/$FQDN.pp" ]; then + echo "Not found: $HYDRA_FOLDER/puppet/manifests/nodes/$FQDN.pp" + exit 1 + fi + + # Copy needed hiera YAMLs + # TODO # Run puppet $HYDRA_CONNECT $node <