Packer with Shell Script Provisioners( Error Uploading)

Hi,

I am trying to build off from an aws ami from aws marketplace using Packer. I am running into issues where the ami automatically pops up an interactive shell prompt (agreeing to licenses) when you ssh. So the Packer issue is when Provisioning with shell script that I have, it gets stuck uploading because of the interactive shell prompt.

The error will come up as this:
Error uploading script: { big text from license agreement }

Any ideas?

Hi @sudovinh !

Could you provide a bit more information, e.g., the AMI id in the marketplace? Perhaps there is an environment variable which you can set to turn off the interactive prompt, similar to setting DEBIAN_FRONTEND when doing unattended actions on apt ?

It may also be possible to use a single provisioner to simply echo yes into the first shell, but that depends on what the prompt expects.

Hi @brucellino1 !

Thanks for helping! I am trying to build off from the OpenVPN AMI. Once you hit yes for the first initial prompt, there is more interactive prompts (6 yes/no questions). I tried using DEBIAN_FRONTEND=noninteractive but does not seem to work.

If it’s something about old vs. New configuration file, there is something like

DEBIAN_FRONTEND=noninteractive apt-get \
-o Dpkg::Options::="--force-confdef" \
-o Dpkg::Options::="--force-confold" \
<command-follow-up>

You should read the docs about it first.

Maybe this post can help you out, too:

This sounds more like an expect problem than an apt problem. I haven’t confirmed yet, but from what @sudovinh says, the AMI is configured with a startup script that expects user input. So, Packer needs to be able to run a provisioner to send that input to the script. Does this sound right?

@Wolfsrudel It is failing before It can run what I need to do. For example, If I do an inline shell command “echo yes”, it will still fail.

@brucellino1 Yes, that sounds about right.