From 7d368f62f06a37a92cf8d644842c338ba55b1d67 Mon Sep 17 00:00:00 2001 From: Kenny Woodson Date: Wed, 11 Feb 2015 10:38:47 -0500 Subject: initial commit of scp utilitiy --- bin/ansibleutil.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'bin/ansibleutil.py') diff --git a/bin/ansibleutil.py b/bin/ansibleutil.py index b12b7b447..f5f699918 100644 --- a/bin/ansibleutil.py +++ b/bin/ansibleutil.py @@ -17,7 +17,8 @@ class AnsibleUtil(object): if args: cmd.extend(args) - env = {} + env = os.environ + p = subprocess.Popen(cmd, stderr=subprocess.PIPE, stdout=subprocess.PIPE, env=env) @@ -66,4 +67,23 @@ class AnsibleUtil(object): return inst_by_env + def get_hostnames(self, args=[]): + inv = self.get_inventory(args) + + import collections + hostnames = collections.defaultdict(list) + + for dns, host in inv['_meta']['hostvars'].items(): + hostnames['ec2_tag_Name'].append(host['ec2_id']) + + return hostnames + + def get_host_ids(self, args=[]): + inv = self.get_inventory(args) + + ids = {} + + for dns, host in inv['_meta']['hostvars'].items(): + ids['ec2_id'] = host + return ids -- cgit v1.2.3 From 603c79412df1b141230ec55f032ad086ada37097 Mon Sep 17 00:00:00 2001 From: Kenny Woodson Date: Wed, 11 Feb 2015 14:41:52 -0500 Subject: Checking in oscp. --- bin/ansibleutil.py | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) (limited to 'bin/ansibleutil.py') diff --git a/bin/ansibleutil.py b/bin/ansibleutil.py index f5f699918..07e41b42c 100644 --- a/bin/ansibleutil.py +++ b/bin/ansibleutil.py @@ -5,6 +5,7 @@ import sys import os import json import re +import collections class AnsibleUtil(object): def __init__(self): @@ -53,7 +54,7 @@ class AnsibleUtil(object): return groups - def build_host_dict(self, args=[]): + def build_host_dict_by_env(self, args=[]): inv = self.get_inventory(args) inst_by_env = {} @@ -63,27 +64,5 @@ class AnsibleUtil(object): host_id = "%s:%s" % (host['ec2_tag_Name'],host['ec2_id']) inst_by_env[host['ec2_tag_environment']][host_id] = host - return inst_by_env - - def get_hostnames(self, args=[]): - inv = self.get_inventory(args) - - import collections - hostnames = collections.defaultdict(list) - - for dns, host in inv['_meta']['hostvars'].items(): - hostnames['ec2_tag_Name'].append(host['ec2_id']) - - return hostnames - - def get_host_ids(self, args=[]): - inv = self.get_inventory(args) - - ids = {} - - for dns, host in inv['_meta']['hostvars'].items(): - ids['ec2_id'] = host - - return ids -- cgit v1.2.3 From 1505751e7846266285c0c517b8cb85cee17c6a5c Mon Sep 17 00:00:00 2001 From: Kenny Woodson Date: Thu, 12 Feb 2015 09:50:18 -0500 Subject: Cleanup before PR approval. --- bin/ansibleutil.py | 1 - 1 file changed, 1 deletion(-) (limited to 'bin/ansibleutil.py') diff --git a/bin/ansibleutil.py b/bin/ansibleutil.py index 07e41b42c..b9f37726e 100644 --- a/bin/ansibleutil.py +++ b/bin/ansibleutil.py @@ -5,7 +5,6 @@ import sys import os import json import re -import collections class AnsibleUtil(object): def __init__(self): -- cgit v1.2.3