|
|
|
|
@ -112,6 +112,11 @@ options:
|
|
|
|
|
- The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
|
|
|
|
|
key that protects this resource.
|
|
|
|
|
required: false
|
|
|
|
|
labels:
|
|
|
|
|
description:
|
|
|
|
|
- Labels to apply to this Image.
|
|
|
|
|
required: false
|
|
|
|
|
version_added: 2.8
|
|
|
|
|
licenses:
|
|
|
|
|
description:
|
|
|
|
|
- Any applicable license URI.
|
|
|
|
|
@ -147,16 +152,16 @@ options:
|
|
|
|
|
description:
|
|
|
|
|
- The full Google Cloud Storage URL where disk storage is stored You must
|
|
|
|
|
provide either this property or the sourceDisk property but not both.
|
|
|
|
|
required: false
|
|
|
|
|
required: true
|
|
|
|
|
source_disk:
|
|
|
|
|
description:
|
|
|
|
|
- Refers to a gcompute_disk object You must provide either this property or the
|
|
|
|
|
rawDisk.source property but not both to create an image.
|
|
|
|
|
- The source disk to create this image based on.
|
|
|
|
|
- You must provide either this property or the rawDisk.source property but not
|
|
|
|
|
both to create an image.
|
|
|
|
|
- 'This field represents a link to a Disk resource in GCP. It can be specified
|
|
|
|
|
in two ways. You can add `register: name-of-resource` to a gcp_compute_disk
|
|
|
|
|
task and then set this source_disk field to "{{ name-of-resource }}" Alternatively,
|
|
|
|
|
you can set this source_disk to a dictionary with the selfLink key where the
|
|
|
|
|
value is the selfLink of your Disk'
|
|
|
|
|
in two ways. First, you can place in the selfLink of the resource here as a
|
|
|
|
|
string Alternatively, you can add `register: name-of-resource` to a gcp_compute_disk
|
|
|
|
|
task and then set this source_disk field to "{{ name-of-resource }}"'
|
|
|
|
|
required: false
|
|
|
|
|
source_disk_encryption_key:
|
|
|
|
|
description:
|
|
|
|
|
@ -188,6 +193,9 @@ options:
|
|
|
|
|
choices:
|
|
|
|
|
- RAW
|
|
|
|
|
extends_documentation_fragment: gcp
|
|
|
|
|
notes:
|
|
|
|
|
- 'API Reference: U(https://cloud.google.com/compute/docs/reference/latest/images)'
|
|
|
|
|
- 'Official Documentation: U(https://cloud.google.com/compute/docs/images)'
|
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
EXAMPLES = '''
|
|
|
|
|
@ -330,6 +338,17 @@ imageEncryptionKey:
|
|
|
|
|
key that protects this resource.
|
|
|
|
|
returned: success
|
|
|
|
|
type: str
|
|
|
|
|
labels:
|
|
|
|
|
description:
|
|
|
|
|
- Labels to apply to this Image.
|
|
|
|
|
returned: success
|
|
|
|
|
type: dict
|
|
|
|
|
labelFingerprint:
|
|
|
|
|
description:
|
|
|
|
|
- The fingerprint used for optimistic locking of this resource. Used internally
|
|
|
|
|
during updates.
|
|
|
|
|
returned: success
|
|
|
|
|
type: str
|
|
|
|
|
licenses:
|
|
|
|
|
description:
|
|
|
|
|
- Any applicable license URI.
|
|
|
|
|
@ -372,10 +391,11 @@ rawDisk:
|
|
|
|
|
type: str
|
|
|
|
|
sourceDisk:
|
|
|
|
|
description:
|
|
|
|
|
- Refers to a gcompute_disk object You must provide either this property or the
|
|
|
|
|
rawDisk.source property but not both to create an image.
|
|
|
|
|
- The source disk to create this image based on.
|
|
|
|
|
- You must provide either this property or the rawDisk.source property but not both
|
|
|
|
|
to create an image.
|
|
|
|
|
returned: success
|
|
|
|
|
type: dict
|
|
|
|
|
type: str
|
|
|
|
|
sourceDiskEncryptionKey:
|
|
|
|
|
description:
|
|
|
|
|
- The customer-supplied encryption key of the source disk. Required if the source
|
|
|
|
|
@ -439,14 +459,15 @@ def main():
|
|
|
|
|
raw_key=dict(type='str'),
|
|
|
|
|
sha256=dict(type='str')
|
|
|
|
|
)),
|
|
|
|
|
labels=dict(type='dict'),
|
|
|
|
|
licenses=dict(type='list', elements='str'),
|
|
|
|
|
name=dict(required=True, type='str'),
|
|
|
|
|
raw_disk=dict(type='dict', options=dict(
|
|
|
|
|
container_type=dict(type='str', choices=['TAR']),
|
|
|
|
|
sha1_checksum=dict(type='str'),
|
|
|
|
|
source=dict(type='str')
|
|
|
|
|
source=dict(required=True, type='str')
|
|
|
|
|
)),
|
|
|
|
|
source_disk=dict(type='dict'),
|
|
|
|
|
source_disk=dict(),
|
|
|
|
|
source_disk_encryption_key=dict(type='dict', options=dict(
|
|
|
|
|
raw_key=dict(type='str'),
|
|
|
|
|
sha256=dict(type='str')
|
|
|
|
|
@ -468,7 +489,7 @@ def main():
|
|
|
|
|
if fetch:
|
|
|
|
|
if state == 'present':
|
|
|
|
|
if is_different(module, fetch):
|
|
|
|
|
update(module, self_link(module), kind)
|
|
|
|
|
update(module, self_link(module), kind, fetch)
|
|
|
|
|
fetch = fetch_resource(module, self_link(module), kind)
|
|
|
|
|
changed = True
|
|
|
|
|
else:
|
|
|
|
|
@ -492,9 +513,29 @@ def create(module, link, kind):
|
|
|
|
|
return wait_for_operation(module, auth.post(link, resource_to_request(module)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def update(module, link, kind):
|
|
|
|
|
def update(module, link, kind, fetch):
|
|
|
|
|
update_fields(module, resource_to_request(module),
|
|
|
|
|
response_to_hash(module, fetch))
|
|
|
|
|
return fetch_resource(module, self_link(module), kind)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def update_fields(module, request, response):
|
|
|
|
|
if response.get('labels') != request.get('labels'):
|
|
|
|
|
labels_update(module, request, response)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def labels_update(module, request, response):
|
|
|
|
|
auth = GcpSession(module, 'compute')
|
|
|
|
|
return wait_for_operation(module, auth.put(link, resource_to_request(module)))
|
|
|
|
|
auth.post(
|
|
|
|
|
''.join([
|
|
|
|
|
"https://www.googleapis.com/compute/v1/",
|
|
|
|
|
"projects/{project}/global/images/{name}/setLabels"
|
|
|
|
|
]).format(**module.params),
|
|
|
|
|
{
|
|
|
|
|
u'labels': module.params.get('labels'),
|
|
|
|
|
u'labelFingerprint': response.get('labelFingerprint')
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def delete(module, link, kind):
|
|
|
|
|
@ -510,6 +551,7 @@ def resource_to_request(module):
|
|
|
|
|
u'family': module.params.get('family'),
|
|
|
|
|
u'guestOsFeatures': ImageGuestosfeaturesArray(module.params.get('guest_os_features', []), module).to_request(),
|
|
|
|
|
u'imageEncryptionKey': ImageImageencryptionkey(module.params.get('image_encryption_key', {}), module).to_request(),
|
|
|
|
|
u'labels': module.params.get('labels'),
|
|
|
|
|
u'licenses': module.params.get('licenses'),
|
|
|
|
|
u'name': module.params.get('name'),
|
|
|
|
|
u'rawDisk': ImageRawdisk(module.params.get('raw_disk', {}), module).to_request(),
|
|
|
|
|
@ -591,6 +633,8 @@ def response_to_hash(module, response):
|
|
|
|
|
u'guestOsFeatures': ImageGuestosfeaturesArray(response.get(u'guestOsFeatures', []), module).from_response(),
|
|
|
|
|
u'id': response.get(u'id'),
|
|
|
|
|
u'imageEncryptionKey': ImageImageencryptionkey(response.get(u'imageEncryptionKey', {}), module).from_response(),
|
|
|
|
|
u'labels': response.get(u'labels'),
|
|
|
|
|
u'labelFingerprint': response.get(u'labelFingerprint'),
|
|
|
|
|
u'licenses': response.get(u'licenses'),
|
|
|
|
|
u'name': response.get(u'name'),
|
|
|
|
|
u'rawDisk': ImageRawdisk(response.get(u'rawDisk', {}), module).from_response(),
|
|
|
|
|
|