DevOps Classroom Series – 23/Oct/2020

Packer

  • Is an Opensource tool for creating virtual machine images for multiple platforms from a single configuration
  • For the scenario below Preview
  • From one configuration file we can create multiple vm images in different cloud /virtual platforms Preview
  • Lets install packer.
    • Windows:
      • Download the installable and install Refer Here
      • Use chocolatey to install packer choco install packer Preview Preview
    • Linux Machine: Download packer and add the executable to PATH
  • Packer configurations are written in json files
  • In Packer we write the template in Json Format. Refer Here for official docs
  • Packer template has the following structure
{
    "variables": {},
    "builders": [],
    "description": "",
    "provisioners": [],
    "post-processors" : []
}
  • Variable: This is input that can be passed by the user

  • builders:

    • This is required object
    • This is array of one or more objects
    • Each builder gives information to packer on where to create machine image
    • Refer Here for builders
  • provisioners:

    • For configuring software we would be using provisioners
  • post-processors

    • This is array of objects for post-processing
  • Manual Steps:

    • Lets create an ami with nginx installed
      • Create an ec2 instance
      • Install the software by logging in
      sudo apt update
      sudo apt install nginx -y
      
      • Create an amazon machine image Preview Preview Preview
      • Lets use packer to create nginx image
      • For amazon-ebs builder Refer Here
      • For Variables Refer Here
      • For Provisioners Refer Here
      • In this example we would be using shell provisioner
      • Refer Here for the changes
      • Execute packer build command and wait for the ami’s to be created Preview Preview Preview Preview Preview
  • Try to create nginx vm image on azure by following the documentation. Refer Here

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Please turn AdBlock off
Floating Social Media Icons by Acurax Wordpress Designers

Discover more from Direct DevOps from Quality Thought

Subscribe now to keep reading and get access to the full archive.

Continue reading

Visit Us On FacebookVisit Us On LinkedinVisit Us On Youtube