使用saltstack

时间:2018-02-08 10:55:02

标签: azure salt-stack

我正在使用盐云配置文件从自定义vhd中为azure提供vm,但它需要大约40分钟然后没有说"

  

配置失败。 VM的操作系统配置' customtestpsvm'没有   在规定的时间内完成。 VM可能仍会完成配置   成功。请稍后检查配置状态..   OSProvisioningTimedOut

"

我执行的步骤如下: -

  1. 在门户网站上创建azure vm。
  2. 进入该虚拟机的RDP并进行必要的修改(开放端口和所有)和sysprep。
  3. 使用Start-AzureStorageBlobCopy powershell命令将VM的OSDisk VHD复制到blob存储。
  4. 等待副本完成。
  5. 然后使用vhd的uri(在blob存储中)作为盐云配置文件中的图像。
  6. 我使用的盐配置文件如下: -

    azure-win:
      cleanup_data_disks: True
      cleanup_disks: True
      cleanup_interfaces: True
      cleanup_vhds: True
      deploy: False
      expire_group_cache: 86400
      expire_interface_cache: 3600
      expire_network_cache: 3600
      expire_offer_cache: 604800
      expire_publisher_cache: 604800
      expire_sku_cache: 604800
      expire_subnet_cache: 3600
      expire_version_cache: 604800
      image: https://crimasterdisks791.blob.core.windows.net/vhds/custompsimage.vhd
      location: EastUS
      network: AzureARM-SanRamon-New
      network_resource_group: AzureARM-SanRamon-New-ResGrp
      os_disk_size_gb: 140
      provider: P_Azure
      resource_group: AzureARM-SanRamon-New-ResGrp
      security_group: cri-azure
      size: Basic_A1
      win_password: Spam99$$
      win_username: azureuser
      storage_account: crimasterdisks791
      subnet: ARM-Subnet1
    

2 个答案:

答案 0 :(得分:0)

请参阅以下链接中提到的建议。 https://github.com/saltstack/salt/issues/38907 https://github.com/saltstack/salt/issues/41315

自定义Salt执行,状态和其他模块可以使用Salt文件服务器分发给Salt minions。 在通过主服务器上的file_roots选项定义的任何环境的根目录下,可以使用与模块类型对应的目录。 这些目录前面加上下划线:https://docs.saltstack.com/en/latest/ref/file_server/dynamic-modules.html

Azure是Microsoft提供的云服务,提供虚拟机,SQL服务,媒体服务等。本文档介绍如何使用Salt Cloud在Azure上创建安装了Salt的虚拟机。 https://docs.saltstack.com/en/latest/topics/cloud/azure.html

供应操作。这就是您遇到此问题的原因,这可能是由于多种原因(取决于VM配置,位置,大小)

您可以尝试导入以下内容:https://github.com/saltstack/salt/blob/develop/salt/cloud/clouds/azurearm.py#L77-L112 这些是azurearm所需的所有依赖项。因此,如果您具有正确的依赖关系,这将有助于缩小范围。 您可以通过在salt-cloud框上运行python -c'import azure.storage'来测试这些导入。如果你在任何一个上面遇到导入错误,那么你就会错过这种依赖。

答案 1 :(得分:0)

按照https://docs.microsoft.com/en-us/azure/virtual-machines/windows/sa-copy-generalized?toc=%2Fazure%2Fvirtual-machines%2Fwindows%2Ftoc.json中的步骤解决了问题 但要使其工作,盐代码需要进行一次更改,

对于自定义映像,os_type parmae​​ter依赖于win_installer参数

if vm_['image'].startswith('http'):
# https://{storage_account}.blob.core.windows.net/{path}/{vhd}
source_image = VirtualHardDisk(vm_['image'])
img_ref = None
if win_installer:
os_type = 'Windows'
else:
os_type = 'Linux'

但是如果我们将deploy部署为False,我们就不会给win_installer而且在windows自定义映像的情况下,os_type也会被设置为Linux,这就是它失败的原因。

我在代码中做了一些更改n直接在配置文件中给出os_type以使其正常工作