mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-07-08 19:49:09 +00:00
Add credential parameters to the GCE modules.
In order to simplify the workflow with the GCE modules, it's now possible to add the parameters and project name as arguments to the various GCE modules. The inventory plugin also returns the IP of the host in `ansible_ssh_host` so that you don't have to specify IPs into the inventory file. Some update to the documentation are also added. Closes #5583.
This commit is contained in:
parent
e79d859dfb
commit
6294264dc4
7 changed files with 185 additions and 130 deletions
|
|
@ -73,7 +73,7 @@ Version: 0.0.1
|
|||
'''
|
||||
|
||||
USER_AGENT_PRODUCT="Ansible-gce_inventory_plugin"
|
||||
USER_AGENT_VERSION="v1beta15"
|
||||
USER_AGENT_VERSION="v1"
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
|
@ -174,6 +174,10 @@ class GceInventory(object):
|
|||
|
||||
def node_to_dict(self, inst):
|
||||
md = {}
|
||||
|
||||
if inst is None:
|
||||
return {}
|
||||
|
||||
if inst.extra['metadata'].has_key('items'):
|
||||
for entry in inst.extra['metadata']['items']:
|
||||
md[entry['key']] = entry['value']
|
||||
|
|
@ -192,12 +196,17 @@ class GceInventory(object):
|
|||
'gce_zone': inst.extra['zone'].name,
|
||||
'gce_tags': inst.extra['tags'],
|
||||
'gce_metadata': md,
|
||||
'gce_network': net
|
||||
'gce_network': net,
|
||||
# Hosts don't have a public name, so we add an IP
|
||||
'ansible_ssh_host': inst.public_ips[0]
|
||||
}
|
||||
|
||||
def get_instance(self, instance_name):
|
||||
'''Gets details about a specific instance '''
|
||||
return self.driver.ex_get_node(instance_name)
|
||||
try:
|
||||
return self.driver.ex_get_node(instance_name)
|
||||
except Exception, e:
|
||||
return None
|
||||
|
||||
def group_instances(self):
|
||||
'''Group all instances'''
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue