diff options
-rw-r--r-- | lib/hydra/deploy | 38 | ||||
-rwxr-xr-x | share/hydra/deploy | 2 |
2 files changed, 39 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..." diff --git a/share/hydra/deploy b/share/hydra/deploy index 7b9e05e..af3d0a2 100755 --- a/share/hydra/deploy +++ b/share/hydra/deploy @@ -140,6 +140,7 @@ for node in $NODES; do hydractl install # Collect facts + hydra_deploy_facts_setup local hydra_deploy_facts_collect local # Run puppet @@ -218,6 +219,7 @@ EOF hydra_deploy_mkdirs # Collect facts + hydra_deploy_facts_setup remote || continue hydra_deploy_facts_collect remote || continue # Sync repository to server |