Salt-Cloud部署Azure Windows VM时Salt-Minion安装失败求助
SaltCloud部署Azure Windows虚拟机时误用端口22安装Salt-Minion的问题解决
问题
使用SaltStack部署Azure Windows虚拟机,虚拟机创建成功,但SaltCloud自动安装Salt-Minion时,始终通过端口22连接Windows虚拟机,导致连接超时失败。
原因
SaltCloud需要根据系统类型选择对应的连接协议:Linux系统用SSH(端口22),Windows系统需用WinRM协议。如果配置中未明确指定Windows的WinRM连接参数,SaltCloud会默认 fallback 到SSH方式,从而出现连接超时。
解决步骤
- 添加WinRM配置参数
在云配置文件(azure_cloud_profile.conf或cloud_provider_conf)中明确指定WinRM相关参数,告知SaltCloud使用WinRM连接Windows主机。示例修改azure_cloud_profile.conf:azure-win2012: provider: my-azure-config image: MicrosoftWindowsServer|WindowsServer|2012-R2-Datacenter|latest size: Standard_B1s location: 'westeurope' win_username: azureuser win_password: 'Verybadpass@!#' allocate_public_ip: True # 新增WinRM配置 winrm_port: 5986 # WinRM默认HTTPS端口 winrm_protocol: https winrm_insecure: False # 自签名证书场景可设为True,生产环境不推荐 - 开放Azure网络安全组端口
在Azure对应虚拟机的网络安全组(NSG)中,添加入站规则,允许5985(HTTP)或5986(HTTPS)端口的流量,确保WinRM连接能正常通过。 - 验证Windows虚拟机WinRM服务状态
Azure官方Windows Server镜像默认已启用WinRM,但如果有自定义配置,需确认WinRM服务处于运行状态,且本地防火墙允许WinRM连接。
原始信息
执行命令
salt-cloud -p azure-win2012 test6:
调试日志片段
[DEBUG ] Closing IPCMessageClient instance [DEBUG ] Deploying 20.20.20.20 at 2022-11-03 13:30:03 [DEBUG ] Attempting connection to host 20.20.20.20 on port 22 [DEBUG ] Caught exception in wait_for_port: timed out [DEBUG ] Retrying connection to host 20.20.20.20 on port 22 (try 1) [DEBUG ] Caught exception in wait_for_port: timed out [DEBUG ] Retrying connection to host 20.20.20.20 on port 22 (try 2) [DEBUG ] Caught exception in wait_for_port: timed out [DEBUG ] Retrying connection to host 20.20.20.20 on port 22 (try 3) [DEBUG ] Caught exception in wait_for_port: timed out [DEBUG ] Retrying connection to host 20.20.20.20 on port 22 (try 4) [DEBUG ] Caught exception in wait_for_port: timed out [DEBUG ] Retrying connection to host 20.20.20.20 on port 22 (try 5) [DEBUG ] Caught exception in wait_for_port: timed out [DEBUG ] Retrying connection to host 20.20.20.20 on port 22 (try 6) [DEBUG ] Caught exception in wait_for_port: timed out [DEBUG ] Retrying connection to host 20.20.20.20 on port 22 (try 7) [DEBUG ] Caught exception in wait_for_port: timed out [DEBUG ] Retrying connection to host 20.20.20.20 on port 22 (try 8) [DEBUG ] Caught exception in wait_for_port: timed out [DEBUG ] Retrying connection to host 20.20.20.20 on port 22 (try 9)
原始配置文件
azure_cloud_profile.conf
azure-win2012: provider: my-azure-config image: MicrosoftWindowsServer|WindowsServer|2012-R2-Datacenter|latest size: Standard_B1s location: 'westeurope' win_username: azureuser win_password: 'Verybadpass@!#' allocate_public_ip: True
cloud_provider_conf
my-azure-config: driver: azurearm subscription_id: xxxxxxxxxxxxxxxxxxx tenant: xxxxxxxxxxxxxxxxxx client_id: XXXXXXXXXXXXXXXX secret: 'XXXXXXXXXXXXXXXXXXX' certificate_path: /etc/salt/azure.pem resource_group: test-rg network: test-vnet subnet: default username: azureuser password: 'Verybadpass@!#' location: 'westeurope' # Set up the location of the salt master # minion: master: x.x.x.x # Optional management_host: management.core.windows.net
内容的提问来源于stack exchange,提问作者Robert
相关产品推荐
相关产品推荐

