hashicorp / terraform-aws-vault

A Terraform Module for how to run Vault on AWS using Terraform and Packer
Apache License 2.0
656 stars 465 forks source link

Packer build failed due to permission error #230

Open Yeunkwan opened 3 years ago

Yeunkwan commented 3 years ago

Hi,

I am trying to implement the vault cluster using the repo. As first step, I tried to create AMIs using packer, however I kept getting "permission error" in running vault-install script. I tried many things only to fail. So, as a last resort, I leave a message. Can somebody help me with this issue? Please refer to the log snippets below: Thank you for your help in advance.

######## 2021/01/13 13:51:26 packer.exe plugin: [DEBUG] starting remote command: chmod 0755 /tmp/script_7151.sh 2021/01/13 13:51:26 packer.exe plugin: [INFO] RPC endpoint: Communicator ended with: 0 2021/01/13 13:51:26 [INFO] RPC client: Communicator ended with: 0 2021/01/13 13:51:26 [INFO] RPC endpoint: Communicator ended with: 0 2021/01/13 13:51:26 packer.exe plugin: [INFO] RPC client: Communicator ended with: 0 2021/01/13 13:51:26 packer.exe plugin: [DEBUG] Opening new ssh session 2021/01/13 13:51:26 packer.exe plugin: [DEBUG] starting remote command: sudo -S env PACKER_BUILDER_TYPE='amazon-ebs' PACKER_BUILD_NAME='amazon-linux-2-ami' /tmp/script_7151.sh 2021/01/13 13:51:26 packer.exe plugin: [ERROR] Remote command exited with '1': sudo -S env PACKER_BUILDER_TYPE='amazon-ebs' PACKER_BUILD_NAME='amazon-linux-2-ami' /tmp/script_7151.sh 2021/01/13 13:51:26 packer.exe plugin: [INFO] RPC endpoint: Communicator ended with: 1 2021/01/13 13:51:26 [INFO] 109 bytes written for 'stderr' 2021/01/13 13:51:26 [INFO] 0 bytes written for 'stdout' 2021/01/13 13:51:26 [INFO] RPC client: Communicator ended with: 1 2021/01/13 13:51:26 [INFO] RPC endpoint: Communicator ended with: 1 2021/01/13 13:51:26 ui error: ==> amazon-linux-2-ami: /tmp/script_7151.sh: line 2: /tmp/terraform-aws-vault/modules/install-vault/install-vault: Permission denied 2021/01/13 13:51:26 packer.exe plugin: [INFO] 0 bytes written for 'stdout' 2021/01/13 13:51:26 packer.exe plugin: [INFO] 109 bytes written for 'stderr' 2021/01/13 13:51:26 packer.exe plugin: [INFO] RPC client: Communicator ended with: 1 2021/01/13 13:51:26 [INFO] (telemetry) ending shell 2021/01/13 13:51:26 ui: ==> amazon-linux-2-ami: Provisioning step had errors: Running the cleanup provisioner, if present... 2021/01/13 13:51:26 ui: ==> amazon-linux-2-ami: Terminating the source AWS instance... 2021/01/13 13:52:12 ui: ==> amazon-linux-2-ami: Cleaning up any extra volumes... 2021/01/13 13:52:12 ui: ==> amazon-linux-2-ami: No volumes to clean up, skipping 2021/01/13 13:52:12 ui: ==> amazon-linux-2-ami: Deleting temporary security group... 2021/01/13 13:52:12 ui: ==> amazon-linux-2-ami: Deleting temporary keypair... 2021/01/13 13:52:13 [INFO] (telemetry) ending amazon-ebs 2021/01/13 13:52:13 ui error: Build 'amazon-linux-2-ami' errored after 2 minutes 10 seconds: Script exited with non-zero exit status: 1.Allowed exit codes are: [0] 2021/01/13 13:52:13 ui: ==> Wait completed after 2 minutes 10 seconds 2021/01/13 13:52:13 machine readable: error-count []string{"1"} 2021/01/13 13:52:13 ui error: ==> Some builds didn't complete successfully and had errors: 2021/01/13 13:52:13 machine readable: amazon-linux-2-ami,error []string{"Script exited with non-zero exit status: 1.Allowed exit codes are: [0]"} 2021/01/13 13:52:13 ui error: --> amazon-linux-2-ami: Script exited with non-zero exit status: 1.Allowed exit codes are: [0] 2021/01/13 13:52:13 ui: ==> Builds finished but no artifacts were created. ##############

brikis98 commented 3 years ago

This is most likely a Windows issue related to line endings or permissions issue.

Please check the settings here:

Also, what version of Packer are you using?

Yeunkwan commented 3 years ago

Thank you for your help. This issue has been resolved

brikis98 commented 3 years ago

Could you share what you did to solve it to help other people who hit the same issue?

Yeunkwan commented 3 years ago

I used Windows OS, so it looks like there was a problem with conversion.
I used "dos2unix" command before uploading files to Linux. I think it resolved the issue that I had.