|
|
@ -140,6 +140,13 @@ options:
|
|
|
|
- Support passing in the GCE-specific
|
|
|
|
- Support passing in the GCE-specific
|
|
|
|
formatted networkInterfaces[] structure.
|
|
|
|
formatted networkInterfaces[] structure.
|
|
|
|
default: null
|
|
|
|
default: null
|
|
|
|
|
|
|
|
disks_gce_struct:
|
|
|
|
|
|
|
|
description:
|
|
|
|
|
|
|
|
- Support passing in the GCE-specific
|
|
|
|
|
|
|
|
formatted formatted disks[] structure. Case sensitive.
|
|
|
|
|
|
|
|
see U(https://cloud.google.com/compute/docs/reference/latest/instanceTemplates#resource) for detailed information
|
|
|
|
|
|
|
|
default: null
|
|
|
|
|
|
|
|
version_added: "2.4"
|
|
|
|
project_id:
|
|
|
|
project_id:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- your GCE project ID
|
|
|
|
- your GCE project ID
|
|
|
@ -205,6 +212,32 @@ EXAMPLES = '''
|
|
|
|
project_id: "{{ project_id }}"
|
|
|
|
project_id: "{{ project_id }}"
|
|
|
|
credentials_file: "{{ credentials_file }}"
|
|
|
|
credentials_file: "{{ credentials_file }}"
|
|
|
|
service_account_email: "{{ service_account_email }}"
|
|
|
|
service_account_email: "{{ service_account_email }}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Example playbook using disks_gce_struct
|
|
|
|
|
|
|
|
- name: Compute Engine Instance Template Examples
|
|
|
|
|
|
|
|
hosts: localhost
|
|
|
|
|
|
|
|
vars:
|
|
|
|
|
|
|
|
service_account_email: "your-sa@your-project-name.iam.gserviceaccount.com"
|
|
|
|
|
|
|
|
credentials_file: "/path/to/your-key.json"
|
|
|
|
|
|
|
|
project_id: "your-project-name"
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
|
|
|
|
- name: create instance template
|
|
|
|
|
|
|
|
gce_instance_template:
|
|
|
|
|
|
|
|
name: foo
|
|
|
|
|
|
|
|
size: n1-standard-1
|
|
|
|
|
|
|
|
state: present
|
|
|
|
|
|
|
|
project_id: "{{ project_id }}"
|
|
|
|
|
|
|
|
credentials_file: "{{ credentials_file }}"
|
|
|
|
|
|
|
|
service_account_email: "{{ service_account_email }}"
|
|
|
|
|
|
|
|
disks_gce_struct:
|
|
|
|
|
|
|
|
- device_name: /dev/sda
|
|
|
|
|
|
|
|
boot: true
|
|
|
|
|
|
|
|
autoDelete: true
|
|
|
|
|
|
|
|
initializeParams:
|
|
|
|
|
|
|
|
diskSizeGb: 30
|
|
|
|
|
|
|
|
diskType: pd-ssd
|
|
|
|
|
|
|
|
sourceImage: projects/debian-cloud/global/images/family/debian-8
|
|
|
|
|
|
|
|
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
|
RETURN = '''
|
|
|
|
RETURN = '''
|
|
|
@ -234,7 +267,6 @@ except ImportError:
|
|
|
|
|
|
|
|
|
|
|
|
def get_info(inst):
|
|
|
|
def get_info(inst):
|
|
|
|
"""Retrieves instance template information
|
|
|
|
"""Retrieves instance template information
|
|
|
|
|
|
|
|
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
return({
|
|
|
|
return({
|
|
|
|
'name': inst.name,
|
|
|
|
'name': inst.name,
|
|
|
@ -272,6 +304,7 @@ def create_instance_template(module, gce):
|
|
|
|
metadata = module.params.get('metadata')
|
|
|
|
metadata = module.params.get('metadata')
|
|
|
|
description = module.params.get('description')
|
|
|
|
description = module.params.get('description')
|
|
|
|
disks = module.params.get('disks')
|
|
|
|
disks = module.params.get('disks')
|
|
|
|
|
|
|
|
disks_gce_struct = module.params.get('disks_gce_struct')
|
|
|
|
changed = False
|
|
|
|
changed = False
|
|
|
|
|
|
|
|
|
|
|
|
# args of ex_create_instancetemplate
|
|
|
|
# args of ex_create_instancetemplate
|
|
|
@ -360,6 +393,9 @@ def create_instance_template(module, gce):
|
|
|
|
if tags is not None:
|
|
|
|
if tags is not None:
|
|
|
|
gce_args['tags'] = tags
|
|
|
|
gce_args['tags'] = tags
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if disks_gce_struct is not None:
|
|
|
|
|
|
|
|
gce_args['disks_gce_struct'] = disks_gce_struct
|
|
|
|
|
|
|
|
|
|
|
|
# Try to convert the user's metadata value into the format expected
|
|
|
|
# Try to convert the user's metadata value into the format expected
|
|
|
|
# by GCE. First try to ensure user has proper quoting of a
|
|
|
|
# by GCE. First try to ensure user has proper quoting of a
|
|
|
|
# dictionary-like syntax using 'literal_eval', then convert the python
|
|
|
|
# dictionary-like syntax using 'literal_eval', then convert the python
|
|
|
@ -534,7 +570,8 @@ def main():
|
|
|
|
project_id=dict(),
|
|
|
|
project_id=dict(),
|
|
|
|
pem_file=dict(type='path'),
|
|
|
|
pem_file=dict(type='path'),
|
|
|
|
credentials_file=dict(type='path'),
|
|
|
|
credentials_file=dict(type='path'),
|
|
|
|
subnetwork_region=dict()
|
|
|
|
subnetwork_region=dict(),
|
|
|
|
|
|
|
|
disks_gce_struct=dict(type='list')
|
|
|
|
),
|
|
|
|
),
|
|
|
|
mutually_exclusive=[['source', 'image']],
|
|
|
|
mutually_exclusive=[['source', 'image']],
|
|
|
|
required_one_of=[['image', 'image_family']],
|
|
|
|
required_one_of=[['image', 'image_family']],
|
|
|
|