aboutsummaryrefslogtreecommitdiff
path: root/share/hydractl
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2015-09-26 09:33:07 -0300
committerSilvio Rhatto <rhatto@riseup.net>2015-09-26 09:33:07 -0300
commitf5ddf7507d440bf3642777d159a0a60ff55d0c5b (patch)
treea1535b01f5b2d2c49fd3449b534aa8b467f0d2b8 /share/hydractl
parent6542f3827dc1d675a2b129622b6b089a693ac0ca (diff)
downloadhydra-f5ddf7507d440bf3642777d159a0a60ff55d0c5b.tar.gz
hydra-f5ddf7507d440bf3642777d159a0a60ff55d0c5b.tar.bz2
Common hydra_deploy_setup
Diffstat (limited to 'share/hydractl')
-rwxr-xr-xshare/hydractl/deploy55
1 files changed, 13 insertions, 42 deletions
diff --git a/share/hydractl/deploy b/share/hydractl/deploy
index 9c82ddf..b488698 100755
--- a/share/hydractl/deploy
+++ b/share/hydractl/deploy
@@ -22,7 +22,6 @@ hydra_config_load
# Parameters
FOLDER="$1"
-FQDN="`facter fqdn`"
# Set sudo config
local sudo device rsync
@@ -32,55 +31,27 @@ fi
# Dispatch
if [ ! -z "$FOLDER" ]; then
- if [ ! -d "$FOLDER"]; then
- echo "folder not found: $FOLDER"
- exit 1
- fi
-
- # Fix hostname
- if [ -s "$FOLDER/etc/hostname" ]; then
- FQDN="`cat $FOLDER/etc/hostname`"
- 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
+ # Setup deploy environment
+ hydra_deploy_setyp remote $node
+ hydra_deploy_mkdirs
# Sync repository to server
- # Exclude eventual keys and version control files
- $sudo rsync -CrltDv --no-perms --exclude=keys --exclude=hiera/secrets --delete $HYDRA_FOLDER/puppet/ $FOLDER/etc/puppet/
-
- # Setup custom facts
- 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'`"
+ $DEPLOY_RSYNC
- # Copy needed hiera YAMLs
- $sudo mkdir -p $FOLDER/etc/puppet/secrets/{domain,location,node,role}
- $sudo cp $HYDRA_FOLDER/puppet/hiera/secrets/domain/$DOMAIN.yaml $FOLDER/etc/puppet/hiera/domain/
- $sudo cp $HYDRA_FOLDER/puppet/hiera/secrets/location/$LOCATION.yaml $FOLDER/etc/puppet/hiera/location/
- $sudo cp $HYDRA_FOLDER/puppet/hiera/secrets/location/$ROLE.yaml $FOLDER/etc/puppet/hiera/role/
-
- # 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 hiera configuration
+ hydra_hiera_copy
# Run puppet
- LC_ALL=C FACTER_role=$ROLE FACTER_location=$LOCATION \
- $sudo chroot $FOLDER puppet apply /etc/puppet/manifests/nodes/$FQDN.pp
+ $DEPLOY_APPLY
elif [ -e "$HYDRA_FOLDER/puppet/manifests/nodes/$FQDN.pp" ]; then
- # Setup custom facts
- 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'`"
+ echo "Deploying to localhost..."
+
+ # Setup deploy environment
+ hydra_deploy_setup
+ # TODO: override FQDN and DOMAIN
# Run puppet
- LC_ALL=C FACTER_role=$ROLE FACTER_location=$LOCATION \
- $sudo puppet apply --confdir=$HYDRA_FOLDER/puppet \
- --modulepath=$HYDRA_FOLDER/modules $HYDRA_FOLDER/puppet/manifests/nodes/$FQDN.pp
+ $DEPLOY_APPLY
fi