I've been playing with packer lately and found it an amazing tool. But I'm failing to use installed tools in the installation script.
Here's an example packer template I've been playing with (I've know there are better ways to use this with scripts and provisioners. but for simplicity sake I'm learning with this) :
{
"variables":{
"aws_access_key": "{{env `AWS_ACCESS_KEY`}}",
"aws_secret_key": "{{env `AWS_SECRET_KEY`}}"
},
"builders":[{
"type": "amazon-ebs",
"access_key":"{{user `aws_access_key`}}",
"secret_key":"{{user `aws_secret_key`}}",
"region": "us-east-1",
"source_ami": "ami-de0d9eb7",
"instance_type": "t1.micro",
"ssh_username": "ubuntu",
"ami_name": "packer-example2 {{timestamp}}"
}],
"provisioners":[{
"type": "shell",
"inline":[
"sleep 30",
"echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen' | sudo tee /etc/apt/sources.list.d/mongodb.list",
"echo 'deb http://www.rabbitmq.com/debian/ testing main' | sudo tee /etc/apt/sources.list.d/rabbitmq.list",
"sudo apt-get-repository ppa:chris-lea/node.js",
"wget http://www.rabbitmq.com/rabbitmq-signing-key-public.asc",
"sudo apt-key add rabbitmq-signing-key-public.asc",
"sudo apt-get update",
"sudo apt-get install -y build-essential python-dev",
"sudo apt-get build-dep -y python-imaging",
"sudo apt-get install -y redis-server",
"sudo apt-get install -y mongodb-org",
"sudo apt-get install -y nodejs",
"sudo apt-get install -y nginx",
"sudo apt-get install -y rabbitmq-server",
"sudo apt-get install -y git",
"sudo apt-get -y install postgresql libpq-dev postgresql-contrib",
"sudo apt-get -y install htop",
"sudo apt-get -y install sysstat",
"sudo apt-get install -y curl",
"sudo apt-get install -y ntp",
"sudo apt-get install -y wget",
"npm install -g swamp bower grunt"
]
}]
}
And I'm getting the following error message:
amazon-ebs: sudo: npm: command not found
I know npm installs with nodejs (at least from my experience) so I'm probably missing something. I guess this would also happen when I try to use similar platform install tools as:pip, gem etc...