aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2016-06-24 13:12:15 -0300
committerSilvio Rhatto <rhatto@riseup.net>2016-06-24 13:12:15 -0300
commitc3f5e9fbb489be5f7695b36380637d0b2349a12a (patch)
treea7298a384d69eeb41adec647908d1c2f266ba1fa /lib
parente30a586d269c3f1b90d04b5c73d0a3407bf22291 (diff)
downloadhydra-c3f5e9fbb489be5f7695b36380637d0b2349a12a.tar.gz
hydra-c3f5e9fbb489be5f7695b36380637d0b2349a12a.tar.bz2
Deploy: do not globally abort on failures to apply in a node
Diffstat (limited to 'lib')
-rw-r--r--lib/hydra/deploy62
1 files changed, 43 insertions, 19 deletions
diff --git a/lib/hydra/deploy b/lib/hydra/deploy
index 84e31a2..96dd67b 100644
--- a/lib/hydra/deploy
+++ b/lib/hydra/deploy
@@ -27,7 +27,7 @@ function hydra_deploy_setup {
# Check for config/node name
if [ "$FQDN" == ".yaml" ]; then
echo "Cannot find config for $NODE."
- exit 1
+ return 1
fi
DEPLOY_BASE="/etc"
@@ -36,10 +36,10 @@ function hydra_deploy_setup {
DEPLOY_DEST="$FQDN:"
RSYNC_PATH="sudo rsync -q"
REMOTE_ENV="LC_ALL=C"
- hydra_deploy_set_manifest
+ hydra_deploy_set_manifest || return 1
else
echo "No folder specified."
- exit 1
+ return 1
fi
elif [ "$1" == "folder" ]; then
# Deploy in a local folder
@@ -56,15 +56,15 @@ function hydra_deploy_setup {
FQDN="`cat $FOLDER/etc/hostname`"
fi
- hydra_deploy_set_manifest
+ hydra_deploy_set_manifest || return 1
if [ ! -d "$FOLDER" ]; then
echo "folder not found: $FOLDER"
- exit 1
+ return 1
fi
else
echo "No node specified."
- exit 1
+ return 1
fi
else
# Deploy on the localhost
@@ -73,7 +73,7 @@ function hydra_deploy_setup {
DEPLOY_RSYNC=""
FQDN="`cat /etc/hostname`"
PUPPET_OPTS="--confdir=$HYDRA_FOLDER/puppet --modulepath=$HYDRA_FOLDER/puppet/modules"
- hydra_deploy_set_manifest $HYDRA_FOLDER
+ hydra_deploy_set_manifest $HYDRA_FOLDER || return 1
# Remove old eyaml symlinks if exists
if [ -h "$HYDRA_FOLDER/puppet/keys/private_key.pkcs7.pem" ]; then
@@ -118,7 +118,7 @@ function hydra_deploy_set_manifest {
PUPPET_MANIFEST="$prefix/puppet/manifests/nodes/default.pp"
else
echo "no manifest found for $FQDN"
- exit 1
+ return 1
fi
}
@@ -151,18 +151,30 @@ function hydra_deploy_copy_keys {
# Test for multi-keys setup
if [ -e "$HYDRA_FOLDER/puppet/keys/$FQDN/eyaml/private_key.pkcs7.pem" ]; then
- hydra_deploy_copy $location $HYDRA_FOLDER/puppet/keys/$FQDN/eyaml/private_key.pkcs7.pem $DEPLOY_DEST/etc/puppet/keys/private_key.pkcs7.pem
+ hydra_deploy_copy $location \
+ $HYDRA_FOLDER/puppet/keys/$FQDN/eyaml/private_key.pkcs7.pem \
+ $DEPLOY_DEST/etc/puppet/keys/private_key.pkcs7.pem \
+ || return 1
# Then try single-key setup
elif [ -e "$HYDRA_FOLDER/puppet/keys/private_key.pkcs7.pem" ]; then
- hydra_deploy_copy $location $HYDRA_FOLDER/puppet/keys/private_key.pkcs7.pem $DEPLOY_DEST/etc/puppet/keys/private_key.pkcs7.pem
+ hydra_deploy_copy $location \
+ $HYDRA_FOLDER/puppet/keys/private_key.pkcs7.pem \
+ $DEPLOY_DEST/etc/puppet/keys/private_key.pkcs7.pem \
+ || return 1
fi
# Test for multi-keys setup
if [ -e "$HYDRA_FOLDER/puppet/keys/$FQDN/eyaml/public_key.pkcs7.pem" ]; then
- hydra_deploy_copy $location $HYDRA_FOLDER/puppet/keys/$FQDN/eyaml/public_key.pkcs7.pem $DEPLOY_DEST/etc/puppet/keys/public_key.pkcs7.pem
+ hydra_deploy_copy $location \
+ $HYDRA_FOLDER/puppet/keys/$FQDN/eyaml/public_key.pkcs7.pem \
+ $DEPLOY_DEST/etc/puppet/keys/public_key.pkcs7.pem \
+ || return 1
# Then try single-key setup
elif [ -e "$HYDRA_FOLDER/puppet/keys/public_key.pkcs7.pem" ]; then
- hydra_deploy_copy $location $HYDRA_FOLDER/puppet/keys/public_key.pkcs7.pem $DEPLOY_DEST/etc/puppet/keys/public_key.pkcs7.pem
+ hydra_deploy_copy $location \
+ $HYDRA_FOLDER/puppet/keys/public_key.pkcs7.pem \
+ $DEPLOY_DEST/etc/puppet/keys/public_key.pkcs7.pem \
+ || return 1
fi
}
@@ -174,22 +186,34 @@ function hydra_deploy_copy_secrets {
location="remote"
fi
- $DEPLOY_COMMAND mkdir -p $FOLDER/etc/puppet/config/secrets/{domain,location,node,role}
+ $DEPLOY_COMMAND mkdir -p $FOLDER/etc/puppet/config/secrets/{domain,location,node,role} || return 1
if [ ! -z "$DOMAIN" ] && [ -e "$HYDRA_FOLDER/puppet/config/secrets/domain/$DOMAIN.yaml" ]; then
- hydra_deploy_copy $location $HYDRA_FOLDER/puppet/config/secrets/domain/$DOMAIN.yaml $DEPLOY_DEST/etc/puppet/config/secrets/domain/
+ hydra_deploy_copy $location \
+ $HYDRA_FOLDER/puppet/config/secrets/domain/$DOMAIN.yaml \
+ $DEPLOY_DEST/etc/puppet/config/secrets/domain/ \
+ || return 1
fi
if [ ! -z "$LOCATION" ] && [ -e "$HYDRA_FOLDER/puppet/config/secrets/location/$LOCATION.yaml" ]; then
- hydra_deploy_copy $location $HYDRA_FOLDER/puppet/config/secrets/location/$LOCATION.yaml $DEPLOY_DEST/etc/puppet/config/secrets/location/
+ hydra_deploy_copy $location \
+ $HYDRA_FOLDER/puppet/config/secrets/location/$LOCATION.yaml \
+ $DEPLOY_DEST/etc/puppet/config/secrets/location/ \
+ || return 1
fi
if [ ! -z "$ROLE" ] && [ -e "$HYDRA_FOLDER/puppet/config/secrets/role/$ROLE.yaml" ]; then
- hydra_deploy_copy $location $HYDRA_FOLDER/puppet/config/secrets/role/$ROLE.yaml $DEPLOY_DEST/etc/puppet/config/secrets/role/
+ hydra_deploy_copy $location \
+ $HYDRA_FOLDER/puppet/config/secrets/role/$ROLE.yaml \
+ $DEPLOY_DEST/etc/puppet/config/secrets/role/ \
+ || return 1
fi
if [ ! -z "$FQDN" ] && [ -e "$HYDRA_FOLDER/puppet/config/secrets/node/$FQDN.yaml" ]; then
- hydra_deploy_copy $location $HYDRA_FOLDER/puppet/config/secrets/node/$FQDN.yaml $DEPLOY_DEST/etc/puppet/config/secrets/node/
+ hydra_deploy_copy $location \
+ $HYDRA_FOLDER/puppet/config/secrets/node/$FQDN.yaml \
+ $DEPLOY_DEST/etc/puppet/config/secrets/node/ \
+ || return 1
fi
}
@@ -208,7 +232,7 @@ function hydra_deploy_copy {
# Check result
if [ "$?" != "0" ]; then
echo "Error copying data to $FQDN."
- exit 1
+ return 1
fi
fi
}
@@ -225,7 +249,7 @@ function hydra_deploy_facts_collect {
# Check result
if [ "$?" != "0" ]; then
echo "Error retrieving facts from $FQDN."
- exit 1
+ return 1
fi
fi
}