如何将加壳程序运行 AMI 配置脚本的目录从 /tmp 更改为 /opt

How can I change the directory that packer runs the AMI provisioning script from /tmp to /opt

我需要从 /tmp/packer-shell975270284 更改加壳器 运行 的 AMI 配置脚本所在的目录,因为我们的实例不允许脚本 运行 形式为 /tmp。

此脚本需要 运行 in /opt 或 /home/ec2-user。它将有权限的地方

下面是我在 ansible 剧本 运行 之后遇到的错误。

==> amazon-ebs: Provisioning with shell script: /tmp/packer-shell975270284
Build 'amazon-ebs' errored: Error uploading script: scp: /tmp/script_5412.sh: Permission denied.

==> Some builds didn't complete successfully and had errors.

==> Builds finished but no artifacts were created.

您需要将 remote_folder 设置为其他值而不是 /tmp。参见 the documentation