salt vagrant and virtualbox - drupal groups · salt vagrant and virtualbox ben hosmer @bhosmer...

32
SALT Vagrant and Virtualbox Ben Hosmer @bhosmer Tuesday, October 23, 12 Mention RB government intelligence customers Vagrant stores lightweight “boxes” for development and testing. Configuration management can be used to have repeatable environments that you can quickly and easily reset

Upload: ngohuong

Post on 19-Oct-2018

223 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: SALT Vagrant and Virtualbox - Drupal Groups · SALT Vagrant and Virtualbox Ben Hosmer @bhosmer Tuesday, October 23, 12 Mention RB government intelligence customers Vagrant stores

SALT Vagrant and Virtualbox

Ben Hosmer@bhosmer

Tuesday, October 23, 12

Mention RB government intelligence customersVagrant stores lightweight “boxes” for development and testing.Configuration management can be used to have repeatable environments that you can quickly and easily reset

Page 2: SALT Vagrant and Virtualbox - Drupal Groups · SALT Vagrant and Virtualbox Ben Hosmer @bhosmer Tuesday, October 23, 12 Mention RB government intelligence customers Vagrant stores

Local Dev Prod

Tuesday, October 23, 12

Why use configuration management?

Page 3: SALT Vagrant and Virtualbox - Drupal Groups · SALT Vagrant and Virtualbox Ben Hosmer @bhosmer Tuesday, October 23, 12 Mention RB government intelligence customers Vagrant stores

Local Dev Prod

Tuesday, October 23, 12

Isn’t this nicer?

Page 4: SALT Vagrant and Virtualbox - Drupal Groups · SALT Vagrant and Virtualbox Ben Hosmer @bhosmer Tuesday, October 23, 12 Mention RB government intelligence customers Vagrant stores

Tuesday, October 23, 12

Puppet is a very popular one.It requires ruby etc.

Page 5: SALT Vagrant and Virtualbox - Drupal Groups · SALT Vagrant and Virtualbox Ben Hosmer @bhosmer Tuesday, October 23, 12 Mention RB government intelligence customers Vagrant stores

Tuesday, October 23, 12

A sample puppet manifest.You have to kind of know ruby code to make it work or modify it.

Page 6: SALT Vagrant and Virtualbox - Drupal Groups · SALT Vagrant and Virtualbox Ben Hosmer @bhosmer Tuesday, October 23, 12 Mention RB government intelligence customers Vagrant stores

Tuesday, October 23, 12

Saltstack is like puppet, but much easier, lighter-weight and uses python and yaml.

Page 7: SALT Vagrant and Virtualbox - Drupal Groups · SALT Vagrant and Virtualbox Ben Hosmer @bhosmer Tuesday, October 23, 12 Mention RB government intelligence customers Vagrant stores

Tuesday, October 23, 12

YAML is much easier to read and interpret. You don’t have to know code to modify it.

Page 8: SALT Vagrant and Virtualbox - Drupal Groups · SALT Vagrant and Virtualbox Ben Hosmer @bhosmer Tuesday, October 23, 12 Mention RB government intelligence customers Vagrant stores

The Team

Tuesday, October 23, 12

We can combine virtualbox, vagrant, and saltstack for configurations that are transportable and distributable among developers. Consistency!

Page 9: SALT Vagrant and Virtualbox - Drupal Groups · SALT Vagrant and Virtualbox Ben Hosmer @bhosmer Tuesday, October 23, 12 Mention RB government intelligence customers Vagrant stores

Remote Execution

Tuesday, October 23, 12

An added benefit that you get out of the box with SALT is remote execution.Type command once and run it on every machine.

Page 10: SALT Vagrant and Virtualbox - Drupal Groups · SALT Vagrant and Virtualbox Ben Hosmer @bhosmer Tuesday, October 23, 12 Mention RB government intelligence customers Vagrant stores

What you need.

Tuesday, October 23, 12

Page 11: SALT Vagrant and Virtualbox - Drupal Groups · SALT Vagrant and Virtualbox Ben Hosmer @bhosmer Tuesday, October 23, 12 Mention RB government intelligence customers Vagrant stores

Rubyruby-lang.org

Tuesday, October 23, 12

We can’t get away from this, but you don’t need to actually know any ruby code.

Page 12: SALT Vagrant and Virtualbox - Drupal Groups · SALT Vagrant and Virtualbox Ben Hosmer @bhosmer Tuesday, October 23, 12 Mention RB government intelligence customers Vagrant stores

Virtualbox.org

Tuesday, October 23, 12

Allows you to run another operating system inside your operating system.Host > Guest paradigm

Page 13: SALT Vagrant and Virtualbox - Drupal Groups · SALT Vagrant and Virtualbox Ben Hosmer @bhosmer Tuesday, October 23, 12 Mention RB government intelligence customers Vagrant stores

vagrantup.com

Tuesday, October 23, 12

Vagrant connects our configuration management system and our boxes to an interface that we can script. You can use it without any configuration management. It lets us create a server, destroy it, and then repeat the process easily.

Page 14: SALT Vagrant and Virtualbox - Drupal Groups · SALT Vagrant and Virtualbox Ben Hosmer @bhosmer Tuesday, October 23, 12 Mention RB government intelligence customers Vagrant stores

salty-vagrantvagrant gem install vagrant-salt

http://bit.ly/REYBZz

Tuesday, October 23, 12

A ruby gem that connects salt configuration management with vagrant.

Page 15: SALT Vagrant and Virtualbox - Drupal Groups · SALT Vagrant and Virtualbox Ben Hosmer @bhosmer Tuesday, October 23, 12 Mention RB government intelligence customers Vagrant stores

A Base Box

vagrantbox.es

Tuesday, October 23, 12

The easiest way to get started is to download a box that has already been created.Get the Ubuntu precise 64 box. There are a lot of others available. CentOS/BSD/Lots of linux flavors.

Page 16: SALT Vagrant and Virtualbox - Drupal Groups · SALT Vagrant and Virtualbox Ben Hosmer @bhosmer Tuesday, October 23, 12 Mention RB government intelligence customers Vagrant stores

Tuesday, October 23, 12

Now we’ll start diving deep.

Page 17: SALT Vagrant and Virtualbox - Drupal Groups · SALT Vagrant and Virtualbox Ben Hosmer @bhosmer Tuesday, October 23, 12 Mention RB government intelligence customers Vagrant stores

Add your box.

vagrant box add precise64

Tuesday, October 23, 12

Now that you have the box, you need to tell vagrant about it.

Page 18: SALT Vagrant and Virtualbox - Drupal Groups · SALT Vagrant and Virtualbox Ben Hosmer @bhosmer Tuesday, October 23, 12 Mention RB government intelligence customers Vagrant stores

Get the Vagrantfile

http://bit.ly/TggfrW

Tuesday, October 23, 12

Vagrant init will create a well-commented file for you, but you don’t need all of the configuration in it. It is much easier to download this from the salty-vagrant github page and copy and paste it.

Page 19: SALT Vagrant and Virtualbox - Drupal Groups · SALT Vagrant and Virtualbox Ben Hosmer @bhosmer Tuesday, October 23, 12 Mention RB government intelligence customers Vagrant stores

Add this for web-browser access:

config.vm.network :hostonly, "192.168.33.20"

Tuesday, October 23, 12

Page 20: SALT Vagrant and Virtualbox - Drupal Groups · SALT Vagrant and Virtualbox Ben Hosmer @bhosmer Tuesday, October 23, 12 Mention RB government intelligence customers Vagrant stores

Create Your Directories

Tuesday, October 23, 12

Page 21: SALT Vagrant and Virtualbox - Drupal Groups · SALT Vagrant and Virtualbox Ben Hosmer @bhosmer Tuesday, October 23, 12 Mention RB government intelligence customers Vagrant stores

minion.conf:

http://bit.ly/RF1x8z

file_client: local

Tuesday, October 23, 12

This is all you need. This tells SALT to get its configuration from a local configuration instead of looking for a remote master.

Page 22: SALT Vagrant and Virtualbox - Drupal Groups · SALT Vagrant and Virtualbox Ben Hosmer @bhosmer Tuesday, October 23, 12 Mention RB government intelligence customers Vagrant stores

The Top Filetop.sls

base: '*': - lamp-drupal

Tuesday, October 23, 12

This tells SALT what configuration you want to use.

Page 23: SALT Vagrant and Virtualbox - Drupal Groups · SALT Vagrant and Virtualbox Ben Hosmer @bhosmer Tuesday, October 23, 12 Mention RB government intelligence customers Vagrant stores

Lamp-Drupal Salt Statehttp://bit.ly/RF1x8z

Tuesday, October 23, 12

Grab this from the github page.

Page 24: SALT Vagrant and Virtualbox - Drupal Groups · SALT Vagrant and Virtualbox Ben Hosmer @bhosmer Tuesday, October 23, 12 Mention RB government intelligence customers Vagrant stores

Vagrant up!

Tuesday, October 23, 12

Page 25: SALT Vagrant and Virtualbox - Drupal Groups · SALT Vagrant and Virtualbox Ben Hosmer @bhosmer Tuesday, October 23, 12 Mention RB government intelligence customers Vagrant stores

Vagrant up!

Tuesday, October 23, 12

Page 26: SALT Vagrant and Virtualbox - Drupal Groups · SALT Vagrant and Virtualbox Ben Hosmer @bhosmer Tuesday, October 23, 12 Mention RB government intelligence customers Vagrant stores

Tuesday, October 23, 12

Page 27: SALT Vagrant and Virtualbox - Drupal Groups · SALT Vagrant and Virtualbox Ben Hosmer @bhosmer Tuesday, October 23, 12 Mention RB government intelligence customers Vagrant stores

Tuesday, October 23, 12

Shared folder:localGuest: /vagrant

Page 28: SALT Vagrant and Virtualbox - Drupal Groups · SALT Vagrant and Virtualbox Ben Hosmer @bhosmer Tuesday, October 23, 12 Mention RB government intelligence customers Vagrant stores

Tuesday, October 23, 12

Shared folder:localGuest: /vagrant

Page 29: SALT Vagrant and Virtualbox - Drupal Groups · SALT Vagrant and Virtualbox Ben Hosmer @bhosmer Tuesday, October 23, 12 Mention RB government intelligence customers Vagrant stores

Virtualbox Guest Additions must match.

Tuesday, October 23, 12

They probably will not, so you need to update them and then use vagrant box repackage so that your box’s guest additions match the version of virtualbox.

Page 30: SALT Vagrant and Virtualbox - Drupal Groups · SALT Vagrant and Virtualbox Ben Hosmer @bhosmer Tuesday, October 23, 12 Mention RB government intelligence customers Vagrant stores

vagrant halt

Tuesday, October 23, 12

Stops the machine, but retains your currently added software and configuration. Basically a shutdown.

Page 31: SALT Vagrant and Virtualbox - Drupal Groups · SALT Vagrant and Virtualbox Ben Hosmer @bhosmer Tuesday, October 23, 12 Mention RB government intelligence customers Vagrant stores

salt-call

Tuesday, October 23, 12

Use this for local SALT commands instead of the standard use of “SALT”

Page 32: SALT Vagrant and Virtualbox - Drupal Groups · SALT Vagrant and Virtualbox Ben Hosmer @bhosmer Tuesday, October 23, 12 Mention RB government intelligence customers Vagrant stores

vagrant destroy(Reset & do-over)

Tuesday, October 23, 12