Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vagrant 当文件存在时,打包程序无法找到该文件_Vagrant_Packer - Fatal编程技术网

Vagrant 当文件存在时,打包程序无法找到该文件

Vagrant 当文件存在时,打包程序无法找到该文件,vagrant,packer,Vagrant,Packer,我正在尝试从我的主目录C:\Users[User]\n运行packer-validate./Vagrant/windows_7.json,但在脚本部分失败,出现错误,系统无法找到指定的路径。我可以使用完全限定的路径,它工作得很好,但由于某些原因,它不适用于relative。配置中是否有任何内容表明系统无法找到该文件的原因?这很奇怪,因为它可以很容易地找到./iso/Windows_7.iso,但找不到vagrantfile-Windows_7.template和脚本。packer目录查看与.js

我正在尝试从我的主目录C:\Users[User]\n运行
packer-validate./Vagrant/windows_7.json
,但在脚本部分失败,出现错误
,系统无法找到指定的路径
。我可以使用完全限定的路径,它工作得很好,但由于某些原因,它不适用于relative。配置中是否有任何内容表明系统无法找到该文件的原因?这很奇怪,因为它可以很容易地找到./iso/Windows_7.iso,但找不到vagrantfile-Windows_7.template和脚本。packer目录查看与.json构建文件相关的所有内容,对吗?我也尝试过检查权限,但我的用户名具有完全访问权限。我还有最新的适用于Windows的Packer 0.10.1

{
  "builders": [
    {
      "type": "virtualbox-iso",
      "iso_url": "{{user `iso_url`}}",
      "iso_checksum_type": "{{user `iso_checksum_type`}}",
      "iso_checksum": "{{user `iso_checksum`}}",
      "headless": true,
      "boot_wait": "2m",
      "ssh_username": "vagrant",
      "ssh_password": "vagrant",
      "ssh_wait_timeout": "8h",
      "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"",
      "guest_os_type": "Windows7_64",
      "disk_size": 61440,
      "floppy_files": [
        "{{user `autounattend`}}",
        "./scripts/dis-updates.ps1",
        "./scripts/hotfix-KB3102810.bat",
        "./scripts/microsoft-updates.bat",
        "./scripts/win-updates.ps1",
        "./scripts/openssh.ps1",
        "./scripts/oracle-cert.cer"
      ],
      "vboxmanage": [
        [
          "modifyvm",
          "{{.Name}}",
          "--memory",
          "2048"
        ],
        [
          "modifyvm",
          "{{.Name}}",
          "--cpus",
          "2"
        ]
      ]
    }
  ],
  "provisioners": [
    {
      "type": "shell",
      "remote_path": "/tmp/script.bat",
      "execute_command": "{{.Vars}} cmd /c C:/Windows/Temp/script.bat",
      "scripts": [
        "./scripts/vm-guest-tools.bat",
        "./scripts/vagrant-ssh.bat",
        "./scripts/disable-auto-logon.bat",
        "./scripts/enable-rdp.bat",
        "./scripts/compile-dotnet-assemblies.bat",
        "./scripts/compact.bat"
      ]
    }
  ],
  "post-processors": [
    {
      "type": "vagrant",
      "keep_input_artifact": false,
      "output": "windows_7_{{.Provider}}.box",
      "vagrantfile_template": "vagrantfile-windows_7.template"
    }
  ],
  "variables": {
    "iso_url": "./iso/Windows_7.iso",
    "iso_checksum_type": "SHA1",
    "iso_checksum": "36AE90DEFBAD9D9539E649B193AE573B77A71C83",
    "autounattend": "./answer_files/Autounattend.xml"
  }
}

我在运行packer构建json模板时遇到了同样的问题,因为它不在当前目录下,而不是json模板目录下

C:...>cd Vagrant
C:...\Vagrant> packer validate windows_7.json
在模板中,您引用脚本
/scripts/dis updates.ps1
,该脚本位于
C:/…/Vagrant/scripts/dis updates.ps1
下,但当packer验证模板时,它将使用当前目录而不是模板所在的目录