A shell provisioner is a Packer build component that executes shell commands on a temporary EC2 instance before Packer captures the configured instance as an AMI. section 15.3
Preinstalling Etherpad
An inline shell script installs Node.js and Git, prepares /opt/etherpad-lite, clones a pinned Etherpad branch, and runs its dependency installer. Packer then stops the instance, creates the AMI, and terminates the temporary instance. section 15.3
Listing 15.8 The Packer template to build an Etherpad AMI, part 3
build { name = "awsinaction-etherpad" sources = [ "source.amazon-ebs.etherpad" #1 ] provisioner "shell" { #2 inline = [ "curl -fsSL https:/ /rpm.nodesource.com/setup_14.x | sudo bash -", #3 "sudo yum install -y nodejs git", #4 "sudo mkdir /opt/etherpad-lite", "sudo chown -R ec2-user:ec2-user /opt/etherpad-lite", "cd /opt", "git clone --depth 1 --branch 1.8.17 https:/ /github.com/ AWSinAction/etherpad-lite.git", #5 "cd etherpad-lite", "./src/bin/installDeps.sh", #6 ] } } #1 References the source; see listing 15.7. #2 The shell provisioner executes a script on the temporary build instance. #3 Adds a YUM repository for Node.js #4 Installs Node.js and Git #5 Fetches Etherpad from GitHub #6 Installs Etherpad dependencies
Shows the shell provisioner syntax and the inline commands used to construct the Etherpad image. section 15.3
