{"id":348,"date":"2018-02-12T11:50:17","date_gmt":"2018-02-12T11:50:17","guid":{"rendered":"https:\/\/www.philroche.net\/?p=348"},"modified":"2018-05-15T23:03:55","modified_gmt":"2018-05-15T22:03:55","slug":"ubuntu-cloud-images-and-how-to-find-the-most-recent-cloud-image-part-1-of-3","status":"publish","type":"post","link":"http:\/\/wp.philroche.net\/2018\/02\/12\/ubuntu-cloud-images-and-how-to-find-the-most-recent-cloud-image-part-1-of-3\/","title":{"rendered":"Ubuntu cloud images and how to find the most recent cloud image – part 1\/3"},"content":{"rendered":"

TLDR;<\/strong><\/p>\n

sstream-query --json --max=1 --keyring=\/usr\/share\/keyrings\/ubuntu-cloudimage-keyring.gpg http:\/\/cloud-images.ubuntu.com\/releases\/streams\/v1\/com.ubuntu.cloud:released:download.sjson arch=amd64 release_codename='Xenial Xerus' ftype='disk1.img' | jq -r '.[].item_url'<\/pre>\n

This will show you the URL for the most recent Ubuntu 16.04 Xenial cloud image in QCOW format.<\/p>\n


\n

Part one of a three part series<\/a>.<\/p>\n

There are a few ways to find the most recent Ubuntu cloud image an the simplest method is to view the release page<\/a>\u00a0which lists the most recent release.<\/span><\/p>\n

Another method is to use the cloud image simple streams data<\/a> which we also update every time we (I work on the Certified Public Cloud team @ Canonical)<\/a> publish an image.<\/p>\n

We publish simple streams data for major public clouds too but this post deals with the base Ubuntu cloud image. I will follow up this post with details on how to use the cloud specific streams data.<\/p>\n

Simple streams<\/strong><\/p>\n

Simple streams is a structured format describing the Ubuntu cloud image releases.<\/p>\n

You can parse the Ubuntu’s release cloud image stream json<\/a>\u00a0yourself or you can use a combination of sstream-query and jq (install packages “ubuntu-cloudimage-keyring<\/a>“, “simplestreams<\/a>” and “jq<\/a>“) to get all or specific data about the most recent release.<\/p>\n

Query all data from most recent release<\/em><\/p>\n

sstream-query --json --max=1 --keyring=\/usr\/share\/keyrings\/ubuntu-cloudimage-keyring.gpg http:\/\/cloud-images.ubuntu.com\/releases\/ arch=amd64 release='xenial' ftype='disk1.img'<\/pre>\n

This will return all data on the release including date released and also the checksums of the file.<\/p>\n

[\r\n {\r\n \"aliases\": \"16.04,default,lts,x,xenial\",\r\n \"arch\": \"amd64\",\r\n \"content_id\": \"com.ubuntu.cloud:released:download\",\r\n \"datatype\": \"image-downloads\",\r\n \"format\": \"products:1.0\",\r\n \"ftype\": \"disk1.img\",\r\n \"item_name\": \"disk1.img\",\r\n \"item_url\": \"http:\/\/cloud-images.ubuntu.com\/releases\/server\/releases\/xenial\/release-20180126\/ubuntu-16.04-server-cloudimg-amd64-disk1.img\",\r\n \"label\": \"release\",\r\n \"license\": \"http:\/\/www.canonical.com\/intellectual-property-policy\",\r\n \"md5\": \"9cb8ed487ad8fbc8b7d082968915c4fd\",\r\n \"os\": \"ubuntu\",\r\n \"path\": \"server\/releases\/xenial\/release-20180126\/ubuntu-16.04-server-cloudimg-amd64-disk1.img\",\r\n \"product_name\": \"com.ubuntu.cloud:server:16.04:amd64\",\r\n \"pubname\": \"ubuntu-xenial-16.04-amd64-server-20180126\",\r\n \"release\": \"xenial\",\r\n \"release_codename\": \"Xenial Xerus\",\r\n \"release_title\": \"16.04 LTS\",\r\n \"sha256\": \"da7a59cbaf43eaaa83ded0b0588bdcee4e722d9355bd6b9bfddd01b2e7e372e2\",\r\n \"size\": \"289603584\",\r\n \"support_eol\": \"2021-04-21\",\r\n \"supported\": \"True\",\r\n \"updated\": \"Wed, 07 Feb 2018 03:58:59 +0000\",\r\n \"version\": \"16.04\",\r\n \"version_name\": \"20180126\"\r\n }\r\n ]<\/pre>\n

Query only the url to the most recent release<\/em><\/p>\n

sstream-query --json --max=1 --keyring=\/usr\/share\/keyrings\/ubuntu-cloudimage-keyring.gpg http:\/\/cloud-images.ubuntu.com\/releases\/streams\/v1\/com.ubuntu.cloud:released:download.sjson arch=amd64 release_codename='Xenial Xerus' ftype='disk1.img' | jq -r '.[].item_url'<\/pre>\n

This will show you the URL for the most recent Ubuntu 16.04 Xenial cloud image in QCOW format.<\/p>\n

\"http:\/\/cloud-images.ubuntu.com\/releases\/server\/releases\/xenial\/release-20180126\/ubuntu-16.04-server-cloudimg-amd64-disk1.img\"<\/pre>\n

Query only the serial of the most recent release<\/em><\/p>\n

sstream-query --json --max=1 --keyring=\/usr\/share\/keyrings\/ubuntu-cloudimage-keyring.gpg http:\/\/cloud-images.ubuntu.com\/releases\/ arch=amd64 release_codename='Xenial Xerus' ftype='disk1.img' | jq \".[].version_name\"<\/pre>\n

This will show you the serial of the most recent Ubuntu 16.04 Xenial cloud image.<\/p>\n

\"20180126\"<\/pre>\n

The above streams are signed using keys in the ubuntu-cloudimage-keyring keyring but you can replace the –keyring option with –no-verify to bypass any signing checks. Another way to bypass the checks is to to use the unsigned streams<\/a>.<\/p>\n

It is also worth noting that OpenStack can be configured to use streams too.<\/p>\n

I hope the above is helpful with your automation.<\/p>\n","protected":false},"excerpt":{"rendered":"

TLDR; sstream-query –json –max=1 –keyring=\/usr\/share\/keyrings\/ubuntu-cloudimage-keyring.gpg http:\/\/cloud-images.ubuntu.com\/releases\/streams\/v1\/com.ubuntu.cloud:released:download.sjson arch=amd64 release_codename=’Xenial Xerus’ ftype=’disk1.img’ | jq -r ‘.[].item_url’ This will show you the URL for the most recent Ubuntu 16.04 Xenial cloud image in QCOW format. Part one of a three part series. There are a few ways to find the most recent Ubuntu cloud image an the simplest […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[13,19],"tags":[],"_links":{"self":[{"href":"http:\/\/wp.philroche.net\/wp-json\/wp\/v2\/posts\/348"}],"collection":[{"href":"http:\/\/wp.philroche.net\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/wp.philroche.net\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/wp.philroche.net\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/wp.philroche.net\/wp-json\/wp\/v2\/comments?post=348"}],"version-history":[{"count":3,"href":"http:\/\/wp.philroche.net\/wp-json\/wp\/v2\/posts\/348\/revisions"}],"predecessor-version":[{"id":360,"href":"http:\/\/wp.philroche.net\/wp-json\/wp\/v2\/posts\/348\/revisions\/360"}],"wp:attachment":[{"href":"http:\/\/wp.philroche.net\/wp-json\/wp\/v2\/media?parent=348"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/wp.philroche.net\/wp-json\/wp\/v2\/categories?post=348"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/wp.philroche.net\/wp-json\/wp\/v2\/tags?post=348"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}