chef-boneyard / knife-rackspace

Chef knife plug-in for Rackspace
https://github.com/chef/knife-rackspace
Apache License 2.0
153 stars 114 forks source link

Unable to create instance with knife. #94

Open fuel-wlightning opened 9 years ago

fuel-wlightning commented 9 years ago

Starting from a blank CentOS 7 (PVHVM 512MB Standard Instance)

ssh -l root serverip yum groupinstall 'Development Tools' yum install ruby ruby-devel libxml2 libxml2-devel gem install chef gem install knife-rackspace adduser knifeuser su - knifeuser mkdir .chef chmod 700 .chef cat << EOF > ~/.chef/knife.rb knife[:rackspace_api_username] = "apiuser" knife[:rackspace_api_key] = "apikey" knife[:rackspace_region] = "DFW" EOF

knife rackspace server create -VV -I 8aac6fb5-4bd3-4256-bf6e-ff8500bf60cd

To which I get the output of: INFO: Using configuration from /home/knifeuser/.chef/knife.rb DEBUG: version (config) DEBUG: version v2 (cli) DEBUG: rackspace_api_key apikey DEBUG: rackspace_username DEBUG: rackspace_api_username apiuser DEBUG: rackspace_auth_url DEBUG: rackspace_auth_url DEBUG: rackspace_auth_url https://identity.api.rackspacecloud.com/v2.0 (using) DEBUG: rackspace_region DFW DEBUG: rackspace_region DFW DEBUG: rackspace v2 DEBUG: https_proxy (config) DEBUG: http_proxy (config) DEBUG: using proxy (config) DEBUG: ssl_verify_peer (config) Instance ID: a75bc74f-3930-4ac8-9d6f-ff48a503a5ec Name: rs-00203265389326035 /usr/local/share/gems/gems/fog-1.27.0/lib/fog/rackspace/core.rb:145:in escape': undefined methodgsub' for 2:Fixnum (NoMethodError) from /usr/local/share/gems/gems/fog-1.27.0/lib/fog/rackspace/requests/compute_v2/get_flavor.rb:26:in get_flavor' from /usr/local/share/gems/gems/fog-1.27.0/lib/fog/rackspace/models/compute_v2/flavors.rb:31:inget' from /usr/local/share/gems/gems/fog-1.27.0/lib/fog/rackspace/models/compute_v2/server.rb:327:in flavor' from /usr/local/share/gems/gems/knife-rackspace-0.10.0/lib/chef/knife/rackspace_server_create.rb:379:inrun' from /usr/local/share/gems/gems/chef-12.0.3/lib/chef/knife.rb:417:in block in run_with_pretty_exceptions' from /usr/local/share/gems/gems/chef-12.0.3/lib/chef/local_mode.rb:38:inwith_server_connectivity' from /usr/local/share/gems/gems/chef-12.0.3/lib/chef/knife.rb:416:in run_with_pretty_exceptions' from /usr/local/share/gems/gems/chef-12.0.3/lib/chef/knife.rb:213:inrun' from /usr/local/share/gems/gems/chef-12.0.3/lib/chef/application/knife.rb:139:in run' from /usr/local/share/gems/gems/chef-12.0.3/bin/knife:25:in<top (required)>'

▽ from /usr/local/bin/knife:23:in load' from /usr/local/bin/knife:23:in

'

jjasghar commented 9 years ago

This is throwing an error here: https://github.com/fog/fog/blob/master/lib/fog/rackspace/core.rb#L145

It looks like fog.io updated this recently too. I'm betting the issue lies with fog not this gem. But i'd like someone else to reconfirm this.

fuel-wlightning commented 9 years ago

I've begun testing it by downgrading fog then removing the newer version (so it would stop using it) So far I've recreated the issue on: fog versions: 1.27.0 1.26.0 1.25.0 1.24.0

Last error I saw: /usr/local/share/gems/gems/fog-1.24.0/lib/fog/rackspace/core.rb:141:in escape': undefined methodgsub' for 2:Fixnum (NoMethodError)

This would be easier if I had a version number to test against. Any idea when the change came out?

fuel-wlightning commented 9 years ago

Utilizing fog I am able to create a machine:

server = Compute.new({:provider => 'rackspace', :rackspace_region => :dfw}).servers.create({:name => "Test Fog Instance", :flavor_id => 2, :image_id => "8aac6fb5-4bd3-4256-bf6e-ff8500bf60cd" })

maxlinc commented 9 years ago

It looks like it's an issue w/ passing the flavor ID as an integer vs a string, which makes it interesting that you can do it directly in fog w/ :flavor_id => 2 rather than :flavor_id => "2".

However, before you go any further you might want to take a look at the list of supported server flavors. In case you're not aware, flavor ID "2" (for "512 MB Standard Instance") is "being phased out and should not be used for new servers". I recommend updating to the smallest general flavor: "general1-1", a "1 GB General Purpose v1".

@jjasghar actually I see this is coming from a default value in this gem, so it probably makes sense to change the default value at https://github.com/chef/knife-rackspace/blob/c05cf2161bac8a010238e7d4fe7b492d0c760989/lib/chef/knife/rackspace_server_create.rb#L49 from 2 to "general1-1".

fuel-wlightning commented 9 years ago

I can confirm: The following commands get past the error above using rackspace-knife(0.10.0) and fog(1.27.0): [wlightning@test-management-server ~]$ knife rackspace server create -f 2 -I 8aac6fb5-4bd3-4256-bf6e-ff8500bf60cd Instance ID: 7de55efa-3a5e-4777-8c15-d7d8dff0f4d1 Name: ..removed.. Flavor: 512MB Standard Instance Image: CentOS 6 (PVHVM) Metadata: [] ConfigDrive: false RackConnect Wait: no ServiceLevel Wait: no .................................................Metadata: []

Waiting server Public DNS Name: ..removed... Public IP Address: ..removed.. Private IP Address: ..removed.. Password: ..removed.. Metadata: []

Waiting for sshddone Connecting to ..removed.. ERROR: Errno::ENOENT: No such file or directory - /etc/chef/validation.pem [wlightning@test-management-server ~]$

This appears to be purely a problem with the default behavior. I also successfully passed a -f "2". This purely seems to be an issue when no flavor id is passed.