aboutsummaryrefslogtreecommitdiff
path: root/share/hydra/deploy
diff options
context:
space:
mode:
Diffstat (limited to 'share/hydra/deploy')
-rwxr-xr-xshare/hydra/deploy20
1 files changed, 18 insertions, 2 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 <<EOF
##### BEGIN REMOTE SCRIPT #####
sudo chown -R root. /etc/puppet
sudo chmod -R 640 /etc/puppet
- sudo puppet apply /etc/puppet/manifests/nodes/\$(facter fqdn).pp
+ LC_ALL=C FACTER_role=$ROLE FACTER_location=$LOCATION \
+ sudo puppet apply /etc/puppet/manifests/nodes/$FQDN.pp
##### END REMOTE SCRIPT #######
EOF
done