0% found this document useful (0 votes)
232 views24 pages

Terraform: Automation On Aws

Packer is an open source tool that automates the creation of machine images for multiple platforms like AWS, Docker, VirtualBox, and more. It embraces configuration management tools like Ansible, Chef, and Puppet to install and configure software within images. Using Packer, you can create portable images that launch fully provisioned machines within seconds, improving stability, testability, and allowing for consistent deployments across environments. Packer builds images by launching an instance, running provisioning scripts, and creating an AMI from the launched instance, which is then terminated.

Uploaded by

Nitin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
232 views24 pages

Terraform: Automation On Aws

Packer is an open source tool that automates the creation of machine images for multiple platforms like AWS, Docker, VirtualBox, and more. It embraces configuration management tools like Ansible, Chef, and Puppet to install and configure software within images. Using Packer, you can create portable images that launch fully provisioned machines within seconds, improving stability, testability, and allowing for consistent deployments across environments. Packer builds images by launching an instance, running provisioning scripts, and creating an AMI from the launched instance, which is then terminated.

Uploaded by

Nitin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

TERRAFORM

A U T O M A T I O N O N A W S
CHAPTER #6
PACKER
PACKER
WHY USE?

packer
Packer is an OpenSource Image Provisioning tool
developed by Hashicorp. It creates machine images
and makes the Configuration Management and Server
provisioning an easy Job. It can create Images for
multiple platforms like Docker, AWS, Oracle Virtual
Box, Digital Ocean, OpenStack, Linode, Azure etc.
PACKER
WHY USE?

packer
Packer is easy to use and automates the creation of
any type of machine image. It embraces modern
configuration management by encouraging you to use
a framework such as Ansible, Chef or Puppet to install
and configure the software within your Packer-made
images.
TERRAFORM
ADVANTAGES

#1 Super fast infrastructure deployment

Packer images allow you to launch completely


provisioned and configured machines in seconds,
rather than several minutes or hours.

#2 Multi-provider portability

Because Packer creates identical images for multiple


platforms, you can run production in AWS, staging/QA
in a private cloud like OpenStack, and development in
desktop virtualization solutions such as VMware or
VirtualBox. Each environment is running an identical
machine image, giving ultimate portability.
TERRAFORM
ADVANTAGES

#3 Improved stability

Packer installs and configures all the software for a


machine at the time the image is built. If there are
bugs in these scripts, they'll be caught early, rather
than several minutes after a machine is launched.

#4 Greater testability

After a machine image is built, that machine image can


be quickly launched and smoke tested to verify that
things appear to be working.
PACKER
DOWNLOAD & INSTALL
PACKER
DOWNLOAD & INSTALL
Download the packer and then "unzip" it.

# unzip packer_1.4.5_linux_amd64.zip
PACKER
DOWNLOAD & INSTALL
PACKER
CONFIRMING
PACKER
CONFIRMING
PACKER
BUILDING IMAGE

Packer configuration templates are written in JSON


format. A template has the following three main parts.

1. variables – Where you define custom variables.

2. builders – Where you mention all the required AMI


parameters.

3. provisioners – Where you can integrate a shell


script, ansible play or a chef cookbook for configuring
a required application in the AMI.
In the current directory (or create a directory specially
for packer code) create a file that contain your AWS
credentials and any other variable you wish to pass.
Now create a
json file to create
your custom image.
Call it -

simpleimage.json
Inspect and validate your file before starting the build
process.
Finally build a new packer image using your variable
file and json file as templates.
Actually Packer will create a new instance with your
configuration. Create a image out of it and then
terminate the instance.
You will find you AMI under "AMIs".
PACKER
BUILDING IMAGE #2
You can use a external script to be added with your
packer json file. You just need to pass the name of the
script file inside your json file. Here I have a
"apache.sh" script which I am adding as provisioner
inside my image's json file.
PACKER
BUILDING IMAGE #2
Just need to replace the "inline" to path / name of the
script inside the json file. Rest of the file, in my case,
is still the same.

Build the image again using "packer build" command.


PACKER
BUILDING IMAGE #2
During the image build process, you will see the httpd
package installation process.

Again the new image will be available under "AMIs"

You might also like