SlideShare uma empresa Scribd logo
1 de 33
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

Mais conteúdo relacionado

Mais procurados

Ansible Introduction
Ansible Introduction Ansible Introduction
Ansible Introduction Robert Reiz
 
Docker introduction &amp; benefits
Docker introduction &amp; benefitsDocker introduction &amp; benefits
Docker introduction &amp; benefitsAmit Manwade
 
Introduction to ansible
Introduction to ansibleIntroduction to ansible
Introduction to ansibleOmid Vahdaty
 
Configuration management I - Ansible + Packer
Configuration management I - Ansible + PackerConfiguration management I - Ansible + Packer
Configuration management I - Ansible + PackerXavier Serrat Bordas
 
DevOps Meetup ansible
DevOps Meetup   ansibleDevOps Meetup   ansible
DevOps Meetup ansiblesriram_rajan
 
Docker introduction (1)
Docker introduction (1)Docker introduction (1)
Docker introduction (1)Gourav Varma
 
Docker Swarm for Beginner
Docker Swarm for BeginnerDocker Swarm for Beginner
Docker Swarm for BeginnerShahzad Masud
 
Docker Security workshop slides
Docker Security workshop slidesDocker Security workshop slides
Docker Security workshop slidesDocker, Inc.
 
Docker 101 : Introduction to Docker and Containers
Docker 101 : Introduction to Docker and ContainersDocker 101 : Introduction to Docker and Containers
Docker 101 : Introduction to Docker and ContainersYajushi Srivastava
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentationJohn Lynch
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker IntroductionHao Fan
 

Mais procurados (20)

Ansible Introduction
Ansible Introduction Ansible Introduction
Ansible Introduction
 
Ansible - Introduction
Ansible - IntroductionAnsible - Introduction
Ansible - Introduction
 
Jenkins CI
Jenkins CIJenkins CI
Jenkins CI
 
Docker introduction &amp; benefits
Docker introduction &amp; benefitsDocker introduction &amp; benefits
Docker introduction &amp; benefits
 
Introduction to ansible
Introduction to ansibleIntroduction to ansible
Introduction to ansible
 
Gradle Introduction
Gradle IntroductionGradle Introduction
Gradle Introduction
 
Configuration management I - Ansible + Packer
Configuration management I - Ansible + PackerConfiguration management I - Ansible + Packer
Configuration management I - Ansible + Packer
 
DevOps Meetup ansible
DevOps Meetup   ansibleDevOps Meetup   ansible
DevOps Meetup ansible
 
Docker introduction (1)
Docker introduction (1)Docker introduction (1)
Docker introduction (1)
 
Docker Swarm for Beginner
Docker Swarm for BeginnerDocker Swarm for Beginner
Docker Swarm for Beginner
 
Docker Security workshop slides
Docker Security workshop slidesDocker Security workshop slides
Docker Security workshop slides
 
Docker 101 : Introduction to Docker and Containers
Docker 101 : Introduction to Docker and ContainersDocker 101 : Introduction to Docker and Containers
Docker 101 : Introduction to Docker and Containers
 
Jenkins
JenkinsJenkins
Jenkins
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker Introduction
 
What is Docker
What is DockerWhat is Docker
What is Docker
 
Intro To Docker
Intro To DockerIntro To Docker
Intro To Docker
 
ansible why ?
ansible why ?ansible why ?
ansible why ?
 
Introduction to container based virtualization with docker
Introduction to container based virtualization with dockerIntroduction to container based virtualization with docker
Introduction to container based virtualization with docker
 
Ansible
AnsibleAnsible
Ansible
 

Semelhante a Packer

Automation with Packer and TerraForm
Automation with Packer and TerraFormAutomation with Packer and TerraForm
Automation with Packer and TerraFormWesley Charles Blake
 
Hashicorp-Terraform_Packer_Vault-by Sushil
Hashicorp-Terraform_Packer_Vault-by SushilHashicorp-Terraform_Packer_Vault-by Sushil
Hashicorp-Terraform_Packer_Vault-by SushilSushil 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 2013Carlos 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 agentsAndrey Karpov
 
Packer, where DevOps begins
Packer, where DevOps beginsPacker, where DevOps begins
Packer, where DevOps beginsJeff 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 puppetAlan 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 Packerfrastel
 
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 JenkinsManish 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 HoursAmazon Web Services
 
Installaling Puppet Master and Agent
Installaling Puppet Master and AgentInstallaling Puppet Master and Agent
Installaling Puppet Master and AgentRanjit Avasarala
 
Our Puppet Story (Linuxtag 2014)
Our Puppet Story (Linuxtag 2014)Our Puppet Story (Linuxtag 2014)
Our Puppet Story (Linuxtag 2014)DECK36
 
Dockerization of Azure Platform
Dockerization of Azure PlatformDockerization of Azure Platform
Dockerization of Azure Platformnirajrules
 
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 2012Carlos Sanchez
 
Vagrant Binding JayDay 2013
Vagrant Binding JayDay 2013Vagrant Binding JayDay 2013
Vagrant Binding JayDay 2013Hendrik Ebbers
 
Continuous Delivery: The Next Frontier
Continuous Delivery: The Next FrontierContinuous Delivery: The Next Frontier
Continuous Delivery: The Next FrontierCarlos Sanchez
 

Semelhante a Packer (20)

Automation with Packer and TerraForm
Automation with Packer and TerraFormAutomation with Packer and TerraForm
Automation with Packer and TerraForm
 
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
 

Último

Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 

Último (20)

Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 

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.