Problem
The Image Builder AWS AMI build step (AWS Image Builder plugin 1.0.1) fails on a self-hosted build agent with one of these errors:
Image build problem: Failed to initialize packer
user_data_file not found: win_packer_bootstrap_ssh
Image build problem: Failed to validate template
The runner downloads and unpacks Packer by itself. Packer does not have to be installed on the agent.
Cause
Two separate defects in plugin 1.0.1:
-
Failed to initialize packerhappens on Windows build agents only. The runner starts Packer by the bare namepacker.exe, with the build checkout directory as the working directory. Windows does not look for the executable in that directory, sopacker initfails unless the directory is inPATH. Linux agents start./packerand are not affected. Tracked in Image Builder AWS AMI on Windows agents: Failed to initialize packer. -
user_data_file not found: win_packer_bootstrap_sshhappens on any build agent when the step has Platform set to Windows and Install TeamCity agent off. The generated template refers to the bootstrap file, but the plugin copies the file only when it installs the agent. Tracked in Windows AMI build: user_data_file not found: win_packer_bootstrap_ssh. Commitdaf51a25f730(AWS Image Builder: configure VCS mirror baking independently from agent installation) fixes it in the plugin source; plugin 1.0.1 does not contain the fix.
Not a cause of these errors:
-
AMI builder plugin no longer works due to packer plugins not being distributed via GitHub any more (Amazon Packer plugin distribution) applies only when the generated template requires the Amazon plugin with a broad version constraint, such as
version = ">= 1.0.9". A template pinned toversion = "= 1.3.9"is not affected. -
ssh_usernamein the generated template is copied from the step's SSH Username field. A different value means that the template comes from an earlier build, before the field was changed.
Resolution
- Download the generated template from the build's hidden artifacts:
.teamcity/image_builder/image-builder.pkr.hcl. Itsami_nameends with the build number of the build that generated it. - If a Windows agent reports
Failed to initialize packer, add the build checkout directory to the machinePATH. The runner unpacks Packer there. Restart the agent so that it inherits the change. A customer confirmed that this works. The checkout directory differs per build configuration and can change, so this is a temporary measure. Running the step on a Linux agent also avoids the error. - For
user_data_file not found: win_packer_bootstrap_ssh, no workaround is confirmed. Do not create the file by hand. A plugin version that contains the fix from Windows AMI build: user_data_file not found: win_packer_bootstrap_ssh is needed.
Comments
0 comments
Please sign in to leave a comment.