From 4a1e5c0b18260355a258384b8510db4361b83f1c Mon Sep 17 00:00:00 2001 From: Thomas Wiest Date: Fri, 13 Feb 2015 14:11:34 -0500 Subject: Updated to the latest gce.py from upstream. It includes _meta and hostvars!!! --- inventory/gce/gce.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/inventory/gce/gce.py b/inventory/gce/gce.py index c8eeb43ab..e77178c16 100755 --- a/inventory/gce/gce.py +++ b/inventory/gce/gce.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # Copyright 2013 Google Inc. # # This file is part of Ansible @@ -103,11 +103,13 @@ class GceInventory(object): # Just display data for specific host if self.args.host: print self.json_format_dict(self.node_to_dict( - self.get_instance(self.args.host))) + self.get_instance(self.args.host)), + pretty=self.args.pretty) sys.exit(0) # Otherwise, assume user wants all instances grouped - print(self.json_format_dict(self.group_instances())) + print(self.json_format_dict(self.group_instances(), + pretty=self.args.pretty)) sys.exit(0) def get_gce_driver(self): @@ -187,6 +189,8 @@ class GceInventory(object): help='List instances (default: True)') parser.add_argument('--host', action='store', help='Get all information about an instance') + parser.add_argument('--pretty', action='store_true', default=False, + help='Pretty format (default: False)') self.args = parser.parse_args() @@ -229,9 +233,14 @@ class GceInventory(object): def group_instances(self): '''Group all instances''' groups = {} + meta = {} + meta["hostvars"] = {} + for node in self.driver.list_nodes(): name = node.name + meta["hostvars"][name] = self.node_to_dict(node) + zone = node.extra['zone'].name if groups.has_key(zone): groups[zone].append(name) else: groups[zone] = [name] @@ -259,6 +268,9 @@ class GceInventory(object): stat = 'status_%s' % status.lower() if groups.has_key(stat): groups[stat].append(name) else: groups[stat] = [name] + + groups["_meta"] = meta + return groups def json_format_dict(self, data, pretty=False): -- cgit v1.2.3 From 8bb0c7f24b4bafec77d6988639ae9f56396bf1a4 Mon Sep 17 00:00:00 2001 From: Kenny Woodson Date: Fri, 13 Feb 2015 15:10:29 -0500 Subject: Fixing tag name to prepend aws identifier. --- lib/aws_command.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/aws_command.rb b/lib/aws_command.rb index 1c3efc91c..2119630cf 100644 --- a/lib/aws_command.rb +++ b/lib/aws_command.rb @@ -78,7 +78,7 @@ module OpenShift details = AwsHelper.get_host_details(options[:name]) ah.extra_vars['oo_host_group_exp'] = options[:name] ah.extra_vars['oo_env'] = details['env'] - host_type = details['host-type'] + host_type = details['ec2_tag_host-type'] elsif options[:type] && options[:env] oo_env_host_type_tag = AwsHelper.generate_env_host_type_tag_name(options[:env], options[:type]) ah.extra_vars['oo_host_group_exp'] = "groups['#{oo_env_host_type_tag}']" -- cgit v1.2.3 From 1bbb46d608b8315830b4ffd4f853cf6e2215d994 Mon Sep 17 00:00:00 2001 From: Kenny Woodson Date: Fri, 13 Feb 2015 15:43:10 -0500 Subject: Fixed a couple of other variables that were incorrect. --- lib/aws_command.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/aws_command.rb b/lib/aws_command.rb index 2119630cf..5cbb7871b 100644 --- a/lib/aws_command.rb +++ b/lib/aws_command.rb @@ -76,8 +76,8 @@ module OpenShift host_type = nil if options[:name] details = AwsHelper.get_host_details(options[:name]) - ah.extra_vars['oo_host_group_exp'] = options[:name] - ah.extra_vars['oo_env'] = details['env'] + ah.extra_vars['oo_host_group_exp'] = details['ec2_public_dns_name'] + ah.extra_vars['oo_env'] = details['ec2_tag_environment'] host_type = details['ec2_tag_host-type'] elsif options[:type] && options[:env] oo_env_host_type_tag = AwsHelper.generate_env_host_type_tag_name(options[:env], options[:type]) -- cgit v1.2.3