Closed lmayorga1980 closed 8 years ago
This isn't a script we include in the packer runs by default, can you post your packerfile that you're using?
@kensykora. Yeah it seems that there is an issue with the current chocolatey.bat
but i am trying the .ps1 approach with the AutoUnattended.xml file.
{
"variables": {
"ssh_name": "vagrant",
"ssh_pass": "vagrant",
"puppet_release": "open",
"puppet_version": "3.7.1",
"iso_url": "iso/en_windows_server_2008_r2_with_sp1_vl_build_x64_dvd_617403.iso",
"iso_checksum": "8d397b69135d207452a78c3c3051339d"
},
"builders": [{
"type": "vmware-iso",
"iso_url": "{{user `iso_url`}}",
"iso_checksum_type": "md5",
"iso_checksum": "{{user `iso_checksum`}}",
"headless": false,
"boot_wait": "2m",
"ssh_username": "{{user `ssh_name`}}",
"ssh_password": "{{user `ssh_pass`}}",
"ssh_wait_timeout": "3h",
"shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"",
"guest_os_type": "windows7srv-64",
"tools_upload_flavor": "windows",
"disk_size": 61440,
"vnc_port_min": 5900,
"vnc_port_max": 5980,
"floppy_files": [
"http/cfg_windows/win2008r2/Autounattend.xml",
"scripts/win-updates.ps1",
"scripts/openssh.ps1",
"scripts/oracle-cert.cer",
"scripts/GeoTrust_Global_CA.cer"
],
"vmx_data": {
"RemoteDisplay.vnc.enabled": "false",
"RemoteDisplay.vnc.port": "5900",
"memsize": "2048",
"numvcpus": "2",
"scsi0.virtualDev": "lsisas1068"
}
},
{
"type": "parallels-iso",
"guest_os_type": "win-2008",
"vm_name": "parallels-windows",
"headless": false,
"parallels_tools_flavor": "win",
"hard_drive_interface": "sata",
"boot_wait": "2m",
"disk_size":"81200",
"iso_url": "{{user `iso_url`}}",
"iso_checksum": "{{user `iso_checksum`}}",
"iso_checksum_type": "md5",
"ssh_username": "{{user `ssh_name`}}",
"ssh_password": "{{user `ssh_pass`}}",
"ssh_wait_timeout": "4h",
"floppy_files": [
"http/cfg_windows/win2008r2/Autounattend.xml",
"scripts/microsoft-updates.bat",
"scripts/win-updates.ps1",
"scripts/openssh.ps1",
"scripts/oracle-cert.cer",
"scripts/GeoTrust_Global_CA.cer"
],
"shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"",
"prlctl": [
["set", "{{.Name}}", "--memsize", "2048"],
["set", "{{.Name}}", "--cpus", "2"],
["set", "{{.Name}}", "--winsystray-in-macmenu","off"],
["set", "{{.Name}}", "--startup-view", "window"]
]
},
{
"type": "virtualbox-iso",
"iso_url": "{{user `iso_url`}}",
"iso_checksum_type": "md5",
"iso_checksum": "{{user `iso_checksum`}}",
"headless": false,
"boot_wait": "2m",
"ssh_username": "{{user `ssh_name`}}",
"ssh_password": "{{user `ssh_pass`}}",
"ssh_wait_timeout": "3h",
"disk_size": 61440,
"shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"",
"guest_os_type": "Windows2008_64",
"floppy_files": [
"http/cfg_windows/win2008r2/Autounattend.xml",
"scripts/win-updates.ps1",
"scripts/openssh.ps1",
"scripts/oracle-cert.cer",
"scripts/chocolatey.bat",
"scripts/GeoTrust_Global_CA.cer"
],
"vboxmanage": [
["modifyvm", "{{.Name}}", "--memory", "2048"],
["modifyvm", "{{.Name}}", "--cpus", "2"]
]
},
{
"type": "amazon-ebs",
"region": "us-east-1",
"source_ami": "ami-6a38cc02",
"instance_type": "t1.micro",
"ssh_username": "vagrant",
"ssh_private_key_file": "/Users/lmo0/.ssh/id_vagrant",
"ami_name": "packer-quick-start {{timestamp}}",
"tags": {
"OS_Version": "Windows",
"Release": "2008R2"
}
}
],
"provisioners": [{
"type": "shell",
"environment_vars": [ "PUPPET_RELEASE={{user `puppet_release`}}",
"PUPPET_VERSION={{user `puppet_version`}}"
],
"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/provisioners.bat"
]
},
{ "type": "shell", "inline": ["rm -rf /tmp/*"] }
],
"post-processors": [{
"type": "vagrant",
"keep_input_artifact": false,
"output": "win2008r2-{{user `puppet_release`}}-{{user `puppet_version`}}-{{.Provider}}.box",
"vagrantfile_template": "vagrant-templates/vagrantfile-windows_2008_r2.template"
}]
}
Like many of the original scripts, chocolatey.bat is authored to run from scripts, which is much further downstream than Autounattended. My understanding is that Autounattend resources are items that everyone should run all the time, and scripts are a buffet of items we could add and remove to suit our needs. This meant that, in general, a person didn't have to edit the xml but simply tailor the Packer template.
IIRC Chocolatey relies on user env variables which, if not set, will make the whole thing fall over.
Ugh. Relies means a bug.
@dylanmei Agree with you on the Autounattended.
{
"variables": {
"ssh_name": "vagrant",
"ssh_pass": "vagrant",
"puppet_release": "open",
"puppet_version": "1.0.0",
"iso_url": "iso/en_windows_server_2008_r2_with_sp1_vl_build_x64_dvd_617403.iso",
"iso_checksum": "8d397b69135d207452a78c3c3051339d"
},
"builders": [{
"type": "vmware-iso",
"iso_url": "{{user `iso_url`}}",
"iso_checksum_type": "md5",
"iso_checksum": "{{user `iso_checksum`}}",
"headless": false,
"boot_wait": "2m",
"ssh_username": "{{user `ssh_name`}}",
"ssh_password": "{{user `ssh_pass`}}",
"ssh_wait_timeout": "3h",
"shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"",
"guest_os_type": "windows7srv-64",
"tools_upload_flavor": "windows",
"disk_size": 61440,
"vnc_port_min": 5900,
"vnc_port_max": 5980,
"floppy_files": [
"http/cfg_windows/win2008r2/Autounattend.xml",
"scripts/win-updates.ps1",
"scripts/openssh.ps1",
"scripts/oracle-cert.cer",
"scripts/GeoTrust_Global_CA.cer"
],
"vmx_data": {
"RemoteDisplay.vnc.enabled": "false",
"RemoteDisplay.vnc.port": "5900",
"memsize": "2048",
"numvcpus": "2",
"scsi0.virtualDev": "lsisas1068"
}
},
{
"type": "parallels-iso",
"guest_os_type": "win-2008",
"vm_name": "parallels-windows",
"headless": false,
"parallels_tools_flavor": "win",
"hard_drive_interface": "sata",
"boot_wait": "2m",
"disk_size":"81200",
"iso_url": "{{user `iso_url`}}",
"iso_checksum": "{{user `iso_checksum`}}",
"iso_checksum_type": "md5",
"ssh_username": "{{user `ssh_name`}}",
"ssh_password": "{{user `ssh_pass`}}",
"ssh_wait_timeout": "4h",
"floppy_files": [
"http/cfg_windows/win2008r2/Autounattend.xml",
"scripts/microsoft-updates.bat",
"scripts/win-updates.ps1",
"scripts/openssh.ps1",
"scripts/oracle-cert.cer",
"scripts/GeoTrust_Global_CA.cer"
],
"shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"",
"prlctl": [
["set", "{{.Name}}", "--memsize", "2048"],
["set", "{{.Name}}", "--cpus", "2"],
["set", "{{.Name}}", "--winsystray-in-macmenu","off"],
["set", "{{.Name}}", "--startup-view", "window"]
]
},
{
"type": "virtualbox-iso",
"iso_url": "{{user `iso_url`}}",
"iso_checksum_type": "md5",
"iso_checksum": "{{user `iso_checksum`}}",
"headless": false,
"boot_wait": "2m",
"ssh_username": "{{user `ssh_name`}}",
"ssh_password": "{{user `ssh_pass`}}",
"ssh_wait_timeout": "3h",
"disk_size": 61440,
"shutdown_command": "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"",
"guest_os_type": "Windows2008_64",
"floppy_files": [
"http/cfg_windows/win2008r2/Autounattend.xml",
"scripts/win-updates.ps1",
"scripts/openssh.ps1",
"scripts/oracle-cert.cer",
"scripts/GeoTrust_Global_CA.cer"
],
"vboxmanage": [
["modifyvm", "{{.Name}}", "--memory", "2048"],
["modifyvm", "{{.Name}}", "--cpus", "2"]
]
},
{
"type": "amazon-ebs",
"region": "us-east-1",
"source_ami": "ami-6a38cc02",
"instance_type": "t1.micro",
"ssh_username": "vagrant",
"ssh_private_key_file": "/Users/lmo0/.ssh/id_vagrant",
"ami_name": "packer-quick-start {{timestamp}}",
"tags": {
"OS_Version": "Windows",
"Release": "2008R2"
}
}
],
"provisioners": [{
"type": "shell",
"environment_vars": [ "PUPPET_RELEASE={{user `puppet_release`}}",
"PUPPET_VERSION={{user `puppet_version`}}"
],
"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/enable-rdp.bat",
"./scripts/compile-dotnet-assemblies.bat",
"./scripts/compact.bat",
"./scripts/provisioners.bat",
"./scripts/chocolatey.bat"
]
},
{ "type": "shell", "inline": ["rm -rf /tmp/*"] }
],
"post-processors": [{
"type": "vagrant",
"keep_input_artifact": false,
"output": "win2008r2-{{user `puppet_release`}}-{{user `puppet_version`}}-{{.Provider}}.box",
"vagrantfile_template": "vagrant-templates/vagrantfile-windows_2008_r2.template"
}]
}
chocolatey.bat
powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" <NUL
<nul set /p ".=;%ALLUSERSPROFILE%\chocolatey\bin" >> C:\Windows\Temp\PATH
set /p PATH=<C:\Windows\Temp\PATH
setx PATH "%PATH%" /m
It seems like chocolatey hangs installing NetFx 4.0
@dylanmei choco should no longer rely on environment variables like temp. If they are not there it uses a different var.
@lmayorga1980 Sounds like new choco is having issues installing - can you verify that the batch appends -y to the other choco install commands as well?
@ferventcoder you mean this guy
I guess chocolatey detected that NetFx4.0 was not there and it tried to installed and it just hangs. Trying again
@lmayorga1980 not sure how good the internet connection is, but it is going to try to download a 45 MB file from the nets.
If you bundle in the NetFx file based on $tempDir
:
$env:TEMP
- https://github.com/chocolatey/choco/blob/ce90c21acebc44f74b21df2a096cb2b3504c0851/nuget/chocolatey/tools/chocolateysetup.psm1#L4chocopath\temp
if $env:TEMP
is not set - https://github.com/chocolatey/choco/blob/ce90c21acebc44f74b21df2a096cb2b3504c0851/nuget/chocolatey/tools/chocolateysetup.psm1#L78dotNetFx40_Full_x86_x64.exe
- https://github.com/chocolatey/choco/blob/ce90c21acebc44f74b21df2a096cb2b3504c0851/nuget/chocolatey/tools/chocolateysetup.psm1#L464-L465This looks like its been "fixed" in the upstream choco script, and if its not... Its probably because OpenSSH isn't properly setting env vars so once we switch over to WinRM this will definitely be addressed.
the following script is throwing some errors https://github.com/joefitzgerald/packer-windows/blob/master/scripts/chocolatey.bat