joefitzgerald / packer-windows

Windows Packer Templates
MIT License
1.63k stars 1.12k forks source link

Artifacts cannot be built when behind an http proxy #153

Closed stanislavhordiyenko closed 8 years ago

stanislavhordiyenko commented 9 years ago

Hi all,

Spent two days making it works on my local machine but all in vain. I thought that this is because of corporate proxy and that is why configured Atlas account to build image there, however, it's not working as well.

I use the following modified code from windows_2012_r2.json packer file:

{
  "builders": [
    {
      "type": "virtualbox-iso",
      "iso_url": "http://download.microsoft.com/download/6/2/A/62A76ABB-9990-4EFC-A4FE-C7D698DAEB96/9600.16384.WINBLUE_RTM.130821-1623_X64FRE_SERVER_EVAL_EN-US-IRM_SSS_X64FREE_EN-US_DV5.ISO",
      "iso_checksum_type": "md5",
      "iso_checksum": "458ff91f8abc21b75cb544744bf92e6a",
      "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": "Windows2012_64",
      "disk_size": 61440,
      "floppy_files": [
        "./answer_files/2012_r2/Autounattend.xml",
        "./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/chef.bat",
        "./scripts/vagrant-ssh.bat",
        "./scripts/enable-rdp.bat",
        "./scripts/compile-dotnet-assemblies.bat",
        "./scripts/disable-auto-logon.bat",
        "./scripts/compact.bat"
      ]
    },
    {
      "type": "shell",
      "inline": [
        "rm -rf /tmp/*"
      ]
    }
  ],
  "post-processors": [
    {
        "type": "atlas",
        "only": ["virtualbox-iso"],
        "token": "<my atlas token>",
        "artifact": "<account>/windows2012_r2",
        "artifact_type": "vagrant.box",
        "metadata": {
          "provider": "virtualbox",
          "version": "0.0.1",
          "created_at": "{{timestamp}}"
        }
      }
  ]
}

Could you please take a look and advise what is going here in a wrong way?

Are there any solutions here as well to utilize corporate proxy? What I noticed is that building locally there is no access to the Internet because of proxy. Are there any scripts to specify it in the build?

Thank you.

mihai-satmarean commented 9 years ago

I get bad results also trying to build the windows_81.json on atlas ==> virtualbox-iso: Typing the boot command... ==> virtualbox-iso: Waiting for WinRM to become available... ==> virtualbox-iso: Timeout waiting for WinRM. ==> virtualbox-iso: Unregistering and deleting virtual machine... ==> virtualbox-iso: Deleting output directory... Build 'virtualbox-iso' errored: Timeout waiting for WinRM.

anyone succesfully build windows on atlas? Thank you!

pearcec commented 9 years ago

I too am stuck on getting it working with a proxy. Can't find any documentation on how to do that.

mihai-satmarean commented 8 years ago

Same issue for me since months. I am trying all kind of variations with ports and what not but in vain. Any help would be appreciated.

mynamewastaken commented 8 years ago

I'm not familiar with Atlas, but Packer uses the http_proxy environment variable if it exists. I wrote a small wrapper script in powershell to set that environment variable to my local cntlm proxy, and then call Packer.

sneal commented 8 years ago

It would be helpful to get some debug output from Packer. Something to note is that a lot of the provisioning scripts connect out to the internet to download bits.

sneal commented 8 years ago

If someone has time in the future to work this issue we can reopen then.

mynamewastaken commented 8 years ago

@sneal I have a script that will set the necessary proxy (system as well as local ENV:http_proxy etc) settings in Windows. Because I don't want to hardcode that, I could use some help from you or others here in passing variables through to the script. I'm happy to make a PR to iterate on.

sneal commented 8 years ago

@mynamewastaken This seems like it would potentially be valuable to others. I personally have no need for it now, but would accept a PR for it.