SlideShare a Scribd company logo
Packer
Introduction and usage
Beginners level
Why packer?
 No specific and powerful tool to create images for multiple platforms like
AWS, Azure, Google Cloud, Vagrant, virtual-box etc.
 Various tools for creating images for different platforms
 Packer is easy to use tool and automates the creation of any type of machine
image.
 It embraces modern configuration management by encouraging you to use a
framework such as Chef or Puppet to install and configure the software within
your Packer-made images
What is packer
 Packer is an open source tool for creating machine images for multiple
platforms from a single source configuration.
 Packer can run on every major operating system, creating machine images for
multiple platforms in parallel.
 Packer does not replace configuration management like Chef or Puppet. In
fact, when building images, Packer is able to use tools like Chef or Puppet to
install software onto the image.
Advantages of packer
 Super fast infrastructure deployment
 Multi provider support
 Improved stability
 Greater testability
Packer Installation
 Using a precompiled binary
 Installing from source
 An unofficial alternative installation method
Reference - https://www.packer.io/intro/getting-started/install.html
Packer Template
Templates are JSON files that configure the various components of Packer in
order to create one or more machine images.
 Builders (required parameter)
 Communicators (optional parameter)
 Engine
 Post processors (optional parameter)
 Provisioners (optional parameter)
 User variables (optional parameter)
Packer template explained
 builders - array of objects used to create the machine image
 description - string to provide the description of what template does
 post processor - array of objects defining various steps to take once builder
part is complete.
 Provisioners - It will be used to install and configure software for the
machines created by the builders.
 Variables - key/value strings that defines user variables contained in the
template.
Builders
 Some examples of builders are
 Amazon EC2
 Docker
 Azure
 Alicloud ECS
 Digital ocean
 Google cloud
Communicator
 Every build is associated with a single communicator, communicators are used
to establish a connection for provisioning a remote machine e.g.
ssh for linux box
winrm for window box
Template Engine
All strings within templates are processed by a common Packer templating
engine, where variables and functions can be used to modify the value of a
configuration parameter at runtime.
 The syntax of templates uses the following conventions:
 Anything template related happens within double-braces: {{ }}.
 Functions are specified directly within the braces, such as {{timestamp}}.
 Template variables are prefixed with a period and capitalized, such as
{{.Variable}}.
Provisioner
Provisioners use built-in and third-party software to install and configure the
machine image after booting. Provisioners prepare the system for use, so
common use cases for provisioners include:
 installing packages
 patching the kernel
 creating users
 downloading application code
Examples of provisioner
 Ansible (local and remote)
 Chef (client and solo)
 File
 Shell
 Salt
 Puppet
Post processor
Post-processors run after the image is built by the builder and provisioned by the
provisioner(s). Post-processors are optional, and they can be used to upload
artifacts, re-package, or more
 Import - alicloud/amazon
 Compress
 Checksum
 Docker - import/push/save/tag
 Google compute
 Shell
 Vagrant and vsphere
Packer commands
 packer build
 packer inspect
 packer validate
 packer fix
 packer build (-color -debug -force -except -on-error)
Builders sample code
 {
"builders": [
{
"type": "amazon-ebs",
"access_key": "...",
"secret_key": "...",
"region": "us-east-1",
"source_ami": "ami-fce3c696",
"instance_type": "t2.micro",
"ssh_username": ”ec2-user",
}
],
Provisioners sample code
"provisioners": [{
"type": "shell",
"inline": [
"sudo yum update -y",
"sudo yum install curl wget vim git mlocate zip unzip dstat jq ruby telnet nc bind-utils -y",
]
},
{
"type": "file",
"source": ”/tmp/dummy.tar.gz",
"destination": "/tmp/dummy.tar.gz"
}
]
Post processor sample code
"post-processors" : [
[
{
"type": "shell-local",
"inline": [ "/usr/bin/ovftool <packer-output-directory>/<vmware-name>.vmx <packer-out-directory>/<vmware-name>.ova" ]
}
{
"type": "amazon-import",
"access_key": "YOUR KEY HERE",
"secret_key": "YOUR SECRET KEY HERE",
"region": "us-east-1",
"s3_bucket_name": "importbucket",
"license_type": "BYOL"
}
}
]]
Simplest working code
cat sample1.json
{
"builders": [{
"type": "amazon-ebs",
"region": "us-east-1",
"source_ami": "ami-af22d9b9",
"instance_type": "t2.micro",
"ssh_username": "ubuntu",
"ami_name": "packer-example {{timestamp}}"
}]
}
Running your sample packer code
$packer validate sample1.json
Template validated successfully.
$packer inspect sample1.json
Variables:
<No variables>
Builders:
amazon-ebs
Provisioners:
<No provisioners>
$packer build sample1.json
Main steps executed in background
 Pre validating AMI Name
 Creating temporary keypair:
 Creating temporary security group for this instance:
 Authorizing access to port 22 from 0.0.0.0/0 in the temporary security group
 Launching a source AWS instance
 Adding tags to source instance
 Waiting for SSH to become available and connect to ssh
 Stopping the source instance
 Creating the AMI: packer-example
 Terminating the source AWS instance
 Deleting temporary security group.
 Deleting temporary keypair
 Build 'amazon-ebs' finished.
Packer code with variables
Use of variables in packer
 Defining dynamically by passing parameters
packer build -var ‘aws_access_key=XXXXXXX ’ -var ‘aws_secret_key=test-packer’
We can define all the variables in a file and parse the file while running packer
packer build -var-file=vars.json
cat var.json
{
"aws_access_key": “XXXXXXX”,
"aws_secret_key": “XXXXXXX”,
}
 Define inside the variable block (main file) – not recommended
Packer code with provisioners type shell-1
Packer code with provisioners shell-2
Packer inspect shows type of provisioners used
Note: shell-1 and shell-2 in above examples will return the same output
Provisioners Advanced
 type - ansible-local
Runs playbook on remote machine in local mode and playbooks needs to be uploaded from your build
machine
{
"type": "ansible-local",
"playbook_file": "local.yml"
}
 type – ansible
It dynamically creates an Ansible inventory file configured to use SSH to the machine being provisioned
by Packer, executes ansible-playbook.
{
"type": "ansible",
"extra_arguments": [ "-vvvv" ],
"playbook_file": "./playbook.yml"
}
 type - chef-client
It installs and configures software on machines built by Packer using chef-client. Packer configures a
Chef client to talk to a remote Chef Server to provision the machine. The provisioner will even install
Chef onto your machine if it isn't already installed, using the official Chef installers provided by Chef.
{
"type": "chef-client",
"server_url": "https://mychefserver.com/"
}
 type – chef-solo
The Chef solo Packer provisioner installs and configures software on machines built by Packer using chef-
solo. Cookbooks can be uploaded from your local machine to the remote machine or remote paths can
be used.
{
"type": "chef-solo",
"cookbook_paths": ["cookbooks"]
}
 type - file
uploads files to machines built by Packer. The recommended usage of the file provisioner is to use it to
upload files, and then use shell provisioner to move them to the proper place, set permissions, etc.
{
"type": "file",
"source": "app.tar.gz",
"destination": "/tmp/app.tar.gz"
}
 type – puppet-server
provisions Packer machines with Puppet by connecting to a Puppet master.
{
"type": "puppet-server",
"extra_arguments": "--test --pluginsync",
"facter": {
"server_role": "webserver"
}
}
 type – puppet-masterless
It configures Puppet to run on the machines by Packer from local modules and manifest files. Modules
and manifests can be uploaded from your local machine to the remote machine. Puppet runs in
masterless mode, meaning it never communicates to a Puppet master.
{
"type": "puppet-masterless",
"manifest_file": "site.pp"
}
 type – shell
The shell Packer provisioner provisions machines built by Packer using shell scripts. Shell provisioning is
the easiest way to get software installed and configured on a machine.
{
"type": "shell",
"inline”, “script”, “scripts”
}
 type – shell-local
shell-local will run the shell script on your build server
{
"type": "shell-local",
"environment_vars": ["PROVISIONERTEST=ProvisionerTest1"],
"scripts": ["./scripts/dummy.sh"]
}
 type – custom
that install and configure software into a running machine prior to turning that machine into an image.
An example of a provisioner is the shell provisioner, which runs shell scripts within the machines.
References
 https://www.packer.io

More Related Content

What's hot

Docker Container Security
Docker Container SecurityDocker Container Security
Docker Container Security
Suraj Khetani
 
Introduction to docker
Introduction to dockerIntroduction to docker
Introduction to docker
Instruqt
 
AWS Code Services
AWS Code ServicesAWS Code Services
AWS Code Services
Amazon Web Services
 
Docker
DockerDocker
Docker Basics
Docker BasicsDocker Basics
Docker Basics
DuckDuckGo
 
Docker: From Zero to Hero
Docker: From Zero to HeroDocker: From Zero to Hero
Docker: From Zero to Hero
fazalraja
 
DevOps with Kubernetes
DevOps with KubernetesDevOps with Kubernetes
DevOps with Kubernetes
EastBanc Tachnologies
 
Kubernetes: A Short Introduction (2019)
Kubernetes: A Short Introduction (2019)Kubernetes: A Short Introduction (2019)
Kubernetes: A Short Introduction (2019)
Megan O'Keefe
 
Helm – The package manager for Kubernetes
Helm – The package manager for KubernetesHelm – The package manager for Kubernetes
Helm – The package manager for Kubernetes
FabianRosenthal1
 
Container security
Container securityContainer security
Container security
Anthony Chow
 
Security Process in DevSecOps
Security Process in DevSecOpsSecurity Process in DevSecOps
Security Process in DevSecOps
Opsta
 
Docker introduction
Docker introductionDocker introduction
Docker introduction
Gourav Varma
 
Terraform on Azure
Terraform on AzureTerraform on Azure
Terraform on Azure
Julien Corioland
 
Kubernetes security
Kubernetes securityKubernetes security
Kubernetes security
Thomas Fricke
 
Helm - Package Manager for Kubernetes
Helm - Package Manager for KubernetesHelm - Package Manager for Kubernetes
Helm - Package Manager for Kubernetes
Knoldus Inc.
 
Running Microservices on Amazon ECS - AWS April 2016 Webinar Series
Running Microservices on Amazon ECS - AWS April 2016 Webinar SeriesRunning Microservices on Amazon ECS - AWS April 2016 Webinar Series
Running Microservices on Amazon ECS - AWS April 2016 Webinar Series
Amazon Web Services
 
Introduction to helm
Introduction to helmIntroduction to helm
Introduction to helm
Jeeva Chelladhurai
 
Azure kubernetes service (aks)
Azure kubernetes service (aks)Azure kubernetes service (aks)
Azure kubernetes service (aks)
Akash Agrawal
 
Kubernetes Application Deployment with Helm - A beginner Guide!
Kubernetes Application Deployment with Helm - A beginner Guide!Kubernetes Application Deployment with Helm - A beginner Guide!
Kubernetes Application Deployment with Helm - A beginner Guide!
Krishna-Kumar
 
Docker Networking - Common Issues and Troubleshooting Techniques
Docker Networking - Common Issues and Troubleshooting TechniquesDocker Networking - Common Issues and Troubleshooting Techniques
Docker Networking - Common Issues and Troubleshooting Techniques
Sreenivas Makam
 

What's hot (20)

Docker Container Security
Docker Container SecurityDocker Container Security
Docker Container Security
 
Introduction to docker
Introduction to dockerIntroduction to docker
Introduction to docker
 
AWS Code Services
AWS Code ServicesAWS Code Services
AWS Code Services
 
Docker
DockerDocker
Docker
 
Docker Basics
Docker BasicsDocker Basics
Docker Basics
 
Docker: From Zero to Hero
Docker: From Zero to HeroDocker: From Zero to Hero
Docker: From Zero to Hero
 
DevOps with Kubernetes
DevOps with KubernetesDevOps with Kubernetes
DevOps with Kubernetes
 
Kubernetes: A Short Introduction (2019)
Kubernetes: A Short Introduction (2019)Kubernetes: A Short Introduction (2019)
Kubernetes: A Short Introduction (2019)
 
Helm – The package manager for Kubernetes
Helm – The package manager for KubernetesHelm – The package manager for Kubernetes
Helm – The package manager for Kubernetes
 
Container security
Container securityContainer security
Container security
 
Security Process in DevSecOps
Security Process in DevSecOpsSecurity Process in DevSecOps
Security Process in DevSecOps
 
Docker introduction
Docker introductionDocker introduction
Docker introduction
 
Terraform on Azure
Terraform on AzureTerraform on Azure
Terraform on Azure
 
Kubernetes security
Kubernetes securityKubernetes security
Kubernetes security
 
Helm - Package Manager for Kubernetes
Helm - Package Manager for KubernetesHelm - Package Manager for Kubernetes
Helm - Package Manager for Kubernetes
 
Running Microservices on Amazon ECS - AWS April 2016 Webinar Series
Running Microservices on Amazon ECS - AWS April 2016 Webinar SeriesRunning Microservices on Amazon ECS - AWS April 2016 Webinar Series
Running Microservices on Amazon ECS - AWS April 2016 Webinar Series
 
Introduction to helm
Introduction to helmIntroduction to helm
Introduction to helm
 
Azure kubernetes service (aks)
Azure kubernetes service (aks)Azure kubernetes service (aks)
Azure kubernetes service (aks)
 
Kubernetes Application Deployment with Helm - A beginner Guide!
Kubernetes Application Deployment with Helm - A beginner Guide!Kubernetes Application Deployment with Helm - A beginner Guide!
Kubernetes Application Deployment with Helm - A beginner Guide!
 
Docker Networking - Common Issues and Troubleshooting Techniques
Docker Networking - Common Issues and Troubleshooting TechniquesDocker Networking - Common Issues and Troubleshooting Techniques
Docker Networking - Common Issues and Troubleshooting Techniques
 

Similar to Packer

Hashicorp-Terraform_Packer_Vault-by Sushil
Hashicorp-Terraform_Packer_Vault-by SushilHashicorp-Terraform_Packer_Vault-by Sushil
Hashicorp-Terraform_Packer_Vault-by Sushil
Sushil Kumar
 
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Carlos Sanchez
 
PVS-Studio: analyzing pull requests in Azure DevOps using self-hosted agents
PVS-Studio: analyzing pull requests in Azure DevOps using self-hosted agentsPVS-Studio: analyzing pull requests in Azure DevOps using self-hosted agents
PVS-Studio: analyzing pull requests in Azure DevOps using self-hosted agents
Andrey Karpov
 
Packer, where DevOps begins
Packer, where DevOps beginsPacker, where DevOps begins
Packer, where DevOps begins
Jeff Hung
 
Baking in the cloud with packer and puppet
Baking in the cloud with packer and puppetBaking in the cloud with packer and puppet
Baking in the cloud with packer and puppet
Alan Parkinson
 
Create your very own Development Environment with Vagrant and Packer
Create your very own Development Environment with Vagrant and PackerCreate your very own Development Environment with Vagrant and Packer
Create your very own Development Environment with Vagrant and Packer
frastel
 
Deployment automation
Deployment automationDeployment automation
Deployment automation
Riccardo Lemmi
 
Immutable AWS Deployments with Packer and Jenkins
Immutable AWS Deployments with Packer and JenkinsImmutable AWS Deployments with Packer and Jenkins
Immutable AWS Deployments with Packer and Jenkins
Manish Pandit
 
DevOps for the Enterprise: Virtual Office Hours
DevOps for the Enterprise: Virtual Office HoursDevOps for the Enterprise: Virtual Office Hours
DevOps for the Enterprise: Virtual Office Hours
Amazon Web Services
 
Installaling Puppet Master and Agent
Installaling Puppet Master and AgentInstallaling Puppet Master and Agent
Installaling Puppet Master and Agent
Ranjit Avasarala
 
Security Testing Using Infrastructure-As-Code
Security Testing Using Infrastructure-As-CodeSecurity Testing Using Infrastructure-As-Code
Security Testing Using Infrastructure-As-Code
Vision Concepts Infrastructure Services Solution
 
Our Puppet Story (Linuxtag 2014)
Our Puppet Story (Linuxtag 2014)Our Puppet Story (Linuxtag 2014)
Our Puppet Story (Linuxtag 2014)
DECK36
 
Vagrant For DevOps
Vagrant For DevOpsVagrant For DevOps
Vagrant For DevOps
Lalatendu Mohanty
 
Dockerization of Azure Platform
Dockerization of Azure PlatformDockerization of Azure Platform
Dockerization of Azure Platform
nirajrules
 
One-Man Ops
One-Man OpsOne-Man Ops
One-Man Ops
Jos Boumans
 
From Dev to DevOps - Codemotion ES 2012
From Dev to DevOps - Codemotion ES 2012From Dev to DevOps - Codemotion ES 2012
From Dev to DevOps - Codemotion ES 2012
Carlos Sanchez
 
Build Automation 101
Build Automation 101Build Automation 101
Build Automation 101
Martin Jackson
 
Vagrant Binding JayDay 2013
Vagrant Binding JayDay 2013Vagrant Binding JayDay 2013
Vagrant Binding JayDay 2013
Hendrik Ebbers
 
Continuous Delivery: The Next Frontier
Continuous Delivery: The Next FrontierContinuous Delivery: The Next Frontier
Continuous Delivery: The Next Frontier
Carlos Sanchez
 
EC2 AMI Factory with Chef, Berkshelf, and Packer
EC2 AMI Factory with Chef, Berkshelf, and PackerEC2 AMI Factory with Chef, Berkshelf, and Packer
EC2 AMI Factory with Chef, Berkshelf, and Packer
George Miranda
 

Similar to Packer (20)

Hashicorp-Terraform_Packer_Vault-by Sushil
Hashicorp-Terraform_Packer_Vault-by SushilHashicorp-Terraform_Packer_Vault-by Sushil
Hashicorp-Terraform_Packer_Vault-by Sushil
 
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
Continuous Delivery with Maven, Puppet and Tomcat - ApacheCon NA 2013
 
PVS-Studio: analyzing pull requests in Azure DevOps using self-hosted agents
PVS-Studio: analyzing pull requests in Azure DevOps using self-hosted agentsPVS-Studio: analyzing pull requests in Azure DevOps using self-hosted agents
PVS-Studio: analyzing pull requests in Azure DevOps using self-hosted agents
 
Packer, where DevOps begins
Packer, where DevOps beginsPacker, where DevOps begins
Packer, where DevOps begins
 
Baking in the cloud with packer and puppet
Baking in the cloud with packer and puppetBaking in the cloud with packer and puppet
Baking in the cloud with packer and puppet
 
Create your very own Development Environment with Vagrant and Packer
Create your very own Development Environment with Vagrant and PackerCreate your very own Development Environment with Vagrant and Packer
Create your very own Development Environment with Vagrant and Packer
 
Deployment automation
Deployment automationDeployment automation
Deployment automation
 
Immutable AWS Deployments with Packer and Jenkins
Immutable AWS Deployments with Packer and JenkinsImmutable AWS Deployments with Packer and Jenkins
Immutable AWS Deployments with Packer and Jenkins
 
DevOps for the Enterprise: Virtual Office Hours
DevOps for the Enterprise: Virtual Office HoursDevOps for the Enterprise: Virtual Office Hours
DevOps for the Enterprise: Virtual Office Hours
 
Installaling Puppet Master and Agent
Installaling Puppet Master and AgentInstallaling Puppet Master and Agent
Installaling Puppet Master and Agent
 
Security Testing Using Infrastructure-As-Code
Security Testing Using Infrastructure-As-CodeSecurity Testing Using Infrastructure-As-Code
Security Testing Using Infrastructure-As-Code
 
Our Puppet Story (Linuxtag 2014)
Our Puppet Story (Linuxtag 2014)Our Puppet Story (Linuxtag 2014)
Our Puppet Story (Linuxtag 2014)
 
Vagrant For DevOps
Vagrant For DevOpsVagrant For DevOps
Vagrant For DevOps
 
Dockerization of Azure Platform
Dockerization of Azure PlatformDockerization of Azure Platform
Dockerization of Azure Platform
 
One-Man Ops
One-Man OpsOne-Man Ops
One-Man Ops
 
From Dev to DevOps - Codemotion ES 2012
From Dev to DevOps - Codemotion ES 2012From Dev to DevOps - Codemotion ES 2012
From Dev to DevOps - Codemotion ES 2012
 
Build Automation 101
Build Automation 101Build Automation 101
Build Automation 101
 
Vagrant Binding JayDay 2013
Vagrant Binding JayDay 2013Vagrant Binding JayDay 2013
Vagrant Binding JayDay 2013
 
Continuous Delivery: The Next Frontier
Continuous Delivery: The Next FrontierContinuous Delivery: The Next Frontier
Continuous Delivery: The Next Frontier
 
EC2 AMI Factory with Chef, Berkshelf, and Packer
EC2 AMI Factory with Chef, Berkshelf, and PackerEC2 AMI Factory with Chef, Berkshelf, and Packer
EC2 AMI Factory with Chef, Berkshelf, and Packer
 

Recently uploaded

GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
Neo4j
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
Edge AI and Vision Alliance
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
Matthew Sinclair
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
danishmna97
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
SOFTTECHHUB
 
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Zilliz
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
Claudio Di Ciccio
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
Neo4j
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
Pixlogix Infotech
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Vladimir Iglovikov, Ph.D.
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
Daiki Mogmet Ito
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 

Recently uploaded (20)

GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024GraphSummit Singapore | The Art of the  Possible with Graph - Q2 2024
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
“Building and Scaling AI Applications with the Nx AI Manager,” a Presentation...
 
20240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 202420240609 QFM020 Irresponsible AI Reading List May 2024
20240609 QFM020 Irresponsible AI Reading List May 2024
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
How to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptxHow to Get CNIC Information System with Paksim Ga.pptx
How to Get CNIC Information System with Paksim Ga.pptx
 
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
Goodbye Windows 11: Make Way for Nitrux Linux 3.5.0!
 
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
Introducing Milvus Lite: Easy-to-Install, Easy-to-Use vector database for you...
 
“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”“I’m still / I’m still / Chaining from the Block”
“I’m still / I’m still / Chaining from the Block”
 
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
GraphSummit Singapore | Enhancing Changi Airport Group's Passenger Experience...
 
20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website20 Comprehensive Checklist of Designing and Developing a Website
20 Comprehensive Checklist of Designing and Developing a Website
 
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AIEnchancing adoption of Open Source Libraries. A case study on Albumentations.AI
Enchancing adoption of Open Source Libraries. A case study on Albumentations.AI
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
How to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For FlutterHow to use Firebase Data Connect For Flutter
How to use Firebase Data Connect For Flutter
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 

Packer

  • 2. Why packer?  No specific and powerful tool to create images for multiple platforms like AWS, Azure, Google Cloud, Vagrant, virtual-box etc.  Various tools for creating images for different platforms  Packer is easy to use tool and automates the creation of any type of machine image.  It embraces modern configuration management by encouraging you to use a framework such as Chef or Puppet to install and configure the software within your Packer-made images
  • 3.
  • 4. What is packer  Packer is an open source tool for creating machine images for multiple platforms from a single source configuration.  Packer can run on every major operating system, creating machine images for multiple platforms in parallel.  Packer does not replace configuration management like Chef or Puppet. In fact, when building images, Packer is able to use tools like Chef or Puppet to install software onto the image.
  • 5. Advantages of packer  Super fast infrastructure deployment  Multi provider support  Improved stability  Greater testability
  • 6. Packer Installation  Using a precompiled binary  Installing from source  An unofficial alternative installation method Reference - https://www.packer.io/intro/getting-started/install.html
  • 7. Packer Template Templates are JSON files that configure the various components of Packer in order to create one or more machine images.  Builders (required parameter)  Communicators (optional parameter)  Engine  Post processors (optional parameter)  Provisioners (optional parameter)  User variables (optional parameter)
  • 8. Packer template explained  builders - array of objects used to create the machine image  description - string to provide the description of what template does  post processor - array of objects defining various steps to take once builder part is complete.  Provisioners - It will be used to install and configure software for the machines created by the builders.  Variables - key/value strings that defines user variables contained in the template.
  • 9. Builders  Some examples of builders are  Amazon EC2  Docker  Azure  Alicloud ECS  Digital ocean  Google cloud
  • 10. Communicator  Every build is associated with a single communicator, communicators are used to establish a connection for provisioning a remote machine e.g. ssh for linux box winrm for window box
  • 11. Template Engine All strings within templates are processed by a common Packer templating engine, where variables and functions can be used to modify the value of a configuration parameter at runtime.  The syntax of templates uses the following conventions:  Anything template related happens within double-braces: {{ }}.  Functions are specified directly within the braces, such as {{timestamp}}.  Template variables are prefixed with a period and capitalized, such as {{.Variable}}.
  • 12. Provisioner Provisioners use built-in and third-party software to install and configure the machine image after booting. Provisioners prepare the system for use, so common use cases for provisioners include:  installing packages  patching the kernel  creating users  downloading application code
  • 13. Examples of provisioner  Ansible (local and remote)  Chef (client and solo)  File  Shell  Salt  Puppet
  • 14. Post processor Post-processors run after the image is built by the builder and provisioned by the provisioner(s). Post-processors are optional, and they can be used to upload artifacts, re-package, or more  Import - alicloud/amazon  Compress  Checksum  Docker - import/push/save/tag  Google compute  Shell  Vagrant and vsphere
  • 15.
  • 16. Packer commands  packer build  packer inspect  packer validate  packer fix  packer build (-color -debug -force -except -on-error)
  • 17. Builders sample code  { "builders": [ { "type": "amazon-ebs", "access_key": "...", "secret_key": "...", "region": "us-east-1", "source_ami": "ami-fce3c696", "instance_type": "t2.micro", "ssh_username": ”ec2-user", } ],
  • 18. Provisioners sample code "provisioners": [{ "type": "shell", "inline": [ "sudo yum update -y", "sudo yum install curl wget vim git mlocate zip unzip dstat jq ruby telnet nc bind-utils -y", ] }, { "type": "file", "source": ”/tmp/dummy.tar.gz", "destination": "/tmp/dummy.tar.gz" } ]
  • 19. Post processor sample code "post-processors" : [ [ { "type": "shell-local", "inline": [ "/usr/bin/ovftool <packer-output-directory>/<vmware-name>.vmx <packer-out-directory>/<vmware-name>.ova" ] } { "type": "amazon-import", "access_key": "YOUR KEY HERE", "secret_key": "YOUR SECRET KEY HERE", "region": "us-east-1", "s3_bucket_name": "importbucket", "license_type": "BYOL" } } ]]
  • 20. Simplest working code cat sample1.json { "builders": [{ "type": "amazon-ebs", "region": "us-east-1", "source_ami": "ami-af22d9b9", "instance_type": "t2.micro", "ssh_username": "ubuntu", "ami_name": "packer-example {{timestamp}}" }] }
  • 21. Running your sample packer code $packer validate sample1.json Template validated successfully. $packer inspect sample1.json Variables: <No variables> Builders: amazon-ebs Provisioners: <No provisioners> $packer build sample1.json
  • 22. Main steps executed in background  Pre validating AMI Name  Creating temporary keypair:  Creating temporary security group for this instance:  Authorizing access to port 22 from 0.0.0.0/0 in the temporary security group  Launching a source AWS instance  Adding tags to source instance  Waiting for SSH to become available and connect to ssh  Stopping the source instance  Creating the AMI: packer-example  Terminating the source AWS instance  Deleting temporary security group.  Deleting temporary keypair  Build 'amazon-ebs' finished.
  • 23. Packer code with variables
  • 24. Use of variables in packer  Defining dynamically by passing parameters packer build -var ‘aws_access_key=XXXXXXX ’ -var ‘aws_secret_key=test-packer’ We can define all the variables in a file and parse the file while running packer packer build -var-file=vars.json cat var.json { "aws_access_key": “XXXXXXX”, "aws_secret_key": “XXXXXXX”, }  Define inside the variable block (main file) – not recommended
  • 25. Packer code with provisioners type shell-1
  • 26. Packer code with provisioners shell-2
  • 27. Packer inspect shows type of provisioners used Note: shell-1 and shell-2 in above examples will return the same output
  • 28. Provisioners Advanced  type - ansible-local Runs playbook on remote machine in local mode and playbooks needs to be uploaded from your build machine { "type": "ansible-local", "playbook_file": "local.yml" }  type – ansible It dynamically creates an Ansible inventory file configured to use SSH to the machine being provisioned by Packer, executes ansible-playbook. { "type": "ansible", "extra_arguments": [ "-vvvv" ], "playbook_file": "./playbook.yml" }
  • 29.  type - chef-client It installs and configures software on machines built by Packer using chef-client. Packer configures a Chef client to talk to a remote Chef Server to provision the machine. The provisioner will even install Chef onto your machine if it isn't already installed, using the official Chef installers provided by Chef. { "type": "chef-client", "server_url": "https://mychefserver.com/" }  type – chef-solo The Chef solo Packer provisioner installs and configures software on machines built by Packer using chef- solo. Cookbooks can be uploaded from your local machine to the remote machine or remote paths can be used. { "type": "chef-solo", "cookbook_paths": ["cookbooks"] }
  • 30.  type - file uploads files to machines built by Packer. The recommended usage of the file provisioner is to use it to upload files, and then use shell provisioner to move them to the proper place, set permissions, etc. { "type": "file", "source": "app.tar.gz", "destination": "/tmp/app.tar.gz" }  type – puppet-server provisions Packer machines with Puppet by connecting to a Puppet master. { "type": "puppet-server", "extra_arguments": "--test --pluginsync", "facter": { "server_role": "webserver" } }
  • 31.  type – puppet-masterless It configures Puppet to run on the machines by Packer from local modules and manifest files. Modules and manifests can be uploaded from your local machine to the remote machine. Puppet runs in masterless mode, meaning it never communicates to a Puppet master. { "type": "puppet-masterless", "manifest_file": "site.pp" }  type – shell The shell Packer provisioner provisions machines built by Packer using shell scripts. Shell provisioning is the easiest way to get software installed and configured on a machine. { "type": "shell", "inline”, “script”, “scripts” }
  • 32.  type – shell-local shell-local will run the shell script on your build server { "type": "shell-local", "environment_vars": ["PROVISIONERTEST=ProvisionerTest1"], "scripts": ["./scripts/dummy.sh"] }  type – custom that install and configure software into a running machine prior to turning that machine into an image. An example of a provisioner is the shell provisioner, which runs shell scripts within the machines.