diff options
| -rw-r--r-- | awwan.env | 9 | ||||
| -rw-r--r-- | gcloud-image-publish.aww | 27 | ||||
| -rw-r--r-- | gcloud-image-test.aww | 30 | ||||
| -rw-r--r-- | gcloud-test-image-official.aww | 17 | ||||
| -rw-r--r-- | gcloud-test-tail.aww | 4 |
5 files changed, 87 insertions, 0 deletions
diff --git a/awwan.env b/awwan.env new file mode 100644 index 0000000..5de47e5 --- /dev/null +++ b/awwan.env @@ -0,0 +1,9 @@ +[gcloud] +config = arch-builder +project = arch-build +region = asia-southeast1 +zone = asia-southeast1-b + +[host] +image = arch-v20220701 +name = arch-test diff --git a/gcloud-image-publish.aww b/gcloud-image-publish.aww new file mode 100644 index 0000000..d16e0f8 --- /dev/null +++ b/gcloud-image-publish.aww @@ -0,0 +1,27 @@ +## Script to publish builded image to public. + +#require: gcloud config configurations activate {{.Val "gcloud::config"}} + +gsutil cp {{.Val "host::image"}}.tar.gz gs://arch-builder-a/image/ + +gcloud compute images delete {{.Val "host::image"}} --quiet || exit 0 + +gcloud compute images create {{.Val "host::image"}} \ + --source-uri=gs://arch-builder-a/image/{{.Val "host::image"}}.tar.gz \ + --family=arch \ + --guest-os-features=GVNIC,UEFI_COMPATIBLE,VIRTIO_SCSI_MULTIQUEUE \ + --description="Arch linux image with ops-agent. See https://github.com/shuLhan/compute-archlinux-image-builder" + +gcloud compute images list --no-standard-images +gcloud compute images describe {{.Val "host::image"}} + +## Share the image publicly with authenticated users. + +gcloud compute images add-iam-policy-binding {{.Val "host::image"}} \ + --member='allAuthenticatedUsers' \ + --role='roles/compute.imageUser' + +## Delete the image on storage. + +gsutil rm -a gs://arch-builder-a/image/** +gsutil ls gs://arch-builder-a/ diff --git a/gcloud-image-test.aww b/gcloud-image-test.aww new file mode 100644 index 0000000..218dae7 --- /dev/null +++ b/gcloud-image-test.aww @@ -0,0 +1,30 @@ +## Script to test the published image manually by creating new compute +## instance. + +#require: gcloud config configurations activate {{.Val "gcloud::config"}} + +gcloud compute instances create arch-test \ + --zone={{.Val "gcloud::zone"}} \ + --image={{.Val "host::image"}} \ + --metadata=block-project-ssh-keys=TRUE \ + --machine-type=f1-micro + +gcloud compute instances describe arch-test \ + --zone={{.Val "gcloud::zone"}} + +gcloud compute instances tail-serial-port-output {{.Val "host::name"}} \ + --zone={{.Val "gcloud::zone"}} \ + +gcloud compute ssh \ + --zone={{.Val "gcloud::zone"}} \ + --command="lsblk -o NAME,UUID,MOUNTPOINTS; cat /etc/fstab; timedatectl show-timesync; localectl" \ + arch-test + +##---- Cleaning up. + +gcloud compute instances stop arch-test \ + --zone={{.Val "gcloud::zone"}} + +gcloud compute instances delete arch-test \ + --zone={{.Val "gcloud::zone"}} \ + --quiet diff --git a/gcloud-test-image-official.aww b/gcloud-test-image-official.aww new file mode 100644 index 0000000..3e464af --- /dev/null +++ b/gcloud-test-image-official.aww @@ -0,0 +1,17 @@ +## Script to test the official public image. + +#require: gcloud config configurations activate {{.Val "gcloud::config"}} + +gcloud compute instances create arch-test \ + --zone={{.Val "gcloud::zone"}} \ + --image-project=arch-linux-gce \ + --image-family=arch \ + --machine-type=f1-micro + +gcloud compute instances describe arch-test \ + --zone={{.Val "gcloud::zone"}} + +gcloud compute ssh \ + --zone={{.Val "gcloud::zone"}} \ + --command="lsblk -o NAME,UUID,MOUNTPOINTS; cat /etc/fstab; timedatectl show-timesync; localectl" \ + arch-test diff --git a/gcloud-test-tail.aww b/gcloud-test-tail.aww new file mode 100644 index 0000000..c7dd93f --- /dev/null +++ b/gcloud-test-tail.aww @@ -0,0 +1,4 @@ +#require: gcloud config configurations activate {{.Val "gcloud::config"}} + +gcloud compute instances get-serial-port-output {{.Val "host::name"}} \ + --zone={{.Val "gcloud::zone"}} |
