Choco установить в пакере

Я запускаю Packer в Jenkins, используя Chocolatey для установки пакетов на этот Windows Server до того, как он будет создан в AMI, в настоящее время у меня возникает проблема с chocolatey в пакере, не позволяющая -y передать "choco install". На данный момент Packer застрял на "При установке вы принимаете лицензии на пакеты".

Ниже приведено сообщение об ошибке:

[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

Ниже приведен файл JSON упаковщика

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

1 ответ

Я столкнулся с точно такой же проблемой - вызовом "choco install XXX" в скрипте упаковщика, который застрял в строке "При установке вы принимаете лицензии на пакеты".

Решением было использовать более старый упаковщик 1.3.1. В настоящее время последняя версия 1.4.0 здесь не работает.

Надеюсь, поможет.

Другие вопросы по тегам