rackspace hack night - vagrant & packer

39
Vagrant & Packer RAX Hack Night

Upload: marc-cluet

Post on 28-Jan-2015

118 views

Category:

Technology


0 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Rackspace Hack Night - Vagrant & Packer

Vagrant & Packer RAX Hack Night

Page 2: Rackspace Hack Night - Vagrant & Packer

RACKSPACE® HOSTING | WWW.RACKSPACE.CO.UK

So…

I automated *all* the things

Page 3: Rackspace Hack Night - Vagrant & Packer

RACKSPACE® HOSTING | WWW.RACKSPACE.CO.UK

So…

Feel quite smug about it

Page 4: Rackspace Hack Night - Vagrant & Packer

RACKSPACE® HOSTING | WWW.RACKSPACE.CO.UK

So…

Got my environments in order

DEV QA PROD

Page 5: Rackspace Hack Night - Vagrant & Packer

RACKSPACE® HOSTING | WWW.RACKSPACE.CO.UK

So…

All is good

Page 6: Rackspace Hack Night - Vagrant & Packer

RACKSPACE® HOSTING | WWW.RACKSPACE.CO.UK

So…

OR IS IT?!?!

Page 7: Rackspace Hack Night - Vagrant & Packer

RACKSPACE® HOSTING | WWW.RACKSPACE.CO.UK

So…

Page 8: Rackspace Hack Night - Vagrant & Packer

RACKSPACE® HOSTING | WWW.RACKSPACE.CO.UK

So…

Page 9: Rackspace Hack Night - Vagrant & Packer

RACKSPACE® HOSTING | WWW.RACKSPACE.CO.UK

So… the problem

How do you get your DEVs mobile?

Page 10: Rackspace Hack Night - Vagrant & Packer

RACKSPACE® HOSTING | WWW.RACKSPACE.CO.UK

So… the problem

Have a dev portable platform!that is the *SAME* everywhere

Page 11: Rackspace Hack Night - Vagrant & Packer

RACKSPACE® HOSTING | WWW.RACKSPACE.CO.UK

So… the problem

Why the hell they all work from Starbucks?!?!?

Page 12: Rackspace Hack Night - Vagrant & Packer

RACKSPACE® HOSTING | WWW.RACKSPACE.CO.UK

Vagrant!

Page 13: Rackspace Hack Night - Vagrant & Packer

RACKSPACE® HOSTING | WWW.RACKSPACE.CO.UK

Vagrant!

You have a base Box VM

Attach to chef or Puppet!Add some script sprinkles

or something else

Page 14: Rackspace Hack Night - Vagrant & Packer

RACKSPACE® HOSTING | WWW.RACKSPACE.CO.UK

Base Box

You have a base Box

Page 15: Rackspace Hack Night - Vagrant & Packer

RACKSPACE® HOSTING | WWW.RACKSPACE.CO.UK

Base Box

Where can I run this Base Box?VirtualBox!

VMWare Fusion!VMWare Workstation

Page 16: Rackspace Hack Night - Vagrant & Packer

RACKSPACE® HOSTING | WWW.RACKSPACE.CO.UK

Base Box

Where can I run this Base Box?Rackspace Cloud!

Amazon!OpenStack

Page 17: Rackspace Hack Night - Vagrant & Packer

RACKSPACE® HOSTING | WWW.RACKSPACE.CO.UK

Base Box

As simple as 1…2…3…vagrant  box  add  $title  $BOX_URL  

vagrant  init  $title  

vagrant  up

Page 18: Rackspace Hack Night - Vagrant & Packer

RACKSPACE® HOSTING | WWW.RACKSPACE.CO.UK

Plugins!

ansible  

vagrant-­‐berkshelf  

vagrant-­‐librarian-­‐puppet  

vagrant-­‐lxc  

vagrant-­‐salt

Page 19: Rackspace Hack Night - Vagrant & Packer

RACKSPACE® HOSTING | WWW.RACKSPACE.CO.UK

Vagrantfile

Defines what Vagrant will do

Page 20: Rackspace Hack Night - Vagrant & Packer

RACKSPACE® HOSTING | WWW.RACKSPACE.CO.UK

VagrantfileVagrant.configure("2")  do  |config|  

       config.vm.box  =  "precise64"  

       config.vm.box_url  =  "http://files.vagrantup.com/precise64.box"  

       config.vm.network  :private_network,  ip:  "192.168.33.10"  

       config.vm.synced_folder  "../data",  "/vagrant_data"  

       config.vm.provider  :virtualbox  do  |vb|  

               vb.customize  ["modifyvm",  :id,  "-­‐-­‐memory",  "1024"]  

       end  

end  

!

Page 21: Rackspace Hack Night - Vagrant & Packer

RACKSPACE® HOSTING | WWW.RACKSPACE.CO.UK

VagrantfileVagrant.configure("2")  do  |config|  

       config.vm.box  =  "precise64"  

       config.vm.box_url  =  "http://files.vagrantup.com/precise64.box"  

       config.vm.network  :private_network,  ip:  "192.168.33.10"  

       config.vm.provision  :puppet  do  |puppet|  

               puppet.manifests_path  =  "manifests"  

               puppet.manifest_file    =  "init.pp"  

       end    

end  

!!

Page 22: Rackspace Hack Night - Vagrant & Packer

RACKSPACE® HOSTING | WWW.RACKSPACE.CO.UK

Taking this to 11!

Page 23: Rackspace Hack Night - Vagrant & Packer

RACKSPACE® HOSTING | WWW.RACKSPACE.CO.UK

Taking this to 11!Vagrant.configure("2")  do  |config|  

   config.vm.provision  "shell",  inline:  "echo  Hello"  

   config.vm.define  "web"  do  |web|  

       web.vm.box  =  "apache"  

   end  

   config.vm.define  "db"  do  |db|  

       db.vm.box  =  "mysql"  

   end  

end  

!!

Page 24: Rackspace Hack Night - Vagrant & Packer

RACKSPACE® HOSTING | WWW.RACKSPACE.CO.UK

Taking this to 11!

Page 25: Rackspace Hack Night - Vagrant & Packer

RACKSPACE® HOSTING | WWW.RACKSPACE.CO.UK

And now…

Page 26: Rackspace Hack Night - Vagrant & Packer

RACKSPACE® HOSTING | WWW.RACKSPACE.CO.UK

And now…

Packer!

Page 27: Rackspace Hack Night - Vagrant & Packer

RACKSPACE® HOSTING | WWW.RACKSPACE.CO.UK

Packer

Do your GMs RIGHT

Page 28: Rackspace Hack Night - Vagrant & Packer

RACKSPACE® HOSTING | WWW.RACKSPACE.CO.UK

PackerAdd that Puppet!you always!wanted

Page 29: Rackspace Hack Night - Vagrant & Packer

RACKSPACE® HOSTING | WWW.RACKSPACE.CO.UK

Packer

Page 30: Rackspace Hack Night - Vagrant & Packer

RACKSPACE® HOSTING | WWW.RACKSPACE.CO.UK

Packer

From a single config file

Page 31: Rackspace Hack Night - Vagrant & Packer

RACKSPACE® HOSTING | WWW.RACKSPACE.CO.UK

Packer

Deploy EVERYWHERE

Page 32: Rackspace Hack Night - Vagrant & Packer

RACKSPACE® HOSTING | WWW.RACKSPACE.CO.UK

Packer

Amazon AWS!Digital Ocean!

OpenStack!VMWare

Page 33: Rackspace Hack Night - Vagrant & Packer

RACKSPACE® HOSTING | WWW.RACKSPACE.CO.UK

Packer{  

   "builders":  [{  

       "type":  "amazon-­‐ebs",  

       "access_key":  "YOUR  KEY  HERE",  

       "secret_key":  "YOUR  SECRET  KEY  HERE",  

       "region":  "us-­‐east-­‐1",  

       "source_ami":  "ami-­‐de0d9eb7",  

       "instance_type":  "t1.micro",  

       "ssh_username":  "ubuntu",  

       "ami_name":  "packer-­‐example  {{timestamp}}"  

   }]  

}  

Page 34: Rackspace Hack Night - Vagrant & Packer

RACKSPACE® HOSTING | WWW.RACKSPACE.CO.UK

Packer$  packer  build  example.json  ==>  amazon-­‐ebs:  amazon-­‐ebs  output  will  be  in  this  color.  ==>  amazon-­‐ebs:  Creating  temporary  keypair  for  this  instance...  ==>  amazon-­‐ebs:  Creating  temporary  security  group  for  this  instance...  ==>  amazon-­‐ebs:  Authorizing  SSH  access  on  the  temporary  security  group...  ==>  amazon-­‐ebs:  Launching  a  source  AWS  instance...  ==>  amazon-­‐ebs:  Waiting  for  instance  to  become  ready...  ==>  amazon-­‐ebs:  Connecting  to  the  instance  via  SSH...  ==>  amazon-­‐ebs:  Stopping  the  source  instance...  ==>  amazon-­‐ebs:  Waiting  for  the  instance  to  stop...  ==>  amazon-­‐ebs:  Creating  the  AMI:  packer-­‐example  1371856345  ==>  amazon-­‐ebs:  AMI:  ami-­‐19601070  ==>  amazon-­‐ebs:  Waiting  for  AMI  to  become  ready...  ==>  amazon-­‐ebs:  Terminating  the  source  AWS  instance...  ==>  amazon-­‐ebs:  Deleting  temporary  security  group...  ==>  amazon-­‐ebs:  Deleting  temporary  keypair...  ==>  amazon-­‐ebs:  Build  finished.  !==>  Builds  finished.  The  artifacts  of  successful  builds  are:  -­‐-­‐>  amazon-­‐ebs:  AMIs  were  created:  !us-­‐east-­‐1:  ami-­‐19601070  

Page 35: Rackspace Hack Night - Vagrant & Packer

RACKSPACE® HOSTING | WWW.RACKSPACE.CO.UK

Packer

Deploy to more than one!provider at the same time!using the “builders” array

Page 36: Rackspace Hack Night - Vagrant & Packer

RACKSPACE® HOSTING | WWW.RACKSPACE.CO.UK

Packer$  packer  build  example.json  ==>  amazon-­‐ebs:  amazon-­‐ebs  output  will  be  in  this  color.  ==>  digitalocean:  digitalocean  output  will  be  in  this  color.  !==>  digitalocean:  Creating  temporary  ssh  key  for  droplet...  ==>  amazon-­‐ebs:  Creating  temporary  keypair  for  this  instance...  ==>  amazon-­‐ebs:  Creating  temporary  security  group  for  this  instance...  ==>  digitalocean:  Creating  droplet...  ==>  amazon-­‐ebs:  Authorizing  SSH  access  on  the  temporary  security  group...  ==>  amazon-­‐ebs:  Launching  a  source  AWS  instance...  ==>  digitalocean:  Waiting  for  droplet  to  become  active...  ==>  amazon-­‐ebs:  Waiting  for  instance  to  become  ready...  ==>  digitalocean:  Connecting  to  the  droplet  via  SSH...  ==>  amazon-­‐ebs:  Connecting  to  the  instance  via  SSH...  ...  ==>  Builds  finished.  The  artifacts  of  successful  builds  are:  -­‐-­‐>  amazon-­‐ebs:  AMIs  were  created:  !us-­‐east-­‐1:  ami-­‐376d1d5e  -­‐-­‐>  digitalocean:  A  snapshot  was  created:  packer-­‐1371870364  

Page 37: Rackspace Hack Night - Vagrant & Packer

RACKSPACE® HOSTING | WWW.RACKSPACE.CO.UK

Packer

Also deploy to Vagrant!using the “post-processors”!

array

Page 38: Rackspace Hack Night - Vagrant & Packer

RACKSPACE® HOSTING | WWW.RACKSPACE.CO.UK

Packer

{  

   "builders":  [...],  

!    "provisioners":  [...],  

!    "post-­‐processors":  ["vagrant"]  

}

Page 39: Rackspace Hack Night - Vagrant & Packer

!39RACKSPACE® HOSTING | © RACKSPACE US, INC. | RACKSPACE® AND FANATICAL SUPPORT® ARE SERVICE MARKS OF RACKSPACE US, INC. REGISTERED IN THE UNITED STATES AND OTHER COUNTRIES. | WWW.RACKSPACE.CO.UK

RACKSPACE® HOSTING | 5 MILLINGTON ROAD | HAYES, UNITED KINGDOM UB3 4AZ UK SALES: +44 (0)20 8712 6507 | UK SUPPORT: 0800 988 0300 | WWW.RACKSPACE.CO.UK