From 4dcf76261952adb273578c9fe798ffa9d33101b2 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Sun, 20 Sep 2015 19:18:00 -0300 Subject: Initial changes for ansible integration --- share/hydra/inventory | 27 +++++++++++++++++++++++++++ share/hydra/mass | 9 ++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) (limited to 'share') diff --git a/share/hydra/inventory b/share/hydra/inventory index e69de29..97b63e6 100644 --- a/share/hydra/inventory +++ b/share/hydra/inventory @@ -0,0 +1,27 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +# Builds an inventory of nodes. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public +# License along with this program. If not, see +# . +# Copyright (C) 2015 Silvio Rhatto + +# Dependencies +import yaml +import sys, os + +# TODO +class Inventory: + """Hydra inventory class""" diff --git a/share/hydra/mass b/share/hydra/mass index 3b1ed2d..b368ec0 100755 --- a/share/hydra/mass +++ b/share/hydra/mass @@ -16,6 +16,11 @@ # License along with this program. If not, see # . +# Issue commands with ansible +function mass_ansible { + HYDRA=$HYDRA ansible $ROLE -i $DIRNAME/inventory --sudo -a "$COMMAND" +} + # Issue commands with pssh function mass_pssh { hydra_check_command parallel-ssh @@ -53,6 +58,7 @@ source $APP_BASE/lib/hydra/functions || exit 1 hydra_config_load # Command line arguments +DIRNAME="`dirname $0`" BASENAME="`basename $0`" COMMAND="$*" @@ -66,7 +72,8 @@ if [ "$BASENAME" == "mass-update" ]; then elif [ "$BASENAME" == "mass-upgrade" ]; then COMMAND="DEBIAN_FRONTEND=noninteractive hydractl upgrade clean" elif [ "$BASENAME" == "mass-web" ]; then - set_nodes web + ROLE="web" + set_nodes $ROLE fi # Execute commands in hosts -- cgit v1.2.3