mitchellh / vagrant-google

Vagrant provider for GCE.
Apache License 2.0
334 stars 100 forks source link

Can't Supply Host Network #230

Closed dgarstang closed 4 years ago

dgarstang commented 4 years ago

Using this Vagrantfile:

Vagrant.configure("2") do |config|
  config.vm.box = "google/gce"
  config.vm.provider :google do |google, override|
    google.google_project_id = "company-user-dgarstang"
    google.network_project_id = "company-vpc-sandbox"
    google.subnetwork = "http://www.googleapis.com/compute/v1/projects/company-vpc-sandbox/regions/us-west1/subnetworks/default-us-west1"
    google.network = "default"
    google.google_json_key_location = "/Users/dgarstang/git/puppet-integration-image/company-user-dgarstang-21dbe490a8d8.json"
    google.image_family = 'puppetint'
    google.zone = "us-west1-a"
    override.ssh.username = "dgarstang"
    override.ssh.private_key_path = "~/.ssh/id_rsa"
  end
end

this plugin is responding with:

==> default: Checking if box 'google/gce' version '0.1.0' is up to date...
==> default: Launching an instance with the following settings...
==> default:  -- Name:            i-2020013015-7585e718
==> default:  -- Project:         company-user-dgarstang
==> default:  -- Type:            n1-standard-1
==> default:  -- Disk type:       pd-standard
==> default:  -- Disk size:       10 GB
==> default:  -- Disk name:
==> default:  -- Image:
==> default:  -- Image family:    puppetint
==> default:  -- Instance Group:
==> default:  -- Zone:            us-west1-a
==> default:  -- Network:         default
==> default:  -- Network Project: company-vpc-sandbox
==> default:  -- Subnetwork:      http://www.googleapis.com/compute/v1/projects/company-vpc-sandbox/regions/us-west1/subnetworks/default-us-west1
==> default:  -- Metadata:        '{}'
==> default:  -- Labels:          '{}'
==> default:  -- Network tags:    '[]'
==> default:  -- IP Forward:
==> default:  -- Use private IP:  false
==> default:  -- External IP:
==> default:  -- Network IP:
==> default:  -- Preemptible:     false
==> default:  -- Auto Restart:    true
==> default:  -- On Maintenance:  MIGRATE
==> default:  -- Autodelete Disk: true
==> default:  -- Additional Disks:[]
/Users/dgarstang/.vagrant.d/gems/2.4.9/gems/google-api-client-0.23.9/lib/google/apis/core/http_command.rb:218:in `check_status': invalid: Invalid value for field 'resource.networkInterfaces[0]': '{  "network": "global/networks/default",  "accessConfig": [{    "type": "ONE_TO_ONE_NAT",    "name":...'. Subnetwork does not belong to the network. (Google::Apis::ClientError)

Without a full url passed to 'network', it seems to think 'network' is 'global/networks/default'. If I pass in the full URL for the network, ie:

google.network = "https://www.googleapis.com/compute/v1/projects/company-vpc-sandbox/global/networks/default"

I then get:

/Users/dgarstang/.vagrant.d/gems/2.4.9/gems/google-api-client-0.23.9/lib/google/apis/core/http_command.rb:218:in `check_status': invalid: Invalid value for field 'resource.networkInterfaces[0].network': 'projects/company-vpc-sandbox/global/networks/https://www.googleapis.com/compute/v1/projects/company-vpc-sandbox/global/networks/default'. The URL is malformed. (Google::Apis::ClientError)

Ok, it's doing some weird string concatention there. Seems it wants only part of the URL. Looks like it's prefixing "projects/company-vpc-sandbox/global/networks" to the beginning anyway.... which leaves only ...."default".... which is what I had before when it tried to use "global/networks/default".

What does it want for a network here?!

dgarstang commented 4 years ago

NA