aboutsummaryrefslogtreecommitdiff
path: root/lib/hydra/deploy
diff options
context:
space:
mode:
Diffstat (limited to 'lib/hydra/deploy')
-rw-r--r--lib/hydra/deploy38
1 files changed, 37 insertions, 1 deletions
diff --git a/lib/hydra/deploy b/lib/hydra/deploy
index 497f03a..b985aa8 100644
--- a/lib/hydra/deploy
+++ b/lib/hydra/deploy
@@ -130,7 +130,8 @@ function hydra_yaml_param {
local param="$1"
local file="$2"
- grep "^$param: " $file | cut -d ' ' -f 2 | sed -e "s/'//g" -e 's/"//g'
+ #grep "^$param: " $file | cut -d ' ' -f 2 | sed -e "s/'//g" -e 's/"//g'
+ grep "^$param" $file | sed -e "s/^$param//" | cut -d ':' -f 2 | sed -e "s/'//g" -e 's/"//g' -e "s/ //g"
}
# Create puppet folder structure
@@ -240,6 +241,41 @@ function hydra_deploy_copy {
fi
}
+# Setup custom facts
+function hydra_deploy_facts_setup {
+ echo "Setting up custom facts..."
+
+ ROLE="`hydra_yaml_param nodo::role $HYDRA_FOLDER/puppet/config/node/$FQDN.yaml`"
+ LOCATION="`hydra_yaml_param nodo::location $HYDRA_FOLDER/puppet/config/node/$FQDN.yaml`"
+
+ if [ -z "$ROLE" ]; then
+ ROLE="default"
+ fi
+
+ if [ -z "$LOCATION" ]; then
+ LOCATION="default"
+ fi
+
+ if [ "$1" == "local" ]; then
+ $SUDO mkdir -p /etc/facter/facts.d
+ $SUDO echo "role=$ROLE" | $SUDO tee /etc/facter/facts.d/role.txt > /dev/null
+ $SUDO echo "location=$LOCATION" | $SUDO tee /etc/facter/facts.d/location.txt > /dev/null
+ elif [ "$1" == "remote" ]; then
+ local error
+
+ $HYDRA_CONNECT $FQDN "sudo mkdir -p /etc/facter/facts.d" || error=1
+ $HYDRA_CONNECT $FQDN "echo role=$ROLE | sudo tee /etc/facter/facts.d/role.txt > /dev/null" || error=1
+ $HYDRA_CONNECT $FQDN "echo location=$LOCATION | sudo tee /etc/facter/facts.d/location.txt > /dev/null" || error=1
+
+ # Check result
+ #if [ "$?" != "0" ]; then
+ if [ "$error" == "1" ]; then
+ echo "Error setting up facts at $FQDN."
+ return 1
+ fi
+ fi
+}
+
# Collects facts from a system
function hydra_deploy_facts_collect {
echo "Collecting facts from system..."