]> gitweb.fluxo.info Git - hydra.git/commitdiff
Adds hydractl yaml-param
authorSilvio Rhatto <rhatto@riseup.net>
Mon, 25 May 2020 14:18:27 +0000 (11:18 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Mon, 25 May 2020 14:18:27 +0000 (11:18 -0300)
lib/hydra/deploy
share/hydractl/yaml-param [new file with mode: 0755]

index b985aa8ae1e4e87a7ad9fd99051c75a9c642bd1b..3335686b48d7eaf3a02cf61b7b05264d6501a258 100644 (file)
@@ -245,7 +245,7 @@ function hydra_deploy_copy {
 function hydra_deploy_facts_setup {
   echo "Setting up custom facts..."
 
-  ROLE="`hydra_yaml_param nodo::role $HYDRA_FOLDER/puppet/config/node/$FQDN.yaml`"
+  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
diff --git a/share/hydractl/yaml-param b/share/hydractl/yaml-param
new file mode 100755 (executable)
index 0000000..1ace6c2
--- /dev/null
@@ -0,0 +1,30 @@
+#!/bin/bash
+
+# Load.
+source $APP_BASE/lib/hydra/functions || exit 1
+hydra_config_load
+
+# Parameters
+BASENAME="`basename $0`"
+PARAM="$1"
+YAML_FILE="$2"
+DEFAULT="$3"
+
+# Check
+if [ -z "$2" ]; then
+  echo "usage: $BASENAME <param> <file> [default-value]"
+  exit 1
+elif [ ! -e "$YAML_FILE" ]; then
+  echo "file not found: $YAML_FILE"
+  exit 1
+fi
+
+# Dispatch
+PARAM="`hydra_yaml_param $PARAM $YAML_FILE`"
+
+# Display
+if [ ! -z "$PARAM" ]; then
+  echo "$PARAM"
+elif [ ! -z "$DEFAULT" ]; then
+  echo "$DEFAULT"
+fi