Packer (amazon-ebs) fails with error

212 views
Skip to first unread message

Pradeep Patra

unread,
Feb 27, 2018, 4:31:15 AM2/27/18
to Packer
Hi all,

I am trying to use packer(amazon-ebs) for creating the AMI. The packer version I used is 1.0.2. I could able to run the below code from a simple shell script and it works perfectly. But when I run using "packer build" command it fails with the error " amazon-ebs: sudo: /usr/local/bin/aws: command not found" 

Can anyone help in this regard?

Regards
Pradeep

echo "======================"
echo "Installing the AWS CLI"
echo "======================"

python --version
sudo curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "/var/awscli-bundle.zip"
sudo yum install zip unzip -y
sudo unzip /var/awscli-bundle.zip -d /var
sudo /var/awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
sudo /usr/local/bin/aws --version


amazon-ebs: Downloading python_dateutil-2.6.1-py2.py3-none-any.whl (194kB)
    amazon-ebs: Requirement already satisfied: futures<4.0.0,>=2.2.0; python_version == "2.6" or python_version == "2.7" in /usr/lib/python2.7/site-packages (from s3transfer<0.2.0,>=0.1.12->awscli)
    amazon-ebs: Requirement already satisfied: pyasn1>=0.1.3 in /usr/lib/python2.7/site-packages (from rsa<=3.5.0,>=3.1.2->awscli)
    amazon-ebs: Requirement already satisfied: six>=1.5 in /usr/lib/python2.7/site-packages (from python-dateutil<3.0.0,>=2.1->botocore==1.9.0->awscli)
    amazon-ebs: Installing collected packages: colorama, python-dateutil, botocore, s3transfer, awscli
    amazon-ebs: Found existing installation: python-dateutil 1.5
    amazon-ebs: Uninstalling python-dateutil-1.5:
    amazon-ebs: Successfully uninstalled python-dateutil-1.5
    amazon-ebs: Found existing installation: botocore 1.6.0
    amazon-ebs: Uninstalling botocore-1.6.0:
    amazon-ebs: Successfully uninstalled botocore-1.6.0
    amazon-ebs: Found existing installation: s3transfer 0.1.10
    amazon-ebs: Uninstalling s3transfer-0.1.10:
    amazon-ebs: Successfully uninstalled s3transfer-0.1.10
    amazon-ebs: Successfully installed awscli-1.14.47 botocore-1.9.0 colorama-0.3.7 python-dateutil-2.6.1 s3transfer-0.1.13


    amazon-ebs: + sudo /usr/local/bin/aws --version
    amazon-ebs: sudo: /usr/local/bin/aws: command not found


==> amazon-ebs: Terminating the source AWS instance...

Rickard von Essen

unread,
Feb 27, 2018, 4:56:24 AM2/27/18
to packe...@googlegroups.com
Hard to say when there is so little information. Add -on-error=ask flag to your packer build command line and rerun. When it fails it will pause and you can jump into the instance and troubleshoot. 

--
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 packer-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/82a0df02-7d29-4235-96b8-d48fa8b6dc48%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alvaro Miranda Aguilera

unread,
Feb 27, 2018, 9:09:17 AM2/27/18
to packe...@googlegroups.com
hello

if you comment our the aws cli and dont' run any more steps I assume the box will be created fine

you are having a issue on how to install and use awscli

i would suggest spin a vm and get those commands a try until you can confirm they work

don't think is a packer issue


Alvaro


--
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 packer-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/82a0df02-7d29-4235-96b8-d48fa8b6dc48%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Pradeep Patra

unread,
Feb 27, 2018, 10:34:09 AM2/27/18
to Packer
When I run all the commands in a shell script it works fine without any error in a separate VM. Only when I run from packer build it fails.
To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool...@googlegroups.com.



--
Alvaro

Rickard von Essen

unread,
Feb 27, 2018, 10:39:19 AM2/27/18
to packe...@googlegroups.com
Most likely because you have a interactive shell etc. 

To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/002a8757-ff46-425f-aaf2-531b46661150%40googlegroups.com.

Alvaro Miranda Aguilera

unread,
Feb 27, 2018, 12:11:56 PM2/27/18
to packe...@googlegroups.com
run the script over ssh

ssh user@host "path to script"

Alvaro

To unsubscribe from this group and stop receiving emails from it, send an email to packer-tool+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/packer-tool/002a8757-ff46-425f-aaf2-531b46661150%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Gabo Kete

unread,
Feb 27, 2018, 7:35:01 PM2/27/18
to Packer
worth to check the following

Looks like within your sudoers you are resetting your environment and setting a secure path, this is enabled by default


Defaults  env_reset
Defaults  secure_path

Under secure_path you may want to add the path to your aws cli command... 




--
Alvaro

Reply all
Reply to author
Forward
0 new messages