SlideShare una empresa de 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

Más contenido relacionado

La actualidad más candente

Docker Container Security
Docker Container SecurityDocker Container Security
Docker Container SecuritySuraj Khetani
 
EKS vs GKE vs AKS - Evaluating Kubernetes in the Cloud
EKS vs GKE vs AKS - Evaluating Kubernetes in the CloudEKS vs GKE vs AKS - Evaluating Kubernetes in the Cloud
EKS vs GKE vs AKS - Evaluating Kubernetes in the CloudDevOps.com
 
Introduction to kubernetes
Introduction to kubernetesIntroduction to kubernetes
Introduction to kubernetesRishabh Indoria
 
Steering the Course with Helm
Steering the Course with HelmSteering the Course with Helm
Steering the Course with HelmDirk Jablonski
 
Deploying OpenShift Container Platform on AWS by Red Hat
Deploying OpenShift Container Platform on AWS by Red HatDeploying OpenShift Container Platform on AWS by Red Hat
Deploying OpenShift Container Platform on AWS by Red HatAmazon Web Services
 
Terraform -- Infrastructure as Code
Terraform -- Infrastructure as CodeTerraform -- Infrastructure as Code
Terraform -- Infrastructure as CodeMartin Schütte
 
Integrating Security into DevOps and CI / CD Environments - Pop-up Loft TLV 2017
Integrating Security into DevOps and CI / CD Environments - Pop-up Loft TLV 2017Integrating Security into DevOps and CI / CD Environments - Pop-up Loft TLV 2017
Integrating Security into DevOps and CI / CD Environments - Pop-up Loft TLV 2017Amazon Web Services
 
Kubernetes extensibility: CRDs & Operators
Kubernetes extensibility: CRDs & OperatorsKubernetes extensibility: CRDs & Operators
Kubernetes extensibility: CRDs & OperatorsSIGHUP
 
Kubernetes Monitoring & Best Practices
Kubernetes Monitoring & Best PracticesKubernetes Monitoring & Best Practices
Kubernetes Monitoring & Best PracticesAjeet Singh Raina
 
Introduction to Kubernetes and Google Container Engine (GKE)
Introduction to Kubernetes and Google Container Engine (GKE)Introduction to Kubernetes and Google Container Engine (GKE)
Introduction to Kubernetes and Google Container Engine (GKE)Opsta
 
Infrastructure as Code with Terraform and Ansible
Infrastructure as Code with Terraform and AnsibleInfrastructure as Code with Terraform and Ansible
Infrastructure as Code with Terraform and AnsibleDevOps Meetup Bern
 
Monitoring, Logging and Tracing on Kubernetes
Monitoring, Logging and Tracing on KubernetesMonitoring, Logging and Tracing on Kubernetes
Monitoring, Logging and Tracing on KubernetesMartin Etmajer
 
Docker Networking Overview
Docker Networking OverviewDocker Networking Overview
Docker Networking OverviewSreenivas Makam
 

La actualidad más candente (20)

Docker Container Security
Docker Container SecurityDocker Container Security
Docker Container Security
 
Docker swarm
Docker swarmDocker swarm
Docker swarm
 
EKS vs GKE vs AKS - Evaluating Kubernetes in the Cloud
EKS vs GKE vs AKS - Evaluating Kubernetes in the CloudEKS vs GKE vs AKS - Evaluating Kubernetes in the Cloud
EKS vs GKE vs AKS - Evaluating Kubernetes in the Cloud
 
Container Security
Container SecurityContainer Security
Container Security
 
Best Practices with Azure & Kubernetes
Best Practices with Azure & KubernetesBest Practices with Azure & Kubernetes
Best Practices with Azure & Kubernetes
 
Intro to kubernetes
Intro to kubernetesIntro to kubernetes
Intro to kubernetes
 
Introduction to kubernetes
Introduction to kubernetesIntroduction to kubernetes
Introduction to kubernetes
 
Steering the Course with Helm
Steering the Course with HelmSteering the Course with Helm
Steering the Course with Helm
 
Deploying OpenShift Container Platform on AWS by Red Hat
Deploying OpenShift Container Platform on AWS by Red HatDeploying OpenShift Container Platform on AWS by Red Hat
Deploying OpenShift Container Platform on AWS by Red Hat
 
Terraform -- Infrastructure as Code
Terraform -- Infrastructure as CodeTerraform -- Infrastructure as Code
Terraform -- Infrastructure as Code
 
Integrating Security into DevOps and CI / CD Environments - Pop-up Loft TLV 2017
Integrating Security into DevOps and CI / CD Environments - Pop-up Loft TLV 2017Integrating Security into DevOps and CI / CD Environments - Pop-up Loft TLV 2017
Integrating Security into DevOps and CI / CD Environments - Pop-up Loft TLV 2017
 
Kubernetes extensibility: CRDs & Operators
Kubernetes extensibility: CRDs & OperatorsKubernetes extensibility: CRDs & Operators
Kubernetes extensibility: CRDs & Operators
 
Advanced Container Security
Advanced Container Security Advanced Container Security
Advanced Container Security
 
Kubernetes Monitoring & Best Practices
Kubernetes Monitoring & Best PracticesKubernetes Monitoring & Best Practices
Kubernetes Monitoring & Best Practices
 
Introduction to Kubernetes and Google Container Engine (GKE)
Introduction to Kubernetes and Google Container Engine (GKE)Introduction to Kubernetes and Google Container Engine (GKE)
Introduction to Kubernetes and Google Container Engine (GKE)
 
Infrastructure as Code with Terraform and Ansible
Infrastructure as Code with Terraform and AnsibleInfrastructure as Code with Terraform and Ansible
Infrastructure as Code with Terraform and Ansible
 
Monitoring, Logging and Tracing on Kubernetes
Monitoring, Logging and Tracing on KubernetesMonitoring, Logging and Tracing on Kubernetes
Monitoring, Logging and Tracing on Kubernetes
 
Introduction to helm
Introduction to helmIntroduction to helm
Introduction to helm
 
Introduction to kubernetes
Introduction to kubernetesIntroduction to kubernetes
Introduction to kubernetes
 
Docker Networking Overview
Docker Networking OverviewDocker Networking Overview
Docker Networking Overview
 

Similar a Packer

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
 
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 PackerGeorge Miranda
 

Similar a 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
 

Último

The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 

Último (20)

The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 

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.