aboutsummaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
Diffstat (limited to 'share')
-rwxr-xr-xshare/hydra/deploy38
-rwxr-xr-xshare/hydractl/deploy55
2 files changed, 20 insertions, 73 deletions
diff --git a/share/hydra/deploy b/share/hydra/deploy
index 940c17b..0afd879 100755
--- a/share/hydra/deploy
+++ b/share/hydra/deploy
@@ -32,40 +32,16 @@ fi
for node in $NODES; do
echo "Deploying to $node..."
- # Saner defaults
- $HYDRA_CONNECT $node sudo mkdir -p /etc/puppet
- $HYDRA_CONNECT $node sudo chown -R root. /etc/puppet
- $HYDRA_CONNECT $node sudo chmod -R 640 /etc/puppet
+ # Setup deploy environment
+ hydra_deploy_setyp remote $node
+ hydra_deploy_mkdirs
# Sync repository to server
- # Exclude eventual keys and version control files
- rsync -CrltDv --no-perms --exclude=keys --exclude=hiera/secrets --delete --rsync-path "sudo rsync" $HYDRA_FOLDER/puppet/ $node:/etc/puppet/
+ $DEPLOY_RSYNC
- # Setup custom facts
- FQDN="`$HYDRA_CONNECT $node facter fqdn`"
- 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'`"
-
- # 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 needed hiera YAMLs
- $HYDRA_CONNECT $node sudo mkdir -p $FOLDER/etc/puppet/secrets/{domain,location,node,role}
- $HYDRA_CONNECT $node sudo cp $HYDRA_FOLDER/puppet/hiera/secrets/domain/$DOMAIN.yaml $FOLDER/etc/puppet/hiera/domain/
- $HYDRA_CONNECT $node sudo cp $HYDRA_FOLDER/puppet/hiera/secrets/location/$LOCATION.yaml $FOLDER/etc/puppet/hiera/location/
- $HYDRA_CONNECT $node sudo cp $HYDRA_FOLDER/puppet/hiera/secrets/location/$ROLE.yaml $FOLDER/etc/puppet/hiera/role/
+ # Copy hiera configuration
+ hydra_hiera_copy
# Run puppet
- $HYDRA_CONNECT $node <<EOF
- ##### BEGIN REMOTE SCRIPT #####
- sudo chown -R root. /etc/puppet
- sudo chmod -R 640 /etc/puppet
- LC_ALL=C FACTER_role=$ROLE FACTER_location=$LOCATION \
- sudo puppet apply /etc/puppet/manifests/nodes/$FQDN.pp
- ##### END REMOTE SCRIPT #######
-EOF
+ $DEPLOY_APPLY
done
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