SlideShare ist ein Scribd-Unternehmen logo
1 von 47
Downloaden Sie, um offline zu lesen
STANDARDISE DEVELOPMENT ENVIRONMENTS
AND MACHINE IMAGES WITH PACKER
Marcelo Pinheiro	

http://salizzar.net - @salizzar
SUMMARY
• Motivation	

• Installation	

• How it works	

• InsideTemplates	

• Some examples	

• Our experience	

• FAQ
MOTIVATION
• How to take control inside the
following environment issues?	

• Common workstation problems
(HD failure, dead computer)	

• Different OS’s	

• Extra machine configuration to
enable devs to work (programming
languages, databases, plugins, etc),
taking one or two days to be
ready-to-code	

• “Works on my machine” syndrome
MOTIVATION
• Vagrant or Docker. Period.	

• Embrace virtualisation	

• Each offers a way to pre-setup yourVM with necessary libraries,
databases and so on	

• No more development databases in your pre-staging DB server,
additional dependencies	

• A try to make development environment more similar to production
MOTIVATION
• It sounds good, but… how to take control over each applicationVM?	

• Sometimes your team needs to use some tools that are not available in
official package repository (or are too old), forcing to manual configuration
after up aVM	

• Even running aVM, developer personal choices can contaminate the
application (example: rspec add-ons, irb plugins)	

• Some developers don’t have knowledge about Chef / Puppet recipes	

• How to maintainVagrant Custom Boxes / Docker Custom Images when
you need to add / change tools, repositories or configs?
MOTIVATION
• For sysadms / sysops:	

• How to export a new machine image to your
virtualisation server (KVM, Xen,VMWare, etc)
when a new OS release is launched without
“dist-upgrade”?	

• How to automate it?
MOTIVATION
• Packer for the rescue	

• Written in Go	

• Owner: Mitchell Hashimoto
(Vagrant, Serf)	

• http://www.packer.io
INSTALLATION
• http://www.packer.io/downloads.html	

• Download zipped binaries for your OS	

• OSX	

• Linux	

• Windows	

• FreeBSD	

• OpenBSD
INSTALLATION
• Move binaries to your /usr/local/bin, ~/bin,
whatever	

• It’s done.
HOW IT WORKS
• Packer recipes are JSON files	

• Validate template:	

• $ packer validate your_recipe.json	

• Run template:	

• $ packer run your_recipe.json
INSIDETEMPLATES
• Packer templates have the following structure:	

• Variables	

• Builders	

• Provisioners	

• Post-processors
INSIDETEMPLATES:	

VARIABLES
• User-defined variables to be used along template	

• Can be declared in a custom file
INSIDETEMPLATES:	

VARIABLES
"variables": {!
"box_ostype": "centos",!
"box_osversion": "6.5",!
"box_nick": "6.5",!
"box_arch": "x64",!
"box_type": "base",!
"box_memory": "512",!
"box_cpus": "1",!
!
"iso_arch": "x86_64",!
"iso_type": "netinstall",!
"iso_md5": "939fd1d87c11ffe7795324438b85adfb",!
!
"ssh_user": "vagrant",!
"ssh_pass": "vagrant",!
"hostname": "vagrant-centos-6.5",!
"domain": "vagrantup.com"!
}
INSIDETEMPLATES:	

VARIABLES
# my_variables.json!
{!
"type": "vmware-iso",!
"vm_name": "mybox-vmw“,!
"guest_os_type": “centos",!
"disk_size": “4096”,!
!
(… other definitions here…)!
}!
INSIDETEMPLATES:	

BUILDERS
• Create a machine image from scratch	

• Download a ISO from official OS mirror, select a
base image to start	

• Set CPU cores, memory size, disk size	

• See documentation for further details (a lot of
options)
INSIDETEMPLATES:	

BUILDERS
"builders": [!
{!
"type": "virtualbox-iso",!
"iso_url": "http://an.repository.com/an-image.iso",!
"iso_checksum": "an-checksum",!
"iso_checksum_type": "md5",!
"http_directory": "http",!
"ssh_username": "root",!
"ssh_password": "apassword",!
"ssh_wait_timeout": "100000s",!
"shutdown_command": "echo {{ user `ssh_user` }} | sudo halt -p",!
!
"boot_command": [!
"<esc> ",!
"install ",!
"auto “,!
!
(… other definitions here …)!
!
"<enter><wait>"!
]!
}!
]
INSIDETEMPLATES:	

BUILDERS
• How to automate setup mundane tasks?	

• Minimal set of packages	

• Disk partition	

• Network	

• Timezone
INSIDETEMPLATES:	

BUILDERS
• For CentOS: Kickstart	

• For Debian: Preseed	

• For Windows:	

• Windows Automated Installation Kit (AIK)	

• Microsoft DeploymentToolkit (MDT)
INSIDETEMPLATES:	

BUILDERS
• Available builders:	

• QEMU - KVM and Xen
(experimental)	

• VMWare	

• Virtualbox	

• Docker	

!
• OpenStack	

• Google Compute
Engine	

• Amazon EC2	

• Digital Ocean
INSIDETEMPLATES:	

BUILDERS /VMWARE &VIRTUALBOX
• VMWare:	

• vmware-iso: create from scratch	

• vmware-vmx: create from a baseVMX file	

• Virtualbox:	

• virtualbox-iso: create from scratch	

• virtualbox-ovf: create from a base OVF file
INSIDETEMPLATES:	

BUILDERS / QEMU
• Create KVM / Xen images from scratch	

• Packer depends on qemu-system-x86_64, available
only on Debian at this time as a binary	

• CentOS have qemu-kvm, but you need to
manually override all Packer default options
INSIDETEMPLATES:	

BUILDERS / DOCKER
• Creates a Docker image by pulling a existent,
starting a container, provision it and exports a .tar
file	

• Provision without Dockerfile
INSIDETEMPLATES:	

BUILDERS / OTHERS
• For other builders, you simply need to inform:	

• username / password,API key	

• base image	

• zone and other related information	

• See Packer documentation
INSIDETEMPLATES:
PROVISIONERS
• After the setup of a machine image, it’s time to configure
it	

• Here is where magic happens:	

• Add packages, useful scripts	

• Standardise config files	

• Apply existent recipes from a CM
INSIDETEMPLATES:
PROVISIONERS
• Available provisioners:	

• Shell Scripts	

• File Uploads	

• Ansible	

• Chef Solo	

• Puppet	

• Salt
INSIDETEMPLATES:	

PROVISIONERS / SHELL SCRIPTS
• Most simple way to setup machine	

• Run apt-get, yum and friends
INSIDETEMPLATES:	

PROVISIONERS / SHELL SCRIPTS
"provisioners": [!
{!
"type": "shell",!
"execute_command": "echo 'root' | sh '{{ .Path }}'",!
"scripts": [!
"scripts/locale.sh",!
"scripts/elrepo.sh"!
]!
},!
{!
"type": "shell",!
"pause_before": "30s",!
"execute_command": "echo 'root' | sh '{{ .Path }}'",!
"scripts": [!
"scripts/vagrant.sh",!
"scripts/sudoers.sh"!
]!
}!
]
INSIDETEMPLATES:	

PROVISIONERS / FILE UPLOADS
• Need to set default configuration files or upload
some custom packages (.tar, .deb / .rpm) to be
installed later?	

• Upload them and after process with a shell script
or CM recipe
INSIDETEMPLATES:	

PROVISIONERS / FILE UPLOADS
"provisioners": [!
{!
"type": "shell",!
"execute_command": "echo 'root' | sh '{{ .Path }}'",!
"scripts": [!
"scripts/lamp/vagrant.sh",!
"scripts/lamp/apache2.sh",!
"scripts/lamp/php5.sh",!
"scripts/lamp/mysql.sh"!
]!
},!
{!
"type": "file",!
"source": "files/lamp-vagrant/vhost",!
"destination": "/etc/apache2/sites-available/lamp-php"!
},!
{!
"type": "shell",!
"execute_command": "echo 'root' | sh '{{ .Path }}'",!
"script": "scripts/lamp/enable-vhost"!
}!
]
INSIDETEMPLATES:	

PROVISIONERS / OTHERS
• The following provisioners requires installation before run:	

• Ansible	

• Puppet	

• Salt	

• Chef Solo is installed by Packer if not present	

• At this time, all provisioners are executed in client mode (no remote
server)
INSIDETEMPLATES:	

PROVISIONERS / OTHERS
"provisioners": [!
{!
"type": "ansible-local",!
"playbook_file": "recipes/ansible/lamp.yml"!
},!
{!
"type": "chef-solo",!
"cookbook_paths": [ "recipes/chef/lamp" ]!
},!
{!
"type": "puppet-masterless",!
"manifest_file": "recipes/puppet/lamp"!
},!
{!
"type": "salt-masterless",!
"local_state_tree": "recipes/salt/lamp"!
}!
]
INSIDETEMPLATES:	

POST-PROCESSORS
• After create / setup a machine image, you can:	

• Convert to aVagrant Custom Box	

• Locally add it as a Docker container	

• Publish in a Docker registry	

• Publish in a vSphere endpoint
INSIDETEMPLATES:	

POST-PROCESSORS /VAGRANT
• Defines a box output name	

• You can attach aVagrantfile template and other
template files (cookbooks)	

• Change compression rate if you want
INSIDETEMPLATES:	

POST-PROCESSORS /VAGRANT
"post-processors": [!
{!
"type": "vagrant",!
“output": "lamp-vagrant.box"!
}!
]
INSIDETEMPLATES:	

POST-PROCESSORS / DOCKER
• You can locally import a Docker image	

• You can push a Docker image to a registry	

• Needs manual login (automated soon)	

• Important: Docker pushes a completely new
image, not incremental
INSIDETEMPLATES:	

POST-PROCESSORS / DOCKER
"post-processors": [!
{!
"type": "docker-import",!
"repository": "salizzar/packer",!
"tag": "0.1"!
},!
"docker-push"!
]
INSIDETEMPLATES:	

POST-PROCESSORS /VSPHERE
• Upload to a vSphere endpoint
INSIDETEMPLATES:	

POST-PROCESSORS /VSPHERE
"post-processors": [!
{!
"type": "vsphere",!
"host": "a-vsphere-host.com",!
"username": "my_user",!
"password": "my_password",!
"cluster": "a-cluster",!
“datacenter": "xyz",!
"datastore": "zyx",!
“resource_pool": "zyx",!
"vm_folder": "images",!
"vm_name": "lamp",!
“vm_network": "staging"!
},!
]
SOME EXAMPLES
• It’s time to see some code!	

• All examples are available on:	

• https://github.com/salizzar/packer-examples
OUR EXPERIENCE
Ivan IVVasilyevich (theTerrible)
OUR EXPERIENCE
• Prepare to argue (sometimes fight :)	

• It’s hard to change development tradition of
premature optimisation, ultra-high performance,
personal choices,“nightly build” syndrome	

• Create a culture first
OUR EXPERIENCE
• Sometimes the better choice must be autocracy-based	

• Use OS package system ASAP (or backport / automate installation if
package not exists)	

• Introduce to developers a wisdom to use the same package of
programming language / DB / whatever that runs in production (!)	

• If is old, upgrade your app to use a newer version	

• The same for tools that “vendorize" your app libraries (maven,
bundler, etc)
OUR EXPERIENCE
• Make all applications ready-to-setup-and-run with one command	

• Track all dependencies with Dockerfile orVagrant Shell Scripts	

• Bash scripts are more easy to setup than 3rd party CM tools
at first time	

• Adopt a convention to make all applications more similar as
possible about their structure	

• Code generators
OUR EXPERIENCE
• Divide to conquer	

• Adopt a bottom-up strategy	

• Minor systems that are easy to setup	

• Minor teams	

• Start to apply with more systems and greater teams	

• Standardise ASAP
OUR EXPERIENCE
• At this time, major systems in Locaweb PaaS areVagrant-ready	

• git clone, vagrant up, vagrant ssh	

• Docker in development	

• Internally created a gem to apply standardisation of Rails apps:	

• Packaging (Debian)	

• Vagrant	

• Packer recipes to createVagrant custom boxes, using our mirrors
FAQ
• Questions?	

• New recipes available on:	

• https://github.com/salizzar/packer-vmware
THANKYOU!	

:)

Weitere ähnliche Inhalte

Kürzlich hochgeladen

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
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
 
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
 
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
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
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
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
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
 
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
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
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
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 

Kürzlich hochgeladen (20)

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
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
 
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
 
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
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
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
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
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
 
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
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
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
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 

Empfohlen

Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 

Empfohlen (20)

Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 

Standardise development environments and machine images with packer

  • 1. STANDARDISE DEVELOPMENT ENVIRONMENTS AND MACHINE IMAGES WITH PACKER Marcelo Pinheiro http://salizzar.net - @salizzar
  • 2. SUMMARY • Motivation • Installation • How it works • InsideTemplates • Some examples • Our experience • FAQ
  • 3. MOTIVATION • How to take control inside the following environment issues? • Common workstation problems (HD failure, dead computer) • Different OS’s • Extra machine configuration to enable devs to work (programming languages, databases, plugins, etc), taking one or two days to be ready-to-code • “Works on my machine” syndrome
  • 4. MOTIVATION • Vagrant or Docker. Period. • Embrace virtualisation • Each offers a way to pre-setup yourVM with necessary libraries, databases and so on • No more development databases in your pre-staging DB server, additional dependencies • A try to make development environment more similar to production
  • 5. MOTIVATION • It sounds good, but… how to take control over each applicationVM? • Sometimes your team needs to use some tools that are not available in official package repository (or are too old), forcing to manual configuration after up aVM • Even running aVM, developer personal choices can contaminate the application (example: rspec add-ons, irb plugins) • Some developers don’t have knowledge about Chef / Puppet recipes • How to maintainVagrant Custom Boxes / Docker Custom Images when you need to add / change tools, repositories or configs?
  • 6. MOTIVATION • For sysadms / sysops: • How to export a new machine image to your virtualisation server (KVM, Xen,VMWare, etc) when a new OS release is launched without “dist-upgrade”? • How to automate it?
  • 7. MOTIVATION • Packer for the rescue • Written in Go • Owner: Mitchell Hashimoto (Vagrant, Serf) • http://www.packer.io
  • 8. INSTALLATION • http://www.packer.io/downloads.html • Download zipped binaries for your OS • OSX • Linux • Windows • FreeBSD • OpenBSD
  • 9. INSTALLATION • Move binaries to your /usr/local/bin, ~/bin, whatever • It’s done.
  • 10. HOW IT WORKS • Packer recipes are JSON files • Validate template: • $ packer validate your_recipe.json • Run template: • $ packer run your_recipe.json
  • 11. INSIDETEMPLATES • Packer templates have the following structure: • Variables • Builders • Provisioners • Post-processors
  • 12. INSIDETEMPLATES: VARIABLES • User-defined variables to be used along template • Can be declared in a custom file
  • 13. INSIDETEMPLATES: VARIABLES "variables": {! "box_ostype": "centos",! "box_osversion": "6.5",! "box_nick": "6.5",! "box_arch": "x64",! "box_type": "base",! "box_memory": "512",! "box_cpus": "1",! ! "iso_arch": "x86_64",! "iso_type": "netinstall",! "iso_md5": "939fd1d87c11ffe7795324438b85adfb",! ! "ssh_user": "vagrant",! "ssh_pass": "vagrant",! "hostname": "vagrant-centos-6.5",! "domain": "vagrantup.com"! }
  • 14. INSIDETEMPLATES: VARIABLES # my_variables.json! {! "type": "vmware-iso",! "vm_name": "mybox-vmw“,! "guest_os_type": “centos",! "disk_size": “4096”,! ! (… other definitions here…)! }!
  • 15. INSIDETEMPLATES: BUILDERS • Create a machine image from scratch • Download a ISO from official OS mirror, select a base image to start • Set CPU cores, memory size, disk size • See documentation for further details (a lot of options)
  • 16. INSIDETEMPLATES: BUILDERS "builders": [! {! "type": "virtualbox-iso",! "iso_url": "http://an.repository.com/an-image.iso",! "iso_checksum": "an-checksum",! "iso_checksum_type": "md5",! "http_directory": "http",! "ssh_username": "root",! "ssh_password": "apassword",! "ssh_wait_timeout": "100000s",! "shutdown_command": "echo {{ user `ssh_user` }} | sudo halt -p",! ! "boot_command": [! "<esc> ",! "install ",! "auto “,! ! (… other definitions here …)! ! "<enter><wait>"! ]! }! ]
  • 17. INSIDETEMPLATES: BUILDERS • How to automate setup mundane tasks? • Minimal set of packages • Disk partition • Network • Timezone
  • 18. INSIDETEMPLATES: BUILDERS • For CentOS: Kickstart • For Debian: Preseed • For Windows: • Windows Automated Installation Kit (AIK) • Microsoft DeploymentToolkit (MDT)
  • 19. INSIDETEMPLATES: BUILDERS • Available builders: • QEMU - KVM and Xen (experimental) • VMWare • Virtualbox • Docker ! • OpenStack • Google Compute Engine • Amazon EC2 • Digital Ocean
  • 20. INSIDETEMPLATES: BUILDERS /VMWARE &VIRTUALBOX • VMWare: • vmware-iso: create from scratch • vmware-vmx: create from a baseVMX file • Virtualbox: • virtualbox-iso: create from scratch • virtualbox-ovf: create from a base OVF file
  • 21. INSIDETEMPLATES: BUILDERS / QEMU • Create KVM / Xen images from scratch • Packer depends on qemu-system-x86_64, available only on Debian at this time as a binary • CentOS have qemu-kvm, but you need to manually override all Packer default options
  • 22. INSIDETEMPLATES: BUILDERS / DOCKER • Creates a Docker image by pulling a existent, starting a container, provision it and exports a .tar file • Provision without Dockerfile
  • 23. INSIDETEMPLATES: BUILDERS / OTHERS • For other builders, you simply need to inform: • username / password,API key • base image • zone and other related information • See Packer documentation
  • 24. INSIDETEMPLATES: PROVISIONERS • After the setup of a machine image, it’s time to configure it • Here is where magic happens: • Add packages, useful scripts • Standardise config files • Apply existent recipes from a CM
  • 25. INSIDETEMPLATES: PROVISIONERS • Available provisioners: • Shell Scripts • File Uploads • Ansible • Chef Solo • Puppet • Salt
  • 26. INSIDETEMPLATES: PROVISIONERS / SHELL SCRIPTS • Most simple way to setup machine • Run apt-get, yum and friends
  • 27. INSIDETEMPLATES: PROVISIONERS / SHELL SCRIPTS "provisioners": [! {! "type": "shell",! "execute_command": "echo 'root' | sh '{{ .Path }}'",! "scripts": [! "scripts/locale.sh",! "scripts/elrepo.sh"! ]! },! {! "type": "shell",! "pause_before": "30s",! "execute_command": "echo 'root' | sh '{{ .Path }}'",! "scripts": [! "scripts/vagrant.sh",! "scripts/sudoers.sh"! ]! }! ]
  • 28. INSIDETEMPLATES: PROVISIONERS / FILE UPLOADS • Need to set default configuration files or upload some custom packages (.tar, .deb / .rpm) to be installed later? • Upload them and after process with a shell script or CM recipe
  • 29. INSIDETEMPLATES: PROVISIONERS / FILE UPLOADS "provisioners": [! {! "type": "shell",! "execute_command": "echo 'root' | sh '{{ .Path }}'",! "scripts": [! "scripts/lamp/vagrant.sh",! "scripts/lamp/apache2.sh",! "scripts/lamp/php5.sh",! "scripts/lamp/mysql.sh"! ]! },! {! "type": "file",! "source": "files/lamp-vagrant/vhost",! "destination": "/etc/apache2/sites-available/lamp-php"! },! {! "type": "shell",! "execute_command": "echo 'root' | sh '{{ .Path }}'",! "script": "scripts/lamp/enable-vhost"! }! ]
  • 30. INSIDETEMPLATES: PROVISIONERS / OTHERS • The following provisioners requires installation before run: • Ansible • Puppet • Salt • Chef Solo is installed by Packer if not present • At this time, all provisioners are executed in client mode (no remote server)
  • 31. INSIDETEMPLATES: PROVISIONERS / OTHERS "provisioners": [! {! "type": "ansible-local",! "playbook_file": "recipes/ansible/lamp.yml"! },! {! "type": "chef-solo",! "cookbook_paths": [ "recipes/chef/lamp" ]! },! {! "type": "puppet-masterless",! "manifest_file": "recipes/puppet/lamp"! },! {! "type": "salt-masterless",! "local_state_tree": "recipes/salt/lamp"! }! ]
  • 32. INSIDETEMPLATES: POST-PROCESSORS • After create / setup a machine image, you can: • Convert to aVagrant Custom Box • Locally add it as a Docker container • Publish in a Docker registry • Publish in a vSphere endpoint
  • 33. INSIDETEMPLATES: POST-PROCESSORS /VAGRANT • Defines a box output name • You can attach aVagrantfile template and other template files (cookbooks) • Change compression rate if you want
  • 34. INSIDETEMPLATES: POST-PROCESSORS /VAGRANT "post-processors": [! {! "type": "vagrant",! “output": "lamp-vagrant.box"! }! ]
  • 35. INSIDETEMPLATES: POST-PROCESSORS / DOCKER • You can locally import a Docker image • You can push a Docker image to a registry • Needs manual login (automated soon) • Important: Docker pushes a completely new image, not incremental
  • 36. INSIDETEMPLATES: POST-PROCESSORS / DOCKER "post-processors": [! {! "type": "docker-import",! "repository": "salizzar/packer",! "tag": "0.1"! },! "docker-push"! ]
  • 38. INSIDETEMPLATES: POST-PROCESSORS /VSPHERE "post-processors": [! {! "type": "vsphere",! "host": "a-vsphere-host.com",! "username": "my_user",! "password": "my_password",! "cluster": "a-cluster",! “datacenter": "xyz",! "datastore": "zyx",! “resource_pool": "zyx",! "vm_folder": "images",! "vm_name": "lamp",! “vm_network": "staging"! },! ]
  • 39. SOME EXAMPLES • It’s time to see some code! • All examples are available on: • https://github.com/salizzar/packer-examples
  • 41. OUR EXPERIENCE • Prepare to argue (sometimes fight :) • It’s hard to change development tradition of premature optimisation, ultra-high performance, personal choices,“nightly build” syndrome • Create a culture first
  • 42. OUR EXPERIENCE • Sometimes the better choice must be autocracy-based • Use OS package system ASAP (or backport / automate installation if package not exists) • Introduce to developers a wisdom to use the same package of programming language / DB / whatever that runs in production (!) • If is old, upgrade your app to use a newer version • The same for tools that “vendorize" your app libraries (maven, bundler, etc)
  • 43. OUR EXPERIENCE • Make all applications ready-to-setup-and-run with one command • Track all dependencies with Dockerfile orVagrant Shell Scripts • Bash scripts are more easy to setup than 3rd party CM tools at first time • Adopt a convention to make all applications more similar as possible about their structure • Code generators
  • 44. OUR EXPERIENCE • Divide to conquer • Adopt a bottom-up strategy • Minor systems that are easy to setup • Minor teams • Start to apply with more systems and greater teams • Standardise ASAP
  • 45. OUR EXPERIENCE • At this time, major systems in Locaweb PaaS areVagrant-ready • git clone, vagrant up, vagrant ssh • Docker in development • Internally created a gem to apply standardisation of Rails apps: • Packaging (Debian) • Vagrant • Packer recipes to createVagrant custom boxes, using our mirrors
  • 46. FAQ • Questions? • New recipes available on: • https://github.com/salizzar/packer-vmware