schubergphilis / vagrant-chef-zero

Vagrant Plugin for Chef Zero
Apache License 2.0
91 stars 42 forks source link

The method env_helpers.get_port() can't handle trailing slash in chef_server_url #69

Closed adrian closed 8 years ago

adrian commented 9 years ago

Given this code,

    node.vm.provision :chef_client do |chef|
      chef.chef_server_url = "https://10.0.0.4:4443/"
      chef.validation_key_path = "validation.pem"
      chef.add_role "web-server"
      chef.environment = "dev"
    end

The chef provisioning step will fail with,

    /Users/adrian.smith/.vagrant.d/gems/gems/vagrant-chef-zero-0.7.1/lib/vagrant-chef-zero/server_helpers.rb:95:in `initialize': getaddrinfo: nodename nor servname provided, or not known (SocketError)
    from /Users/adrian.smith/.vagrant.d/gems/gems/vagrant-chef-zero-0.7.1/lib/vagrant-chef-zero/server_helpers.rb:95:in `new'
    from /Users/adrian.smith/.vagrant.d/gems/gems/vagrant-chef-zero-0.7.1/lib/vagrant-chef-zero/server_helpers.rb:95:in `port_open?'
    from /Users/adrian.smith/.vagrant.d/gems/gems/vagrant-chef-zero-0.7.1/lib/vagrant-chef-zero/server_helpers.rb:73:in `block in chef_zero_server_running?'

The cause of the problem is in env_helpers.get_port(). The parsing code doesn't strip the trailing slash. In the example above it would try to connect to the port '4443/'.

Note: The trailing slash isn't a problem for the regular chef provisioner.

miguelaferreira commented 8 years ago

@adrian

First-off , sorry for the late reply.

May I ask why are you setting the chef_server_url and validation_key_path? Those attributes are set by the plugin in the .zero-knife.rb file that gets generated when you do vagrant up.