aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xshare/hydra/nodes42
1 files changed, 26 insertions, 16 deletions
diff --git a/share/hydra/nodes b/share/hydra/nodes
index fff3549..c75d5d3 100755
--- a/share/hydra/nodes
+++ b/share/hydra/nodes
@@ -17,7 +17,7 @@
# <http://www.gnu.org/licenses/>.
# Get a list of puppet node files
-function hydra_node_files_puppet {
+function hydra_node_puppet_files {
if [ -d "$PUPPET/config/node/" ]; then
#FILES="$PUPPET/config/node/*"
FILES="`ls -1 $PUPPET/config/node/ | grep -v example.org | xargs`"
@@ -25,27 +25,20 @@ function hydra_node_files_puppet {
}
# Return node names from puppet config
-function hydra_nodes_puppet {
+function hydra_nodes_puppet_names {
for file in $FILES; do
basename $file .yaml
done
}
-# Load
-source $APP_BASE/lib/hydra/functions || exit 1
-hydra_config_load
-
-# Command line arguments
-CLASS="$1"
-
-# Validation
-if ! [ -z "$PUPPET" ]; then
+# Return nodes from puppet config
+function hydra_nodes_puppet {
# Get initial file list
- hydra_node_files_puppet
+ hydra_node_puppet_files
# Get nodes
if [ ! -z "$CLASS" ]; then
- hydra_nodes_puppet | while read node; do
+ hydra_nodes_puppet_names | while read node; do
find $PUPPET/config -name "$node.yaml"
done | while read candidate; do
if grep -e "$CLASS" $candidate | grep -qe "^nodo::role"; then
@@ -53,14 +46,31 @@ if ! [ -z "$PUPPET" ]; then
fi
done
else
- hydra_nodes_puppet
+ hydra_nodes_puppet_names
fi
-elif [ -d "$HYDRA_FOLDER/ansible" ]; then
+}
+
+# Return nodes from ansible config
+function hydra_nodes_ansible {
if [ -z "$CLASS" ]; then
CLASS="all"
fi
- ANSIBLE_CONFIG=$HYDRA_FOLDER/ansible/ansible.cfg ansible -i inventories $CLASS --list-hosts | grep -v "^ hosts (" | sed -e 's/^ //'
+ hydra $HYDRA ansible $CLASS --list-hosts | grep -v "^ hosts (" | sed -e 's/^ //'
+}
+
+# Load
+source $APP_BASE/lib/hydra/functions || exit 1
+hydra_config_load
+
+# Command line arguments
+CLASS="$1"
+
+# Validation
+if ! [ -z "$PUPPET" ] && [ "$BACKEND" != "ansible" ]; then
+ hydra_nodes_puppet
+elif [ -d "$HYDRA_FOLDER/ansible" ]; then
+ hydra_nodes_ansible
else
echo "No PUPPET parameter defined at $HYDRA preferences or ansible config available."
exit 1