summaryrefslogtreecommitdiff
path: root/share/hydractl
diff options
context:
space:
mode:
Diffstat (limited to 'share/hydractl')
-rwxr-xr-xshare/hydractl/deploy35
1 files changed, 31 insertions, 4 deletions
diff --git a/share/hydractl/deploy b/share/hydractl/deploy
index d61519e..7bedb1e 100755
--- a/share/hydractl/deploy
+++ b/share/hydractl/deploy
@@ -22,9 +22,36 @@ hydra_config_load
# Parameters
MANIFEST="`facter fqdn`.pp"
+FOLDER="$1"
-# Run puppet
-if [ -e "$HYDRA_FOLDER/puppet/manifests/nodes/$MANIFEST" ]; then
- sudo puppet apply --confdir=$HYDRA_FOLDER/puppet \
- --modulepath=$HYDRA_FOLDER/modules $HYDRA_FOLDER/puppet/manifests/nodes/$MANIFEST
+# Set sudo config
+local sudo device rsync
+if [ "`whoami`" != 'root' ]; then
+ sudo="sudo"
+fi
+
+# Dispatch
+if [ ! -z "$FOLDER" ]; then
+ if [ ! -d "$FOLDER"]; then
+ echo "folder not found: $FOLDER"
+ exit 1
+ fi
+
+ echo "Deploying to $FOLDER..."
+
+ # Saner defaults
+ $sudo mkdir -p $FOLDER/etc/puppet
+ $sudo chown -R root. $FOLDER/etc/puppet
+ $sudo chmod -R 640 $FOLDER/etc/puppet
+
+ # Sync repository to server
+ # Exclude eventual keys and version control files
+ $sudo rsync -CrltDv --no-perms --exclude=keys --delete $HYDRA_FOLDER/puppet/ $FOLDER/etc/puppet/
+
+ # Run puppet
+ $sudo chroot $FOLDER puppet apply /etc/puppet/manifests/nodes/$MANIFEST
+elif [ -e "$HYDRA_FOLDER/puppet/manifests/nodes/$MANIFEST" ]; then
+ # Run puppet
+ $sudo puppet apply --confdir=$HYDRA_FOLDER/puppet \
+ --modulepath=$HYDRA_FOLDER/modules $HYDRA_FOLDER/puppet/manifests/nodes/$MANIFEST
fi