| { | |
| "Name": "build-image", | |
| "Vars": { | |
| "source_image": {"Required": true, "Description": "URL of the source image to preload."}, | |
| "output_image_name": {"Required": true, "Description": "Name of output image."}, | |
| "output_image_family": {"Value": "", "Description": "Family of output image."}, | |
| "output_image_project": {"Required": true, "Description": "Project of output image."}, | |
| "cidata_img": {"Required": true, "Description": "Path to CIDATA vfat image containing cloud-init user-data and the provisioner program. Must be in .tar.gz format."}, | |
| "scratch_img": {"Required": true, "Description": "Path to SCRATCH ext4 image. Must be in .tar.gz format."}, | |
| "disk_type": {"Value": "pd-standard", "Description": "The disk type to use for preloading."}, | |
| "disk_size_gb": {"Value": "", "Description": "The disk size to use for preloading."}, | |
| "host_maintenance": {"Value": "MIGRATE", "Description": "VM behavior when there is maintenance."}, | |
| "machine_type": {"Required": true, "Description": "Machine type of the preload VM."}, | |
| "network": {"Value": "", "Description": "Network to use for preload VM."}, | |
| "subnet": {"Value": "", "Description": "Subnetwork used for the preload VM."}, | |
| "service_account": {"Value": "default", "Description": "Service account used for the preload VM."} | |
| }, | |
| "Sources": { | |
| "cloud-config": "/data/startup.yaml", | |
| "scratch.tar.gz_": "${scratch_img}", | |
| "cidata.tar.gz_": "${cidata_img}" | |
| }, | |
| "Steps": { | |
| "copy-gcs": { | |
| "CopyGCSObjects": [ | |
| { | |
| "Source": "${SOURCESPATH}/cidata.tar.gz_", | |
| "Destination": "${SOURCESPATH}/cidata.tar.gz" | |
| }, | |
| { | |
| "Source": "${SOURCESPATH}/scratch.tar.gz_", | |
| "Destination": "${SOURCESPATH}/scratch.tar.gz" | |
| } | |
| ] | |
| }, | |
| "create-images": { | |
| "CreateImages": [ | |
| { | |
| "Name": "cidata", | |
| "RawDisk": { | |
| "Source": "${SOURCESPATH}/cidata.tar.gz" | |
| } | |
| }, | |
| { | |
| "Name": "scratch", | |
| "RawDisk": { | |
| "Source": "${SOURCESPATH}/scratch.tar.gz" | |
| } | |
| } | |
| ] | |
| }, | |
| "setup": { | |
| "CreateDisks": [ | |
| {{.ScratchDisks}} | |
| { | |
| "Name": "boot-disk", | |
| "SourceImage": "${source_image}", | |
| "Type": "${disk_type}", | |
| "SizeGb": "${disk_size_gb}" | |
| }, | |
| { | |
| "Name": "cidata-disk", | |
| "SourceImage": "cidata", | |
| "Type": "${disk_type}" | |
| } | |
| ] | |
| }, | |
| "run": { | |
| "CreateInstances": [ | |
| { | |
| "Name": "preload-vm", | |
| "Disks": [{"Source": "boot-disk"}, {{.ScratchDiskSource}} {"Source": "cidata-disk"}], | |
| "Labels": {"cos-customizer-cleanup":""}, | |
| "ServiceAccounts":[{ | |
| "Email": "${service_account}", | |
| "Scopes": ["https://www.googleapis.com/auth/cloud-platform","https://www.googleapis.com/auth/devstorage.read_write"] | |
| }], | |
| "MachineType": "${machine_type}", | |
| "guestAccelerators": {{.Accelerators}}, | |
| "scheduling": { | |
| "onHostMaintenance": "${host_maintenance}" | |
| }, | |
| "networkInterfaces": [ | |
| { | |
| "network": "${network}", | |
| "subnetwork": "${subnet}" | |
| } | |
| ], | |
| "Metadata": {{.InstanceMetadata}}, | |
| "Scopes": [ | |
| "https://www.googleapis.com/auth/devstorage.read_write", | |
| "https://www.googleapis.com/auth/cloud-platform" | |
| ] | |
| } | |
| ] | |
| }, | |
| "wait-preload-finished": { | |
| "WaitForInstancesSignal": [ | |
| { | |
| "Name": "preload-vm", | |
| "Interval": "30s", | |
| "SerialOutput": { | |
| "Port": 3, | |
| "FailureMatch": "BuildFailed:", | |
| "SuccessMatch": "BuildSucceeded:", | |
| "StatusMatch": "BuildStatus:" | |
| } | |
| } | |
| ] | |
| }, | |
| "send-logging-end-msg": { | |
| "UpdateInstancesMetadata": [ | |
| { | |
| "Instance": "preload-vm", | |
| "Metadata": { | |
| "DaisyEnd": "ack" | |
| } | |
| } | |
| ] | |
| }, | |
| "wait-vm-shutdown": { | |
| "WaitForInstancesSignal": [ | |
| { | |
| "Name": "preload-vm", | |
| "Interval": "2s", | |
| "Stopped": true | |
| } | |
| ] | |
| }, | |
| "wait-for-resize": { | |
| {{.WaitResize}} | |
| }, | |
| "resize-disk": { | |
| {{.ResizeDisks}} | |
| }, | |
| "image": { | |
| "CreateImages": [ | |
| { | |
| "RealName": "${output_image_name}", | |
| "Project": "${output_image_project}", | |
| "NoCleanup": true, | |
| "SourceDisk": "boot-disk", | |
| "labels": {{.Labels}}, | |
| "description": "Derivative of ${source_image}.", | |
| "family": "${output_image_family}", | |
| "IgnoreLicenseValidationIfForbidden": true, | |
| "licenses": {{.Licenses}} | |
| } | |
| ] | |
| } | |
| }, | |
| "Dependencies": { | |
| "create-images" : ["copy-gcs"], | |
| "setup": ["create-images"], | |
| "run": ["setup"], | |
| "wait-preload-finished": ["run"], | |
| "wait-for-resize": ["run"], | |
| "resize-disk": ["wait-for-resize"], | |
| "send-logging-end-msg": ["wait-preload-finished", "resize-disk"], | |
| "wait-vm-shutdown": ["send-logging-end-msg"], | |
| "image": ["wait-vm-shutdown"] | |
| } | |
| } |