微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

无法使用 HashiCorp 打包程序和 hyper-v 配置程序通过批处理文件安装 SQL Express 2005

如何解决无法使用 HashiCorp 打包程序和 hyper-v 配置程序通过批处理文件安装 SQL Express 2005

我已成功将 sql Express 安装程序 (exe) 复制到我的 hyper-v 虚拟机上,因为它是由打包程序设置的,但实际安装批处理文件似乎没有成功。下面是我的打包器配置文件

{
  "scripts": [
    "./scripts/storeservices/copy_sql_exe2.ps1"
  ],"type": "powershell"
},{
  "script": "./scripts/storeservices/InstallQuest-sql2K16x64.bat","type":"windows-shell","pause_before": "15m"
}

复制脚本工作,然后安装脚本“出现”完成(例如,当我查看打包程序日志时,我可以看到批处理文件中安装行前后的回声)

@Echo off
ECHO [StoreServices] Beginning sql Express installation...
start /wait "sqlEXPRESS" "C:\WINDOWS\Temp\sqlEXPR_x64_ENU.exe" /Q /ACTION=INSTALL /FEATURES=sqlEngine /INSTANCENAME="QUEST" /ENABLERANU /SecurityMODE=sql /SAPWD="" /sqlSVCACCOUNT="NT AUTHORITY\SYstem" /NPENABLED=1 /TCPENABLED=1 /IACCEPTsqlSERVERLICENSETERMS
ECHO [StoreServices] Finished sql Express installation...

打包日志:

    hyperv-iso: Installing AWS Tools...
    hyperv-iso: Creating AWS credentials...
    hyperv-iso: copying sql setup file(s) to local machine...
    hyperv-iso:
    hyperv-iso: LastWriteTime : 7/17/2021 9:48:22 PM
    hyperv-iso: Length        : 459167776
    hyperv-iso: Name          : sqlEXPR_x64_ENU.exe
    hyperv-iso:
==> hyperv-iso: Pausing 15m0s before the next provisioner...
==> hyperv-iso: Provisioning with windows-shell...
==> hyperv-iso: Provisioning with shell script: ./scripts/storeservices/InstallQuest-sql2K16x64.bat
    hyperv-iso: [StoreServices] Beginning sql Express installation...
    hyperv-iso: [StoreServices] Finished sql Express installation...
==> hyperv-iso: Gracefully halting virtual machine...

但是,当我使用 vagrant 生成生成的 .Box 文件并将其附加为 hyper-v 虚拟机时,未安装 sql express。 ‘exe’文件按预期在临时文件夹中,我可以看到所有其他脚本执行正常,但未安装 sql express。如果我在 VM 上手动运行批处理文件sql Express 安装正常。

在这里错过了什么?完整的打包器配置文件如下,以备不时之需:

{
  "builders": [
    {
      "boot_wait": "6m","output_directory":"./output","communicator": "winrm","http_directory":"./scripts/storeservices/","configuration_version": "8.0","cpus": "2","disk_size": "{{user `disk_size`}}","floppy_files": [
        "{{user `autounattend`}}","./floppy/WindowsPowershell.lnk","./floppy/PinTo10.exe","./scripts/fixnetwork.ps1","./scripts/create-shares.ps1","./scripts/disable-screensaver.ps1","./scripts/disable-winrm.ps1","./scripts/enable-winrm.ps1","./scripts/microsoft-updates.bat","./scripts/win-updates.ps1"
      ],"guest_additions_mode": "none","iso_checksum": "{{user `iso_checksum`}}","iso_url": "{{user `iso_url`}}","memory": "{{user `memory`}}","shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"","switch_name": "{{user `switch_name`}}","type": "hyperv-iso","vm_name": "{{user `vm_name`}}","winrm_password": "vagrant","winrm_timeout": "{{user `winrm_timeout`}}","winrm_username": "vagrant"
    }
  ],"post-processors": [
    {
      "keep_input_artifact": false,"output": "windows_10_{{.Provider}}.Box","type": "vagrant","vagrantfile_template": "vagrantfile-windows_10.template"
    }
  ],"provisioners": [
    {
      "type": "file","source": "./floppy/storeservices/javacpl.exe","destination": "'C:\\WINDOWS\\Temp\\"
    },{
      "execute_command": "{{ .Vars }} cmd /c \"{{ .Path }}\"","remote_path": "/tmp/script.bat","scripts": [
        "./scripts/enable-rdp.bat"
      ],"type": "windows-shell"
    },{
      "scripts": [
        "./scripts/vm-guest-tools.ps1","./scripts/debloat-windows.ps1"
      ],"type": "powershell"
    },{
      "restart_timeout": "{{user `restart_timeout`}}","type": "windows-restart"
    },{
      "scripts": [
        "./scripts/set-powerplan.ps1","./scripts/docker/disable-windows-defender.ps1"
      ],"scripts": [
        "./scripts/pin-powershell.bat","./scripts/compile-dotnet-assemblies.bat","./scripts/set-winrm-automatic.bat","./scripts/uac-enable.bat","./scripts/dis-updates.bat","./scripts/compact.bat","./scripts/storeservices/create_shares.bat"
      ],{
      "scripts": [
        "./scripts/storeservices/copy_sql_exe2.ps1"
      ],{
      "script": "./scripts/storeservices/InstallQuest-sql2K16x64.bat","pause_before": "15m"
    }
  ],"variables": {
    "autounattend": "./answer_files/10/Autounattend.xml","disk_size": "61440","disk_type_id": "1","memory": "2048","headless": "false","iso_checksum": "sha256:668fe1af70c2f7416328aee3a0bb066b12dc6bbd2576f40f812b95741e18bc3a","iso_url": "https://software-download.microsoft.com/download/sg/17763.107.101029-1455.rs5_release_svc_refresh_CLIENT_LTSC_EVAL_x64FRE_en-us.iso","restart_timeout": "5m","vhv_enable": "false","virtio_win_iso": "~/virtio-win.iso","vm_name": "windows_10","winrm_timeout": "6h","vmx_version": "14"
  }
}

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。