aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2015-10-19 15:00:06 -0200
committerSilvio Rhatto <rhatto@riseup.net>2015-10-19 15:00:06 -0200
commit7b26418c6e5cf39ec3aa7606a6af9e29601c585a (patch)
treeac0a71aa880c0b81ec4d3caa236053e447fc5861 /lib
parent7fe06088632486f1c7f349cc4d43a6aa5ce57ed3 (diff)
downloadhydra-7b26418c6e5cf39ec3aa7606a6af9e29601c585a.tar.gz
hydra-7b26418c6e5cf39ec3aa7606a6af9e29601c585a.tar.bz2
Deploy: change copy files procedure to workaround bash quoting limitations
Diffstat (limited to 'lib')
-rw-r--r--lib/hydra/deploy44
1 files changed, 33 insertions, 11 deletions
diff --git a/lib/hydra/deploy b/lib/hydra/deploy
index 9fdb9e8..5fecafd 100644
--- a/lib/hydra/deploy
+++ b/lib/hydra/deploy
@@ -4,17 +4,20 @@
function hydra_deploy_setup {
# Common parameters
# Exclude eventual keys and version control files
- DEPLOY_RSYNC="rsync -CrltDv --no-perms --exclude=keys --exclude=hiera/secrets --delete"
+ DEPLOY_RSYNC="rsync -CrltDv --no-perms --exclude=ssl --exclude=keys --exclude=hiera/secrets --delete --rsync-path"
+ RSYNC_PATH="rsync"
+ COPY_PATH=""
if [ "$1" == "remote" ]; then
# Deploy in a local folder
if [ ! -z "$2" ]; then
NODE="$2"
DEPLOY_COMMAND="$HYDRA_CONNECT $NODE sudo"
- DEPLOY_RSYNC="$DEPLOY_RSYNC --rsync-path 'sudo rsync' $HYDRA_FOLDER/puppet/ $NODE:/etc/puppet/"
+ RSYNC_PATH="sudo rsync"
+ DEPLOY_OPTS="$HYDRA_FOLDER/puppet/ $NODE:/etc/puppet/"
FQDN="`$DEPLOY_COMMAND facter fqdn`"
DEPLOY_DEST="$FQDN:"
- DEPLOY_COPY="$DEPLOY_RSYNC"
+ COPY_PATH="$RSYNC_PATH"
PUPPET_MANIFEST="/etc/puppet/manifests/nodes/$FQDN.pp"
else
echo "No folder specified."
@@ -25,8 +28,7 @@ function hydra_deploy_setup {
if [ ! -z "$2" ]; then
FOLDER="$2"
DEPLOY_COMMAND="$SUDO chroot $FOLDER"
- DEPLOY_RSYNC="$DEPLOY_RSYNC $HYDRA_FOLDER/puppet/ $FOLDER/etc/puppet/"
- DEPLOY_COPY="$SUDO cp"
+ DEPLOY_OPTS="$HYDRA_FOLDER/puppet/ $FOLDER/etc/puppet/"
DEPLOY_DEST="$FOLDER"
PUPPET_MANIFEST="/etc/puppet/manifests/nodes/$FQDN.pp"
@@ -45,6 +47,7 @@ function hydra_deploy_setup {
fi
else
# Deploy on the localhost
+ DEPLOY_RSYNC=""
DEPLOY_COMMAND="$SUDO"
FQDN="`facter fqdn`"
PUPPET_OPTS="--confdir=$HYDRA_FOLDER/puppet --modulepath=$HYDRA_FOLDER/modules"
@@ -81,23 +84,42 @@ function hydra_deploy_mkdirs {
$DEPLOY_COMMAND chmod -R 640 /etc/puppet
}
-# Create hiera folder structure
-function hydra_hiera_copy {
+# Copy hiera secrets
+function hydra_deploy_copy_secrets {
+ local location="$1"
+
+ if [ -z "$location" ]; then
+ location="remote"
+ fi
+
$DEPLOY_COMMAND mkdir -p $FOLDER/etc/puppet/secrets/{domain,location,node,role}
if [ ! -z "$DOMAIN" ] && [ -e "$HYDRA_FOLDER/puppet/hiera/secrets/domain/$DOMAIN.yaml" ]; then
- $DEPLOY_COPY $HYDRA_FOLDER/puppet/hiera/secrets/domain/$DOMAIN.yaml $DEPLOY_DEST/etc/puppet/hiera/secrets/domain/
+ hydra_deploy_copy $location $HYDRA_FOLDER/puppet/hiera/secrets/domain/$DOMAIN.yaml $DEPLOY_DEST/etc/puppet/hiera/secrets/domain/
fi
if [ ! -z "$LOCATION" ] && [ -e "$HYDRA_FOLDER/puppet/hiera/secrets/location/$LOCATION.yaml" ]; then
- $DEPLOY_COPY $HYDRA_FOLDER/puppet/hiera/secrets/location/$LOCATION.yaml $DEPLOY_DEST/etc/puppet/hiera/secrets/location/
+ hydra_deploy_copy $location $HYDRA_FOLDER/puppet/hiera/secrets/location/$LOCATION.yaml $DEPLOY_DEST/etc/puppet/hiera/secrets/location/
fi
if [ ! -z "$ROLE" ] && [ -e "$HYDRA_FOLDER/puppet/hiera/secrets/role/$ROLE.yaml" ]; then
- $DEPLOY_COPY $HYDRA_FOLDER/puppet/hiera/secrets/role/$ROLE.yaml $DEPLOY_DEST/etc/puppet/hiera/secrets/role/
+ hydra_deploy_copy $location $HYDRA_FOLDER/puppet/hiera/secrets/role/$ROLE.yaml $DEPLOY_DEST/etc/puppet/hiera/secrets/role/
fi
if [ ! -z "$NODE" ] && [ -e "$HYDRA_FOLDER/puppet/hiera/secrets/node/$NODE.yaml" ]; then
- $DEPLOY_COPY $HYDRA_FOLDER/puppet/hiera/secrets/node/$NODE.yaml $DEPLOY_DEST/etc/puppet/hiera/secrets/node/
+ hydra_deploy_copy $location $HYDRA_FOLDER/puppet/hiera/secrets/node/$NODE.yaml $DEPLOY_DEST/etc/puppet/hiera/secrets/node/
+ fi
+}
+
+# Copy a single file
+function hydra_deploy_copy {
+ local location="$1"
+ local orig="$2"
+ local dest="$3"
+
+ if [ "$location" == "folder" ]; then
+ $SUDO cp $orig $dest
+ elif [ "$location" == "remote" ]; then
+ $DEPLOY_RSYNC "$RSYNC_PATH" $orig $dest
fi
}