Packer template BELOW

{
"variables": {
"aws_access_key": "{{env `PACKER_VAR_DEV_AWS_ACCESS_KEY_ID`}}",
"aws_secret_key": "{{env `PACKER_VAR_DEV_AWS_SECRET_ACCESS_KEY`}}"
},
"builders": [{
"type": "amazon-ebs",
"access_key": "{{user `aws_access_key`}}",
"secret_key": "{{user `aws_secret_key`}}",
"region": "us-east-1",
"source_ami_filter": {
"filters": {
"virtualization-type": "hvm",
"name": "Base-AMI-Ubuntu-*",
"root-device-type": "ebs"
},
"owners": [
"622297214873"
],
"most_recent": true
},
"instance_type": "t2.large",
"ssh_username": "ubuntu",
"ami_name": "redacted-{{timestamp}}",
"vpc_id": "redacted",
"associate_public_ip_address": "true",
"subnet_id": "redacted"
}],
"provisioners": [{
"type": "file",
"source": "/tmp/redacted.sh",
"destination": "/tmp/redacted.sh"
}, 
{
"type": "shell",
"execute_command": "echo 'packer' | sudo -E sh -c '{{ .Vars }} {{ .Path }}'"
,
"script": "/tmp/redacted.sh"
}]
}

*redacted.sh script below*
#!/bin/bash -x

ScriptPath="/tmp/"
ScriptName="runComposer.sh"

set -ex
clear
sudo git clone --depth=1 --no-tags https://github.com/XXXXXX.git /tmp

sleep 15
sudo chmod a+x $ScriptName
sleep 5
$ScriptPath/$ScriptName

result=$?


*ERROR BELOW from PACKER DEBUG OUTPUT LOGGING*

2020/04/01 15:51:27 packer-builder-amazon-ebs plugin: [DEBUG] starting 
remote command: echo 'packer' | sudo -E sh -c 
'PACKER_BUILDER_TYPE='amazon-ebs' PACKER_BUILD_NAME='amazon-ebs' 
/tmp/script_883.sh' ==> amazon-ebs: + ScriptPath=/tmp/ ==> amazon-ebs: + 
ScriptName=runComposer.sh ==> amazon-ebs: + set -ex ==> amazon-ebs: + clear 
2020/04/01 15:51:27 packer-builder-amazon-ebs plugin: [ERROR] Remote 
command exited with '1': echo 'packer' | sudo -E sh -c 
'PACKER_BUILDER_TYPE='amazon-ebs' PACKER_BUILD_NAME='amazon-ebs' 
/tmp/script_883.sh' 2020/04/01 15:51:27 packer-builder-amazon-ebs plugin: 
[INFO] RPC endpoint: Communicator ended with: 1 2020/04/01 15:51:27 [INFO] 
0 bytes written for 'stdout' 2020/04/01 15:51:27 [INFO] 108 bytes written 
for 'stderr' 2020/04/01 15:51:27 [INFO] RPC client: Communicator ended 
with: 1 2020/04/01 15:51:27 [INFO] RPC endpoint: Communicator ended with: 1 
2020/04/01 15:51:27 packer-provisioner-shell plugin: [INFO] 0 bytes written 
for 'stdout' 2020/04/01 15:51:27 packer-provisioner-shell plugin: [INFO] 
108 bytes written for 'stderr' 2020/04/01 15:51:27 packer-provisioner-shell 
plugin: [INFO] RPC client: Communicator ended with: 1 ==> amazon-ebs: 
'unknown': I need something more specific.

-- 
This mailing list is governed under the HashiCorp Community Guidelines - 
https://www.hashicorp.com/community-guidelines.html. Behavior in violation of 
those guidelines may result in your removal from this mailing list.

GitHub Issues: https://github.com/mitchellh/packer/issues
IRC: #packer-tool on Freenode
--- 
You received this message because you are subscribed to the Google Groups 
"Packer" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/packer-tool/251c6e60-4ba9-4674-bc87-94a39ae042e4%40googlegroups.com.

Reply via email to