1

I am running Packer within Jenkins using Chocolatey to install packages onto that Windows Server before it's created into an AMI, I am currently having an issue with chocolatey within packer not passing the -y into "choco install". Packer is currently stuck on "By installing you accept licenses for the packages".

Below is the Error Message:

[0;32m    amazon-ebs: WinRM connected.[0m
[1;32m==> amazon-ebs: Connected to WinRM![0m
[1;32m==> amazon-ebs: Provisioning with Powershell...[0m
[1;32m==> amazon-ebs: Provisioning with powershell script: /tmp/powershell-provisioner816199866[0m
[0;32m    amazon-ebs: Getting latest version of the Chocolatey package for download.[0m
[0;32m    amazon-ebs: Getting Chocolatey from https://chocolatey.org/api/v2/package/chocolatey/0.10.13.[0m
[0;32m    amazon-ebs: Downloading 7-Zip commandline tool prior to extraction.[0m
[0;32m    amazon-ebs: Extracting C:\Users\ADMINI~1\AppData\Local\Temp\chocolatey\chocInstall\chocolatey.zip to C:\Users\ADMINI~1\AppData\Local\Temp\chocolatey\chocInstall...[0m
[0;32m    amazon-ebs: Installing chocolatey on this machine[0m
[0;32m    amazon-ebs: Creating ChocolateyInstall as an environment variable (targeting 'Machine')[0m
[0;32m    amazon-ebs:   Setting ChocolateyInstall to 'C:\ProgramData\chocolatey'[0m
[0;32m    amazon-ebs: WARNING: It's very likely you will need to close and reopen your shell[0m
[0;32m    amazon-ebs:   before you can use choco.[0m
[0;32m    amazon-ebs: Restricting write permissions to Administrators[0m
[0;32m    amazon-ebs: We are setting up the Chocolatey package repository.[0m
[0;32m    amazon-ebs: The packages themselves go to 'C:\ProgramData\chocolatey\lib'[0m
[0;32m    amazon-ebs:   (i.e. C:\ProgramData\chocolatey\lib\yourPackageName).[0m
[0;32m    amazon-ebs: A shim file for the command line goes to 'C:\ProgramData\chocolatey\bin'[0m
[0;32m    amazon-ebs:   and points to an executable in 'C:\ProgramData\chocolatey\lib\yourPackageName'.[0m
[0;32m    amazon-ebs: Creating Chocolatey folders if they do not already exist.[0m
[0;32m    amazon-ebs: WARNING: You can safely ignore errors related to missing log files when[0m
[0;32m    amazon-ebs:   upgrading from a version of Chocolatey less than 0.9.9.[0m
[0;32m    amazon-ebs:   'Batch file could not be found' is also safe to ignore.[0m
[0;32m    amazon-ebs:   'The system cannot find the file specified' - also safe.[0m
[0;32m    amazon-ebs: chocolatey.nupkg file not installed in lib.[0m
[0;32m    amazon-ebs:  Attempting to locate it from bootstrapper.[0m
[0;32m    amazon-ebs: PATH environment variable does not have C:\ProgramData\chocolatey\bin in it. Adding...[0m
[0;32m    amazon-ebs: WARNING: Not setting tab completion: Profile file does not exist at[0m
[0;32m    amazon-ebs: 'C:\Users\Administrator\Documents\WindowsPowerShell\Microsoft.PowerShell_profil[0m
[0;32m    amazon-ebs: e.ps1'.[0m
[0;32m    amazon-ebs: Chocolatey (choco.exe) is now ready.[0m
[1;32m==> amazon-ebs: Provisioning with Powershell...[0m
[1;32m==> amazon-ebs: Provisioning with powershell script: /tmp/powershell-provisioner259657802[0m
[0;32m    amazon-ebs: Chocolatey v0.10.13[0m
[0;32m    amazon-ebs: Installing the following packages:[0m
[0;32m    amazon-ebs: notepadplusplus[0m
[0;32m    amazon-ebs: By installing you accept licenses for the packages.[0m

The Following is the Packer JSON file

{
  "provisioners": [
    {
       "type": "powershell",
       "inline": [
         "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))"
         ]
     },
     {
       "type": "powershell",
       "inline": [
            "choco install -y notepadplusplus",
            "choco install -y googlechrome",
            "choco install -y firefox"
       ]
     },
       {
       "type": "powershell",
       "inline": [
         "C:\\ProgramData\\Amazon\\EC2-Windows\\Launch\\Scripts\\SendWindowsIsReady.ps1 -Schedule",
         "C:\\ProgramData\\Amazon\\EC2-Windows\\Launch\\Scripts\\InitializeInstance.ps1 -Schedule",
         "C:\\ProgramData\\Amazon\\EC2-Windows\\Launch\\Scripts\\SysprepInstance.ps1 -NoShutdown"
       ]
     }
   ],
  "builders": [{
  "type": "amazon-ebs",
  "access_key": "{{user `aws_access_key`}}",
  "secret_key": "{{user `aws_secret_key`}}",
  "region": "us-east-1",
  "source_ami_filter": {
    "filters": {
      "virtualization-type": "hvm",
      "name": "Windows_Server-2012-R2_RTM-English-64Bit-Base-*",
      "root-device-type": "ebs"
    },
    "owners": ["amazon"],
    "most_recent": true
  },
  "instance_type": "t2.micro",
  "winrm_username": "Administrator",
  "ami_name": "Windows_2012_base-{{timestamp}}",
  "user_data_file": "SetUpWinRM.ps1",
  "communicator": "winrm",
  "winrm_use_ssl": true,
  "winrm_insecure": true,
  "launch_block_device_mappings": [{
    "device_name": "/dev/sda1",
    "volume_size": 60,
    "volume_type": "gp2",
    "delete_on_termination": true
  }]
}]
}
2
  • From the logs that you have shown, it hasn't actually got to the point of "needing" the -y flag yet. The last line that you have there is just before it reaches out to the internet to download the package that you have requested to be installed. Commented Apr 25, 2019 at 6:32
  • Hi Gary, for some reason it's suck on that and can be like that for about two hours
    – Dave
    Commented Apr 25, 2019 at 9:10

1 Answer 1

1

I encountered exactly the same issue - calling "choco install XXX" in packer script stuck on line "By installing you accept licenses for the packages."

Solution was to use older packer 1.3.1. Currently latest 1.4.0 does not work here.

Hope it helps.

1
  • 1.3.5 seems to work as well there is def something going on with 1.4.x
    – Shawn
    Commented May 15, 2019 at 18:48

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .