A Introduction of Packer

16
Let Packer Simplify your work — It’s all about DevOps Packer

description

Packer is a tool for creating identical machine images for multiple platforms from a single source configuration.

Transcript of A Introduction of Packer

Page 1: A Introduction of Packer

Let Packer Simplify your work— It’s all about DevOps

Packer

Page 2: A Introduction of Packer

Content

•Why Packer created

•How to use Packer

•What are typical application scenarios of Packer

Page 3: A Introduction of Packer

“I want a server”“OK☺”

Page 4: A Introduction of Packer

Set up machine & network.. 2 hour Install operation system.. 30 min Install software.. N hour Configuring & deploying.. N hour

About 10 years ago…

We got VMware, VirtualBox.. We got Puppet, Chef, Ansible.. Everything is automatic!! Setup machine is just one click..

About 20 years ago…

1 daySetup machine, Setup OS, Manually setup software, etc

Setup machine, Auto setup everything3 hours

Page 5: A Introduction of Packer

About 5 years ago…

We got clouds! !We don’t even need to have our own machine! !What a perfect world..

Auto setup everything30 mins

Page 6: A Introduction of Packer

We trigger up a instance then trigger the auto-configure tool, and we can just waiting.. !I like AWS, I like Anisble, it make everything automatical, what we need to do is just waiting..

Why we still have to keep waiting ?

Hold..

Page 7: A Introduction of Packer

1 min Start up instance

30 mins

29 mins Auto-configure server

Put everything

into the image

Page 8: A Introduction of Packer
Page 9: A Introduction of Packer

Usage

Page 10: A Introduction of Packer

Packer Template File

1. { 2. "variables": { 3. "aws_access_key": "", 4. "aws_secret_key": "" 5. }, 6. "builders": [ 7. { 8. "type": "amazon-ebs", 9. "access_key": "{{user `aws_access_key`}}", 10. "secret_key": "{{user `aws_secret_key`}}", 11. "region": "us-east-1", 12. "source_ami": "ami-de0d9eb7", 13. "instance_type": "t1.micro", 14. "ssh_username": "ubuntu", 15. "ami_name": "packer {{timestamp}}" 16. } 17. ], 18. "provisioners": [ 19. { 20. "type": "shell", 21. "script": "setup_things.sh" 22. } 23. ] 24. }

• builders (required) • description (optional) • variables (optional) • provisioners (optional) • post-processors (optional)

Page 11: A Introduction of Packer

Packer Command-line

packer build [-var ‘variable_name=value_string’] <template_file.json>

packer inspect <template_file.json>

packer validate <template_file.json>

packer fix <template_file.json>

Inspect

validate

build

fix

Page 12: A Introduction of Packer

Demo

Page 13: A Introduction of Packer

Packer as part of pipeline

Developing Testing Delivering

★ Fit for small system

★ Deploying can be tedious for large system

★ Take longer time and more network bandwidth with new test environment added

Page 14: A Introduction of Packer

Packer as part of pipeline

Developing PackingTesting Delivering

Deliver imagesSafer deployment

Time saving

Parallel builds

Page 15: A Introduction of Packer

Product Env.

Testing Env.

Developing

Packer

Page 16: A Introduction of Packer

—— Dr. Packer

Configure once, Use anywhere

http://www.packer.io https://github.com/mitchellh/packer