summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/hydra/deploy44
-rwxr-xr-xshare/hydra/deploy4
-rwxr-xr-xshare/hydractl/deploy6
3 files changed, 38 insertions, 16 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
}
diff --git a/share/hydra/deploy b/share/hydra/deploy
index 4be5392..d7d4d95 100755
--- a/share/hydra/deploy
+++ b/share/hydra/deploy
@@ -37,10 +37,10 @@ for node in $NODES; do
hydra_deploy_mkdirs
# Sync repository to server
- $DEPLOY_RSYNC
+ $DEPLOY_RSYNC "$RSYNC_PATH" $DEPLOY_OPTS
# Copy hiera configuration
- hydra_hiera_copy
+ hydra_deploy_copy_secrets remote
# Check if puppet is installed
$HYDRA_CONNECT $node <<EOF
diff --git a/share/hydractl/deploy b/share/hydractl/deploy
index 6f9de7c..a500a6e 100755
--- a/share/hydractl/deploy
+++ b/share/hydractl/deploy
@@ -28,14 +28,14 @@ if [ ! -z "$FOLDER" ]; then
echo "Deploying to $FOLDER..."
# Setup deploy environment
- hydra_deploy_setup remote $node
+ hydra_deploy_setup folder $FOLDER
hydra_deploy_mkdirs
# Sync repository to server
- $DEPLOY_RSYNC
+ $DEPLOY_RSYNC "$RSYNC_PATH" $DEPLOY_OPTS
# Copy hiera configuration
- hydra_hiera_copy
+ hydra_deploy_copy_secrets folder
# Check if puppet is installed
if [ ! -e "$FOLDER/usr/bin/puppet" ]; then