1

I'm using packer, this is in my provisioners (or the relevant parts at least) right after a provisioner that installs ruby.

{ "type": "shell",
  "inline_shebang": "/bin/bash",
  "inline": [
    "source ~/.bash_profile",
    "rbenv versions",
    "ruby -v",
    "ls /home/ubuntu/.rbenv/versions/",
    "ls /home/ubuntu/.rbenv/",
    "sudo apt-get update",
    "sudo apt-get -y install unzip",
    "sudo apt-get -y install libqt4-dev libsndfile1-dev",
    "wget http://s3.amazonaws.com/ec2-downloads/ec2-ami-tools.zip",
    "sudo mkdir -p /usr/local/ec2",
    "sudo unzip ec2-ami-tools.zip -d /usr/local/ec2"
}

rbenv versions sees 2.1.6

ruby -v says it's 2.1.6

so ruby is definitely installed...

yet I get this error at the end of my packer bundle

==> amazon-instance: Bundling the volume...
    amazon-instance: /usr/local/ec2/ec2-ami-tools-1.5.7/bin/ec2-bundle-vol: line 6: ruby: command not found

the command I have for bundling the volume is

sudo -n env EC2_AMITOOL_HOME=/usr/local/ec2/ec2-ami-tools-1.5.7 /usr/local/ec2/ec2-ami-tools-1.5.7/bin/ec2-bundle-vol -k {{.KeyPath}}  -u {{.AccountId}} -c {{.CertPath}} -    r {{.Architecture}} -e {{.PrivatePath}}/* -d {{.Destination}} -p {{.Prefix}} --batch --no-filter"

I've tried to find any reference at all to someone else getting this error with ec2-ami-tools but with no success. Any pointers as to where I should look for information (already checked out ec2-ami-tools docs, packer docs referencing ec2-bundle-vol, other Packer configs, etc. but could have missed something) would be appreciated.

Morgan
  • 1,438
  • 3
  • 17
  • 32
  • what ami image do you use to packer? Do you mean that `rbenv` and `ruby` has been installed already before you provision? I am curious how the ruby running already? – BMW Jun 24 '15 at 12:42
  • I mean, I installed via a script provisioner rbenv and ruby and then ran the above inline provisioner. I'm using a base AMI image; latest w/instance storage from here (http://cloud-images.ubuntu.com/locator/ec2/). Not much on it. – Morgan Jun 24 '15 at 15:46
  • So this confused me. How you can get result with `rbenv` and `ruby -v` before you install them. – BMW Jun 25 '15 at 00:05
  • I ended up just using a chef cookbook that just installed ruby. As for your question, Chef has provisioners. The first provisioner installed rbenv and the associated ruby via a script. Then this provisioner ran. Since the script has installed rbenv and ruby, this provisioner had access to them. – Morgan Jun 25 '15 at 20:40
  • So share us the full story with detail codes. – BMW Jun 25 '15 at 22:31

1 Answers1

0

My guess is it's because you are bundling with sudo. I actually don't know what rbenv is, but I suspect that only the ubuntu user knows where to find ruby.

So see if sudo ruby -v gives you the right output. If it doesn't, there's your problem.