Packer 脚本以非零退出状态退出:127

Packer Script exited with non-zero exit status : 127

我正在尝试配置 AWS AMI,但打包程序脚本因以下错误而终止。

Build 'amazon-ebs' errored: Script exited with non-zero exit status: 127
   ==> Some builds didn't complete successfully and had errors:
   --> amazon-ebs: Script exited with non-zero exit status: 127
   ==> Builds finished but no artifacts were created.

我的 Packer 模板如下:

   { 
   "variables": {
    "aws_access_key": "{{env `MY_ACCESS_KEY`}}",
    "aws_secret_key": "{{env `MY_SECRET_KEY`}}"
   },
    "builders": [{
    "type": "amazon-ebs",
    "access_key": "{{user `aws_access_key`}}",
    "secret_key": "{{user `aws_secret_key`}}",
    "region": "us-east-1",
    "source_ami":"ami-8c1be5f6",
    "instance_type": "t2.micro",
    "ssh_username": "ec2-user",
    "ami_name": "packer-example {{timestamp}}"
    }],
    "provisioners":[
    {
      "type": "shell",
      "script": "provision.sh"
    }]}

错误日志如下:PACKER_LOG=1 packer build template.json

2017/11/01 01:30:37 [INFO] (telemetry) ending amazon-ebs
2017/11/01 01:30:37 [INFO] (telemetry) found error: Script exited with non-zero exit status: 127
2017/11/01 01:30:37 ui error: Build 'amazon-ebs' errored: Script exited with non-zero exit status: 127
2017/11/01 01:30:37 Builds completed. Waiting on interrupt barrier...
2017/11/01 01:30:37 machine readable: error-count []string{"1"}
2017/11/01 01:30:37 ui error: 
==> Some builds didn't complete successfully and had errors:
2017/11/01 01:30:37 machine readable: amazon-ebs,error []string{"Script exited with non-zero exit status: 127"}
2017/11/01 01:30:37 ui error: --> amazon-ebs: Script exited with non-zero exit status: 127
2017/11/01 01:30:37 ui: 
==> Builds finished but no artifacts were created.
Build 'amazon-ebs' errored: Script exited with non-zero exit status: 127

provision.sh 包括

   #!/bin/bash
   sudo yum install httpd -y
   sudo yum update -y
   sudo aws s3 cp s3://zbcxlkxcjvlxkj/index1.html /var/www/html/ --region us-east-1
   sudo service httpd start
   sudo chkconfig httpd on

当找不到命令时,bash 返回退出代码 127。在 运行 之前,您很可能没有在图像上安装脚本中使用的所有命令。