saltstack / salt

Software to automate the management and configuration of any infrastructure or application at scale. Get access to the Salt software package repository here:
https://repo.saltproject.io/
Apache License 2.0
14.16k stars 5.48k forks source link

Azure: change the SSH port when creating other VMs under the same cloud service #19518

Closed flavianh closed 9 years ago

flavianh commented 9 years ago

Since the SSH port is hard coded to be 22 and the VM is accessed through the cloud service's DNS, creating another VM will result in a port conflict. We can either:

However, how will the master react to a non-22 SSH port when assigning a key?

           Salt: 2015.2.0-75-gea2b826
         Python: 2.7.6 (default, Mar 22 2014, 22:59:56)
         Jinja2: 2.7.3
       M2Crypto: 0.21.1
 msgpack-python: 0.4.3
   msgpack-pure: Not Installed
       pycrypto: 2.6.1
        libnacl: Not Installed
         PyYAML: 3.10
          ioflo: Not Installed
          PyZMQ: 14.4.1
           RAET: Not Installed
            ZMQ: 4.0.5
           Mako: Not Installed
techhat commented 9 years ago

@traxair, so much of the underlying code has configurable ports, I guess I just assumed that it was exposed to the user too. If you look at salt.utils.cloud, you'll see configurable ports everywhere.

The argument should be called port (for consistency, and because it may be used for either *nix or Windows), and it should be configurable from provider/profile/maps (vm_) or from the Cloud config (__opts__).

flavianh commented 9 years ago

I like the maps option. So basically if I call _vm.get("port", 22) I should be automatically fine?

techhat commented 9 years ago

@traxair, technically that will work, but what you really want to do is look at the config.get_cloud_config_value() examples scattered throughout Salt Cloud, since it looks through vm_ and __opts__.

flavianh commented 9 years ago

Yes I just found one for volumes config.get_cloud_config_value( 'volumes', vm_, __opts__, search_global=True )

techhat commented 9 years ago

Also, I see both port and local_port in msazure.py. You should probably do both, using those names.

flavianh commented 9 years ago

I'm not sure but if you change local_port to something other than 22 SSH won't like it

flavianh commented 9 years ago

I want to make sure of something. cloud.profiles.d/azure.conf:

azure-ubuntu:
  provider: azure
  image: 'b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu-14_04_1-LTS-amd64-server-20141125-en-us-30GB'
  size: Small
  location: 'West Europe'
  ssh_username: the_name
  ssh_password: the_password
  slot: production
  media_link: 'http://portalvhds9f92yhq0vgyk2.blob.core.windows.net/vhds'

maps/azure.map:

azure-ubuntu:
  - machine-1:
      port: 22
  - machine-2:
      port: 23
  - machine-3:
      port: 24

This should work right?

techhat commented 9 years ago

I don't see any problems with that offhand.

flavianh commented 9 years ago

Very well then. I'm working on Azure data disk at the moment I'll submit a pull request when I'm ready and I may have questions for you

flavianh commented 9 years ago

Works now

garethgreenaway commented 8 years ago

How did you work around the fact that the bootstrap script tries to connect via SSH on port 22?

garethgreenaway commented 8 years ago

Looks like including ssh_port in the map allows it to work.