Packer在那里找不到文件

时间:2016-05-10 07:17:44

标签: vagrant packer

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

{
  "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"
  }
}

1 个答案:

答案 0 :(得分:3)

我在运行packer时遇到了同样的问题,构建的json模板与当前目录不在同一目录中,而不是json模板目录

C:...>cd Vagrant
C:...\Vagrant> packer validate windows_7.json

在您的模板中,您引用脚本./scripts/dis-updates.ps1,脚本位于C:/.../Vagrant/scripts/dis-updates.ps1下,但当打包器验证您的模板时,它会使当前目录不是模板所在目录。