]> gitweb.fluxo.info Git - hydra.git/commitdiff
Updates deployment code
authorSilvio Rhatto <rhatto@riseup.net>
Sun, 27 Sep 2015 01:27:25 +0000 (22:27 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Sun, 27 Sep 2015 01:27:25 +0000 (22:27 -0300)
lib/hydra/deploy
share/hydra/deploy
share/hydractl/deploy

index f537c4257a5e9be48f31938670204188dc176962..d5df1a0f3263d5ed654bdf16d15db415451162ac 100644 (file)
@@ -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
 }
index 0afd879eaf285a2005a494237a257b0c5955dd52..4bf668602f4763e372343874e353f760988200f5 100755 (executable)
@@ -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
index b48869887cf59a4ed57007bafd75ea831f42a0c1..191b060de7977794ebdf93097180bc58dba253a3 100755 (executable)
@@ -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