Create a FreeBSD GCE instance with salt-cloud

April 16, 2016

When creating a Google Compute Engine instance from a publicly shared image which is not in your own project nor one of the default projects – such as FreeBSD – the image-project can be specified on the gcloud command line. Here’s how to do the same when using salt-cloud instead of gcloud:

  • Assuming we have a working command line such as this:
    gcloud compute instances create my-freebsd-host --image freebsd-10-3-release-amd64 --image-project=freebsd-org-cloud-dev
  • First we have to find the URI of the public image:
    gcloud compute images list --project freebsd-org-cloud-dev --uri --regexp freebsd-10-3-release-amd64
    …which gives the following URI in this case:
  • Now the URI can be used in a salt-cloud profile instead of the image name, for example:
    sudo nano /etc/salt/cloud.profiles.d/my-freebsd-host.conf

      image: ""
      size: n1-standard-2
      location: europe-west1-b
      network: default
      provider: gce
      ssh_username: freebsd

    Note to self: remember to escape the URI string using quotation marks ;-)

When an instance is created from an image using either gcloud compute instance create or salt-cloud -p profile create, both utilities search for the image in the same project as the instance as well as the “well-known image projects”, which are “centos-cloud, coreos-cloud, debian-cloud, google-containers, opensuse-cloud, rhel-cloud, suse-cloud, ubuntu-os-cloud, windows-cloud”. gcloud let’s you use images from other projects by specifying the --image-project parameter, while salt-cloud does not (presumably because libcloud does not support it either, this Apache library is used by salt-cloud under the hood). However, by using gcloud to find the URI of the public image we want to use, we can get salt-cloud to use any publicly available image for our instances.

Kudos to Agam for pointing me at the freebsd-org-cloud-dev image repository in the first place.

flattr this!

Previous post:

Next post: