From b62580df0a90c3131abb30f631b6aca8f987f2de Mon Sep 17 00:00:00 2001 From: Jake Spain Date: Fri, 15 Apr 2022 08:25:31 -0400 Subject: [PATCH] Set hostname for instance during create_vm This sets the instance hostname to the configured domain according to https://cloud.google.com/compute/docs/instances/custom-hostname-vm#api and https://googleapis.dev/ruby/google-api-client/latest/Google/Apis/ComputeV1/Instance.html#hostname-instance_method --- lib/vmpooler/providers/gce.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/vmpooler/providers/gce.rb b/lib/vmpooler/providers/gce.rb index 3aa965e..7df7426 100644 --- a/lib/vmpooler/providers/gce.rb +++ b/lib/vmpooler/providers/gce.rb @@ -191,9 +191,13 @@ module Vmpooler boot: true, initialize_params: Google::Apis::ComputeV1::AttachedDiskInitializeParams.new(init_params) ) + append_domain = domain || global_config[:config]['domain'] + fqdn = "#{new_vmname}.#{append_domain}" if append_domain + # Assume all pool config is valid i.e. not missing client = ::Google::Apis::ComputeV1::Instance.new( name: new_vmname, + hostname: fqdn, machine_type: pool['machine_type'], disks: [disk], network_interfaces: [network_interfaces],