Permission denied on shell script provisioner

I’m trying to create a “gold ami” from a base ami in the amazon marketplace. That AMI is based on RHEL, but I can’t seem to get it bootstrapped.

"provisioners": [
    "type": "shell",
    "script": "../"
    "type": "ansible-local",
    "playbook_file": "../playbooks/ship-it.yml",
    "playbook_dir": "../playbooks/roles/"


==> amazon-ebs: Provisioning with shell script: ../
==> amazon-ebs: bash: /tmp/ Permission denied

If I run the packer build in debug mode and ssh to the instance immediately after the execution fails, I see this when I ls -la the /tmp directory:

$ ls -la
total 4
drwxrwxrwt.  9 root     root     200 Apr  6 20:14 .
dr-xr-xr-x. 18 root     root     236 Sep 23  2019 ..
-rwxr-xr-x.  1 ec2-user ec2-user 378 Apr  6 20:14

Any thoughts would be much appreciated.

You could try setting execute_command:

"type": "shell",
"script": "../"
"execute_command": "{{.Vars}} bash '{{.Path}}'"

Okay, so yep, that looks like exactly what I needed, but I have to admit that I don’t really understand why. had execute permissions and is owned by the ssh user. Can you help me understand the secret sauce that execute_command provides?

Thanks for your help!

Sometimes /tmp is mounted without exec permission (noexec) or selinux restrictions apply.

1 Like