Closed andrewelizondo closed 8 years ago
Hello @andrewelizondo
I've tried with knife-azure
v 1.5.2 and here's command-
knife azure server create -I 'b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu-12_04_5-LTS-amd64-server-20150127-en-us-30GB' -x azureuser -P azure@123 --bootstrap-protocol ssh -c ~/chef-repo\.chef\knife.rb --azure-service-location "West US" --ssh-port 2323 -VV
And XML generated:
<Deployment xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<Name>az-8ed7b8c0519a</Name>
<DeploymentSlot>Production</DeploymentSlot>
<Label>YXotOGVkN2I4YzA1MTlh</Label>
<RoleList>
<Role i:type="PersistentVMRole">
<RoleName>az-8ed7b8c0519a</RoleName>
<OsVersion i:nil="true"/>
<RoleType>PersistentVMRole</RoleType>
<ConfigurationSets>
<ConfigurationSet i:type="LinuxProvisioningConfigurationSet">
<ConfigurationSetType>LinuxProvisioningConfiguration</ConfigurationSetType>
<HostName>az-8ed7b8c0519a</HostName>
<UserName>azureuser</UserName>
<UserPassword>azure@123</UserPassword>
<DisableSshPasswordAuthentication>false</DisableSshPasswordAuthentication>
</ConfigurationSet>
<ConfigurationSet i:type="NetworkConfigurationSet">
<ConfigurationSetType>NetworkConfiguration</ConfigurationSetType>
<InputEndpoints>
<InputEndpoint>
<LocalPort>22</LocalPort>
<Name>SSH</Name>
<Port>2323</Port>
<Protocol>TCP</Protocol>
</InputEndpoint>
</InputEndpoints>
</ConfigurationSet>
</ConfigurationSets>
<Label>YXotOGVkN2I4YzA1MTlh</Label>
<OSVirtualHardDisk>
<DiskName>disk_bf95ae41-f10a-4636-8de9-28a79fd22c33</DiskName>
<MediaLink>http://storage.blob.core.windows.net/vhds/disk_bf95ae41-f10a-4636-8de9-28a79fd22c33.vhd</MediaLink>
<SourceImageName>b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu-12_04_5-LTS-amd64-server-20150127-en-us-30GB</SourceImageName>
</OSVirtualHardDisk>
<RoleSize>Small</RoleSize>
</Role>
</RoleList>
</Deployment>
Above command working fine for me! Please share the command that you tried? Thanks!
@siddheshwar-more that works fine, but you're explicitly specifying the ssh port.
We should be defaulting to 22 if the ssh port isn't provided so that azure doesn't complain when we give it an empty xml element, the resulting error if we aren't explicitly providing that value is incredibly challenging for a new user attempting to troubleshoot it and is not the desired user experience.
Here is the error that azure returns in this scenario.
InvalidXmlRequest : The request body's XML was invalid or not correctly specified.
@andrewelizondo
Yeah its working for me without specifying --ssh-port also, repeating that I'm using knife-azure
v1.5.2. Please confirm your knife-azure version and share command here!
I think below logic will take care what you are expecting https://github.com/chef/knife-azure/blob/1.5.2/lib/chef/knife/azure_server_create.rb#L878-L890
Thanks!
@siddheshwar-more I'm actually seeing the exact issue @andrewelizondo reported earlier, and I'm using knife-azure v1.5.2.
The command I'm running is:
knife azure server create -VV -E azure_qa --ssh-user 'ubuntu' --identity-file <path_to_pem> -I 'base_image' -m 'West US' -z 'Medium' -r 'role[role1],role[role2]' --azure-storage-account '<account>' -t '<path_to_bootstrap_template.rb>' --azure-network-name '<network>' --azure-publish-settings-file <path_to_publishsettings_file> --azure-dns-name '<dns_name>' --azure-connect-to-existing-dns --azure-vm-name '<vm_name>' --color
XML being sent:
<?xml version="1.0"?>
<PersistentVMRole xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<RoleName>vm_name</RoleName>
<OsVersion i:nil="true"/>
<RoleType>PersistentVMRole</RoleType>
<ConfigurationSets>
<ConfigurationSet i:type="LinuxProvisioningConfigurationSet">
<ConfigurationSetType>LinuxProvisioningConfiguration</ConfigurationSetType>
<HostName>host_name</HostName>
<UserName>ubuntu</UserName>
<DisableSshPasswordAuthentication>true</DisableSshPasswordAuthentication>
<SSH>
<PublicKeys>
<PublicKey>
<Fingerprint>fingerprint</Fingerprint>
<Path>/home/ubuntu/.ssh/authorized_keys</Path>
</PublicKey>
</PublicKeys>
</SSH>
</ConfigurationSet>
<ConfigurationSet i:type="NetworkConfigurationSet">
<ConfigurationSetType>NetworkConfiguration</ConfigurationSetType>
<InputEndpoints>
<InputEndpoint>
<LocalPort>22</LocalPort>
<Name>SSH</Name>
<Port/>
<Protocol>TCP</Protocol>
</InputEndpoint>
</InputEndpoints>
</ConfigurationSet>
</ConfigurationSets>
<Label>label</Label>
<OSVirtualHardDisk>
<DiskName>disk_name</DiskName>
<MediaLink>media_link</MediaLink>
<SourceImageName>image_name</SourceImageName>
</OSVirtualHardDisk>
<RoleSize>Small</RoleSize>
</PersistentVMRole>
As you can see, the SSH port appears to be malformed XML, because it's missing the port.
Note that I've replaced sensitive information with descriptive text, in both the XML and the knife command.
Any suggestions would be very welcome. Thanks!
Working on this issue https://github.com/chef/knife-azure/issues/262.
Issue is that the default bootstrap_protocol
is winrm
and it gets reset to ssh
for linux VMs after this is executed.
ssh
port gets reset here https://github.com/chef/knife-azure/blob/1.5.2/lib/chef/knife/azure_server_create.rb#L934
@andrewelizondo , @kpkrishnamoorthy , Fixed and merged the fix in master branch here https://github.com/chef/knife-azure/pull/262. Please follow these steps to verify it on master branch:
$ gem uninstall 'knife-azure'
$ git clone https://github.com/chef/knife-azure
$ cd knife-azure
$ gem build knife-azure.gemspec
$ gem install ./knife-azure-1.5.0.gem #version number may vary
When trying to bootstrap a base linux box I found a bug where the port isn't properly getting passed into the generated xml when creating the ssh endpoint, causing azure to complain about not liking the generated xml. The problem appears to be that
params[:port]
isn't available when we attempt to inject it here