Facter contains GCE (Google Compute Engine) metadata details:
$ facter | grep gce
gce => {"instance"=>{"attributes"=>{}, "description"=>"", "disks"=>[{"deviceName"=>"srvpup01", "index"=>0, "mode"=>"READ_WRITE", "type"=>"PERSISTENT"}, {"deviceName"=>"srvpup01-storage01", "index"=>1, "mode"=>"READ_WRITE", "type"=>"PERSISTENT"}], "hostname"=>"srvpup01.c.example.internal", "id"=>12345, "image"=>nil, "licenses"=>[{"id"=>"1000010"}], "machineType"=>"n1-standard-1", "maintenanceEvent"=>"NONE", "networkInterfaces"=>[{"accessConfigs"=>[{"externalIp"=>"", "type"=>"ONE_TO_ONE_NAT"}], "forwardedIps"=>[], "ip"=>"123.456.789.123", "ipAliases"=>[], "mac"=>"00:11:22:33:44:55", "network"=>"example"}], "scheduling"=>{"automaticRestart"=>"TRUE", "onHostMaintenance"=>"MIGRATE", "preemptible"=>"FALSE"}, "serviceAccounts"=>{"12345-compute@developer.gserviceaccount.com"=>{"aliases"=>["default"], "email"=>"12345-compute@developer.gserviceaccount.com", "scopes"=>["xxx"]}, "default"=>{"aliases"=>["default"], "email"=>"12345-compute@developer.gserviceaccount.com", "scopes"=>["xxx"]}}, "tags"=>["no-public-ip"], "zone"=>"europe-west1-d"}, "project"=>{"attributes"=>{"google-compute-default-region"=>"europe-west1", "google-compute-default-zone"=>"europe-west1-d", "sshKeys"=>["...
Is there any easy way accessing like for example the "zone" attribute from within a puppet module or do I have to parse that string by myself?
Accessing it like a hash fails:
gce is not a hash or array