From 4737b41f264593c630f67f981bd6c3eaac75660c Mon Sep 17 00:00:00 2001 From: Robert Marsa Date: Thu, 12 Feb 2015 14:24:03 -0800 Subject: [PATCH] Added the ability to set an instance to forward ip. --- lib/ansible/modules/cloud/google/gce.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/ansible/modules/cloud/google/gce.py b/lib/ansible/modules/cloud/google/gce.py index d429b61de20..4105baa30f4 100644 --- a/lib/ansible/modules/cloud/google/gce.py +++ b/lib/ansible/modules/cloud/google/gce.py @@ -115,6 +115,13 @@ options: required: true default: "us-central1-a" aliases: [] + ip_forward: + version_added: "1.9" + description: + - set to true if the instance can forward ip packets (useful for gateways) + required: false + default: "false" + aliases: [] requirements: [ "libcloud" ] notes: @@ -235,7 +242,7 @@ def get_instance_info(inst): 'status': ('status' in inst.extra) and inst.extra['status'] or None, 'tags': ('tags' in inst.extra) and inst.extra['tags'] or [], 'zone': ('zone' in inst.extra) and inst.extra['zone'].name or None, - }) + }) def create_instances(module, gce, instance_names): """Creates new instances. Attributes other than instance_names are picked @@ -259,6 +266,7 @@ def create_instances(module, gce, instance_names): state = module.params.get('state') tags = module.params.get('tags') zone = module.params.get('zone') + ip_forward = module.params.get('ip_forward') new_instances = [] changed = False @@ -319,7 +327,7 @@ def create_instances(module, gce, instance_names): try: inst = gce.create_node(name, lc_machine_type, lc_image, location=lc_zone, ex_network=network, ex_tags=tags, - ex_metadata=metadata, ex_boot_disk=pd) + ex_metadata=metadata, ex_boot_disk=pd, ex_can_ip_forward=ip_forward) changed = True except ResourceExistsError: inst = gce.ex_get_node(name, lc_zone) @@ -409,6 +417,7 @@ def main(): service_account_email = dict(), pem_file = dict(), project_id = dict(), + ip_forward = dict(type='bool', default=False), ) ) @@ -424,6 +433,7 @@ def main(): state = module.params.get('state') tags = module.params.get('tags') zone = module.params.get('zone') + ip_forward = module.params.get('ip_forward') changed = False inames = []