I’m relatively new to packer and new to this forum so hopefully I’ve engaged the right board for this.
I am building an RHEL7 AWS EC2. It is provisioned successfully and ssh connection is established. I am having difficulty performing post provisioning steps where I need to run either inline shell commands or execute a shell script. In case there was a shell provisioner issue I also attempted a file transfer using the file provisioner. In all three cases I have experience the same outcome. That is a file gets created by the ec2-user on the EC2 instance but is empty.
...
"communicator": "ssh",
"ssh_username": "ec2-user"
}
],
"provisioners": [
{
"type": "file",
"source": "lin01.sh",
"destination": "/tmp/lin01-file.sh/"
},
{
"type": "shell",
"script": "lin01.sh",
"remote_folder": "/home/ec2-user/"
}
]
}
2020/06/12 17:33:15 packer.exe plugin: [INFO] Not using winrm communicator, skipping get password...
==> amazon-ebs: Using ssh communicator to connect: 10.x.x.x
2020/06/12 17:33:15 packer.exe plugin: [INFO] Waiting for SSH, up to timeout: 5m0s
==> amazon-ebs: Waiting for SSH to become available...
2020/06/12 17:33:15 packer.exe plugin: Using host value: 10.x.x.x
2020/06/12 17:33:24 packer.exe plugin: [INFO] Attempting SSH connection to 10.x.x.x
2020/06/12 17:33:24 packer.exe plugin: [DEBUG] reconnecting to TCP connection for SSH
2020/06/12 17:33:24 packer.exe plugin: [DEBUG] handshaking with SSH
2020/06/12 17:33:25 packer.exe plugin: [DEBUG] handshake complete!
2020/06/12 17:33:25 packer.exe plugin: [INFO] no local agent socket, will not connect agent
==> amazon-ebs: Connected to SSH!
2020/06/12 17:33:25 packer.exe plugin: Running the provision hook
2020/06/12 17:33:25 [INFO] (telemetry) Starting provisioner file
==> amazon-ebs: Uploading lin01.sh => /tmp/lin01-file.sh
2020/06/12 17:33:25 packer.exe plugin: [DEBUG] Opening new ssh session
2020/06/12 17:33:25 packer.exe plugin: [INFO] 60 bytes written for 'uploadData'
2020/06/12 17:33:25 [INFO] 60 bytes written for 'uploadData'
2020/06/12 17:33:25 packer.exe plugin: [DEBUG] Starting remote scp process: scp -vt /tmp
2020/06/12 17:33:25 packer.exe plugin: [DEBUG] Started SCP session, beginning transfers...
2020/06/12 17:33:25 packer.exe plugin: [DEBUG] scp: Uploading lin01-file.sh: perms=C0666 size=60
==> amazon-ebs: Upload failed: ed Hat Enterprise Linux Server release 7.8 (Maipo)
2020/06/12 17:33:25 packer.exe plugin: closing
2020/06/12 17:33:25 closing