aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2015-09-26 22:27:25 -0300
committerSilvio Rhatto <rhatto@riseup.net>2015-09-26 22:27:25 -0300
commit4952dcb2c77f5f99039283cfaaf127553c8e7c3d (patch)
tree92546c8bfee771107343adcc538da63dbb916ada
parentd876a2fa81899eb2bc689a0ac9d0ecd9513cf187 (diff)
downloadhydra-4952dcb2c77f5f99039283cfaaf127553c8e7c3d.tar.gz
hydra-4952dcb2c77f5f99039283cfaaf127553c8e7c3d.tar.bz2
Updates deployment code
-rw-r--r--lib/hydra/deploy14
-rwxr-xr-xshare/hydra/deploy11
-rwxr-xr-xshare/hydractl/deploy19
3 files changed, 29 insertions, 15 deletions
diff --git a/lib/hydra/deploy b/lib/hydra/deploy
index f537c42..d5df1a0 100644
--- a/lib/hydra/deploy
+++ b/lib/hydra/deploy
@@ -1,7 +1,6 @@
#!/bin/bash
# Setup deployment parameters
-# TODO: check environment passing to sudo, chroot and ssh
function hydra_deploy_setup {
# Common parameters
# Exclude eventual keys and version control files
@@ -56,8 +55,7 @@ function hydra_deploy_setup {
DOMAIN="`echo $FQDN | cut -d . -f 2-`"
ROLE="`hydra_yaml_param nodo::role $HYDRA_FOLDER/$DOMAIN/$FQDN.yaml`"
LOCATION="`hydra_yaml_param nodo::location $HYDRA_FOLDER/$DOMAIN/$FQDN.yaml`"
- DEPLOY_ENV="LC_ALL=C FACTER_role=$ROLE FACTER_location=$LOCATION"
- DEPLOY_PUPPET="$DEPLOY_ENV puppet appy $PUPPET_OPTS $PUPPET_MANIFEST"
+ DEPLOY_PUPPET="puppet appy $PUPPET_OPTS $PUPPET_MANIFEST"
DEPLOY_APPLY="$DEPLOY_COMMAND $DEPLOY_PUPPET"
# Check for manifest
@@ -91,11 +89,15 @@ function hydra_hiera_copy {
$DEPLOY_COPY $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/domain/$LOCATION.yaml" ]; then
+ 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/
fi
- if [ ! -z "$ROLE" ] && [ -e "$HYDRA_FOLDER/puppet/hiera/secrets/domain/$ROLE.yaml" ]; then
- $DEPLOY_COPY $HYDRA_FOLDER/puppet/hiera/secrets/location/$ROLE.yaml $DEPLOY_DEST/etc/puppet/hiera/secrets/role/
+ 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/
+ 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/
fi
}
diff --git a/share/hydra/deploy b/share/hydra/deploy
index 0afd879..4bf6686 100755
--- a/share/hydra/deploy
+++ b/share/hydra/deploy
@@ -42,6 +42,17 @@ for node in $NODES; do
# Copy hiera configuration
hydra_hiera_copy
+ # Check if puppet is installed
+ $HYDRA_CONNECT $node <<EOF
+ ##### BEGIN REMOTE SCRIPT #####
+ if ! which puppet &> /dev/null; then
+ echo "Installing puppet..."
+ sudo aptitude update
+ sudo aptitude install puppet -y
+ fi
+ ##### END REMOTE SCRIPT #######
+EOF
+
# Run puppet
$DEPLOY_APPLY
done
diff --git a/share/hydractl/deploy b/share/hydractl/deploy
index b488698..191b060 100755
--- a/share/hydractl/deploy
+++ b/share/hydractl/deploy
@@ -23,12 +23,6 @@ hydra_config_load
# Parameters
FOLDER="$1"
-# Set sudo config
-local sudo device rsync
-if [ "`whoami`" != 'root' ]; then
- sudo="sudo"
-fi
-
# Dispatch
if [ ! -z "$FOLDER" ]; then
echo "Deploying to $FOLDER..."
@@ -43,15 +37,22 @@ if [ ! -z "$FOLDER" ]; then
# Copy hiera configuration
hydra_hiera_copy
- # Run puppet
- $DEPLOY_APPLY
+ # Check if puppet is installed
+ if [ ! -e "$FOLDER/usr/bin/puppet" ]; then
+ $DEPLOY_COMMAND apt-get install puppet -y
+ fi
+
+ # Run puppet, overriding FQDN
+ FACTER_domain=$DOMAIN FACTER_hostname=$HOSTNAME FACTER_fqdn=$HOSTNAME.$DOMAIN $DEPLOY_APPLY
elif [ -e "$HYDRA_FOLDER/puppet/manifests/nodes/$FQDN.pp" ]; then
echo "Deploying to localhost..."
# Setup deploy environment
hydra_deploy_setup
- # TODO: override FQDN and DOMAIN
+ # Check if puppet is installed
+ hydra_install_package puppet
+
# Run puppet
$DEPLOY_APPLY
fi