For Packer Offline Use. How to map a network drive?

837 views
Skip to first unread message

Voll AufMühlen

unread,
Sep 30, 2014, 2:30:35 AM9/30/14
to packe...@googlegroups.com
Hi there to Packer Pro's.

I'm a newbie. Searched the net, but didn't find any solution for creating Windows Guest Base Boxes with Packer, when I only can work with files on the network. I can not use Internet connection when working with Packer.

Can someone explain me how to include a network folder with Packer, so that I can install apps and windows updates from there.

Thank you!

Alvaro Miranda Aguilera

unread,
Sep 30, 2014, 3:59:31 AM9/30/14
to packe...@googlegroups.com
what provider?

with virtualbox you can create a shared folder, and after a reboot once the vbox additions are installed you should see the shared folder mounted.

other option is use the file provider and copy a zip file to the vm

other option is put what you want in the http folder and download in the vm from web

other option is put the files on a shared folder over the network or web/ftp and use a script to mount/copy and then use them

does this help? or its too basic?

windows side, you can create a wsus server in the local network or separate vm and use it to update this vm

other option is create an iso with all the patches, and mount into the vm, this wont have the 4.5gb limit, as you wont burn this to media.

hope this helps
alvaro

--
You received this message because you are subscribed to the Google Groups "Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Voll AufMühlen

unread,
Sep 30, 2014, 4:38:30 AM9/30/14
to packe...@googlegroups.com
Provider : VirtualBox

First I've tried with File Provider.

  "provisioners": [
  {
  "type": "file",
  "source": "C:/a/setupssh-6.6p1-1.exe",
  "destination": "c:/Windows/Temp"
},

But that don't work

Voll AufMühlen

unread,
Sep 30, 2014, 4:46:47 AM9/30/14
to packe...@googlegroups.com
And, it seems that the Virtual is not installing the VirtualBox Guest Additions. Is there something missing??


  "builders": [
    {
      "type": "virtualbox-iso",
      "iso_url": "http://care.dlservice.microsoft.com/dl/download/evalx/win7/x64/EN/7600.16385.090713-1255_x64fre_enterprise_en-us_EVAL_Eval_Enterprise-GRMCENXEVAL_EN_DVD.iso",
      "iso_checksum_type": "md5",
      "iso_checksum": "1d0d239a252cb53e466d39e752b17c28",
      "headless": false,
      "boot_wait": "2m",
      "ssh_username": "vagrant",
      "ssh_password": "vagrant",
      "ssh_wait_timeout": "4h",
      "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"",
      "guest_os_type": "Windows7_64",
      "disk_size": 61440,
      "floppy_files": [
        "./answer_files/7/Autounattend.xml",
        "./scripts/microsoft-updates_nicht_nutzen.bat",
        "./scripts/win-updates_nicht_nutzen.ps1",
        "./scripts/openssh.ps1",
        "./scripts/oracle-cert.cer"
        ],

Voll AufMühlen

unread,
Sep 30, 2014, 4:59:03 AM9/30/14
to packe...@googlegroups.com
First, Thanks for the quick answer :-)

Can you explain me how to do that step by step.

Alvaro Miranda Aguilera

unread,
Sep 30, 2014, 5:05:52 AM9/30/14
to packe...@googlegroups.com
Hello

as you don't have internet, that may be failing.

by default packer will download and cache the iso..

the host have internet access? do you see anything on packer_cache ?

if you share the full json file, I can give it a try


--

Alvaro Miranda Aguilera

unread,
Sep 30, 2014, 5:11:22 AM9/30/14
to packe...@googlegroups.com
1. on json template file, something like this:

 "vboxmanage": [
    ["sharedfolder", "add", "{{.Name}}", "--name", "installers", "--hostpath", "E:\\boxes\\installs","--automount"]
    ],    

2. on vm guest install vbox additions

3. reboot

4. profit !


Message has been deleted
Message has been deleted

Voll AufMühlen

unread,
Sep 30, 2014, 6:25:49 AM9/30/14
to packe...@googlegroups.com
Hey Alvaro, really thank you for your very quick answers and that you take the time to help me out!

Here is the whole json file.

{
  "builders": [
    {
      "type": "virtualbox-iso",
      "iso_url": "C:/iso/7600.16385.090713-1255_x64fre_enterprise_en-us_EVAL_Eval_Enterprise-GRMCENXEVAL_EN_DVD.iso",

      "iso_checksum_type": "md5",
      "iso_checksum": "1d0d239a252cb53e466d39e752b17c28",
      "headless": false,
      "boot_wait": "2m",
      "ssh_username": "vagrant",
      "ssh_password": "vagrant",
      "ssh_wait_timeout": "4h",
      "shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"",
      "guest_os_type": "Windows7_64",
      "disk_size": 61440,
      "floppy_files": [
        "./answer_files/7/Autounattend.xml",
        "./scripts/microsoft-updates_nicht_nutzen.bat",
        "./scripts/win-updates_nicht_nutzen.ps1",
        "./scripts/openssh.ps1",
        "./scripts/oracle-cert.cer"
        ],
        "vboxmanage": [
        [
            "sharedfolder",
            "add",
            "{{.Name}}",
            "--name",
            "V_Packer",
            "--hostpath",
            "C:\\a",
            "--automount"
            ],
        [
          "modifyvm",
          "{{.Name}}",
          "--memory",
          "2048"
        ],
        [
          "modifyvm",
          "{{.Name}}",
          "--cpus",
          "2"
        ]
      ]
    }
  ],


  "provisioners": [
  {
  "type": "file",
  "source": "C:/a/setupssh-6.6p1-1.exe",
  "destination": "c:/Windows/"
},
    {
      "type": "shell",
      "remote_path": "/tmp/script.bat",
      "execute_command": "{{.Vars}} cmd /c C:/Windows/Temp/script.bat",
      "scripts": [
        "./scripts/vm-guest-tools.bat",
        "./scripts/chef.bat",
        "./scripts/vagrant-ssh.bat",
        "./scripts/disable-auto-logon.bat",
        "./scripts/enable-rdp.bat",
        "./scripts/compile-dotnet-assemblies.bat",
        "./scripts/compact.bat"
      ]
    },
    {
      "type": "shell",
      "inline": [
        "rm -rf /tmp/*"
      ]
    }
  ],
  "post-processors": [
    {
      "type": "vagrant",
      "keep_input_artifact": false,
      "output": "windows_7_{{.Provider}}.box",
      "vagrantfile_template": "vagrantfile-windows_7.template"
    }
  ]
}

Voll AufMühlen

unread,
Sep 30, 2014, 7:05:23 AM9/30/14
to packe...@googlegroups.com
I tried to add a sharedfolder to the vm but it didn't work.

Here is what is in the json file

        "vboxmanage": [
        [
            "sharedfolder",
            "add",
            "{{.Name}}",
            "--name",
            "V_Packer",
            "--hostpath",
            "C:\\a",
            "--automount"
            ],
        [
          "modifyvm",
          "{{.Name}}",
          "--memory",
          "2048"
        ],
        [
          "modifyvm",
          "{{.Name}}",
          "--cpus",
          "2"
        ]
      ]

And here is what happens in cmd :

==> virtualbox-iso: Downloading or copying Guest additions
    virtualbox-iso: Downloading or copying: file:///C:/Program%20Files/Oracle/Vi
rtualBox/VBoxGuestAdditions.iso
==> virtualbox-iso: Downloading or copying ISO
    virtualbox-iso: Downloading or copying: file:///C:/Packer_Files/7600.16385.0
90713-1255_x64fre_enterprise_en-us_EVAL_Eval_Enterprise-GRMCENXEVAL_EN_DVD.iso
==> virtualbox-iso: Creating floppy disk...
    virtualbox-iso: Copying: ./answer_files/7/Autounattend.xml
    virtualbox-iso: Copying: ./scripts/microsoft-updates_nicht_nutzen.bat
    virtualbox-iso: Copying: ./scripts/win-updates_nicht_nutzen.ps1
    virtualbox-iso: Copying: ./scripts/openssh.ps1
    virtualbox-iso: Copying: ./scripts/oracle-cert.cer
==> virtualbox-iso: Creating virtual machine...
==> virtualbox-iso: Creating hard drive...
==> virtualbox-iso: Attaching floppy disk...
==> virtualbox-iso: Creating forwarded port mapping for SSH (host port 2901)
==> virtualbox-iso: Executing custom VBoxManage commands...
    virtualbox-iso: Executing: sharedfolder add packer-virtualbox-iso-1412074203
 --name V_Packer --hostpath C:\a --automount
    virtualbox-iso: Executing: modifyvm packer-virtualbox-iso-1412074203 --memor
y 2048
    virtualbox-iso: Executing: modifyvm packer-virtualbox-iso-1412074203 --cpus
2
==> virtualbox-iso: Starting the virtual machine...
==> virtualbox-iso: Waiting 2m0s for boot...
==> virtualbox-iso: Typing the boot command...
==> virtualbox-iso: Waiting for SSH to become available...

Alvaro Miranda Aguilera

unread,
Sep 30, 2014, 5:01:04 PM9/30/14
to packe...@googlegroups.com
Morning.

Did you reboot the box?

On windows, the shares are avaliable like \\vboxsrv\share

so you can use an script to kick an net use \\vboxsrv\share and map into a letter.

I would say try to do it once manually, so you can get the exacts commands for vboxmanage and then inside the guest for the mount point

is not hard, but helps and become easier if you have done it without packer manually

On Tue, Sep 30, 2014 at 11:10 PM, Voll AufMühlen <vollwas...@googlemail.com> wrote:
Thank you for the explanation how to add an folder to vm.

I tried it....but there's no shared folder and no Drive E: in the guest machine.



Am Dienstag, 30. September 2014 11:11:22 UTC+2 schrieb Alvaro Miranda Aguilera:
1. on json template file, something like this:

 "vboxmanage": [
    ["sharedfolder", "add", "{{.Name}}", "--name", "installers", "--hostpath", "E:\\boxes\\installs","--automount"]
    ],    

2. on vm guest install vbox additions

3. reboot

4. profit !

Reply all
Reply to author
Forward
0 new messages