audiolize / vagrant-softlayer

This is a Vagrant plugin that adds a SoftLayer provider to Vagrant, allowing Vagrant to control and provision SoftLayer CCI instances.
MIT License
42 stars 15 forks source link

Cannot specify image_guid #59

Open poflynn opened 9 years ago

poflynn commented 9 years ago

It seems when I try to specify a custom image, I get this error:

There are errors in the configuration of this machine. Please fix
the following errors and try again:

SoftLayer:
* The image guid for a compute or flex image and the operating
system reference code cannot be used at the same time.
Please use only one of the following options in the provider
section:

config.vm.provider :softlayer do |sl|
  sl.image_guid = "AAAAAAAA-BBBB-CCCC-DDDD-EEEEEEEEEEEE"
end

config.vm.provider :softlayer do |sl|
  sl.operating_system = "UBUNTU_LATEST"
end

I am not specifying an OS in my Vagrantfile. When I comment out my image_guid, and use an OS name instead, it works fine. I got the image GUID from the SL CLI tool. A small excerpt from my VagrantFile is below, let me know if it is too small.

    config.vm.provider :softlayer do |provider, override|
        override.vm.box = 'SoftLayer'  
        provider.box_url = 'http://xxxxx/softlayer/box/1.0/box-1.0.box'    
        provider.username = "xxxxx"
        provider.ssh_key  = "xxxxx"
        provider.api_key  = "xxxxx"
        provider.image_guid = "xxxxx"
        provider.datacenter = $vmdatacenter
        provider.domain = "xxxxx.com"
        provider.hostname = $vmhostname
        provider.api_timeout = 420
        provider.post_install = "https://xxxxx.com/repos/SoftLayer/softlayerPostInstall.sh"
        override.ssh.private_key_path = "~/.ssh/xxxxx.pem"
        override.ssh.pty = true
    end
ju2wheels commented 9 years ago

This should only kick up if image_guid and disk_capacity or operating_system are defined together. Did you add those settings to your box maybe and its inheriting the values from there?:

https://github.com/audiolize/vagrant-softlayer/blob/master/lib/vagrant-softlayer/config.rb#L258-L259

Reference the Load Order and Merging at the end of the Quck Start guide.

poflynn commented 9 years ago

Well, the image I created I fired up from their CentOS 5 image and immediately created an image from it (as a test). I included the default 25GB drive in it.

My .box contains one file only (metadata.json) and its contents are below.

{
    "provider": "softlayer"
}
ju2wheels commented 9 years ago

Does your box include its own Vagrantfile or have you configured a user Vagrantfile to load before the one shown above?

lonniev commented 9 years ago

Also, I found that I had to explicitly unset the competing parameters. Even though I did not set a OS value in the Vagrantfile with sl.operating_system, because I used some other services like winrm, the value was getting set for me. In addition to setting the image_guid parameter, I explicitly set operating_system to nil. Then it worked.

ju2wheels commented 9 years ago

Thats odd and that to me would definitely be a bug somewhere, when we initialize them its set to nil already so something else would definitely be doing it. If you use the public boxes we put up and try to use image_guid with those then those have a built in Vagrantfile that set operating_system and you would definitely need to overide the value with nil in that case or switch to the generic box.

poflynn commented 9 years ago

nil worked! Cool, thanks for the tip lonniev! (provider.operating_system = nil) I had previously tried "" as I noticed it seemed to be defaulting to "UBUNTU_LATEST" but I guess one needs to be more explicit than that. I would say that this is a bug as you shouldn't need to set OS to nil if you are setting the image_guid. Thanks all.

cromulus commented 9 years ago

same problem here.

Thanks!