aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2018-05-26 16:26:33 -0300
committerSilvio Rhatto <rhatto@riseup.net>2018-05-26 16:26:33 -0300
commit62ebbcf86b038fd01891a154c203f58ad434d89e (patch)
treee1158c4a245cb7e28a4f6007340528837a61fc03
parentb75fa5cc871c958284d2e25dc0845a99058d3e88 (diff)
downloadhydra-62ebbcf86b038fd01891a154c203f58ad434d89e.tar.gz
hydra-62ebbcf86b038fd01891a154c203f58ad434d89e.tar.bz2
Nodes: ansible support
-rwxr-xr-xshare/hydra/nodes44
1 files changed, 25 insertions, 19 deletions
diff --git a/share/hydra/nodes b/share/hydra/nodes
index eb661c3..fff3549 100755
--- a/share/hydra/nodes
+++ b/share/hydra/nodes
@@ -17,15 +17,15 @@
# <http://www.gnu.org/licenses/>.
# Get a list of puppet node files
-function hydra_node_files {
+function hydra_node_files_puppet {
if [ -d "$PUPPET/config/node/" ]; then
#FILES="$PUPPET/config/node/*"
FILES="`ls -1 $PUPPET/config/node/ | grep -v example.org | xargs`"
fi
}
-# Return node names
-function hydra_nodes {
+# Return node names from puppet config
+function hydra_nodes_puppet {
for file in $FILES; do
basename $file .yaml
done
@@ -39,23 +39,29 @@ hydra_config_load
CLASS="$1"
# Validation
-if [ -z "$PUPPET" ]; then
- echo "No PUPPET parameter defined at $HYDRA preferences."
- exit 1
-fi
+if ! [ -z "$PUPPET" ]; then
+ # Get initial file list
+ hydra_node_files_puppet
-# Get initial file list
-hydra_node_files
+ # Get nodes
+ if [ ! -z "$CLASS" ]; then
+ hydra_nodes_puppet | 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
+ basename $candidate .yaml
+ fi
+ done
+ else
+ hydra_nodes_puppet
+ fi
+elif [ -d "$HYDRA_FOLDER/ansible" ]; then
+ if [ -z "$CLASS" ]; then
+ CLASS="all"
+ fi
-# Get nodes
-if [ ! -z "$CLASS" ]; then
- hydra_nodes | 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
- basename $candidate .yaml
- fi
- done
+ ANSIBLE_CONFIG=$HYDRA_FOLDER/ansible/ansible.cfg ansible -i inventories $CLASS --list-hosts | grep -v "^ hosts (" | sed -e 's/^ //'
else
- hydra_nodes
+ echo "No PUPPET parameter defined at $HYDRA preferences or ansible config available."
+ exit 1
fi