DZone
DevOps Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > DevOps Zone > Learning Puppet or Chef? Check out Vagrant!

Learning Puppet or Chef? Check out Vagrant!

Carlos Sanchez user avatar by
Carlos Sanchez
·
Apr. 21, 12 · DevOps Zone · Interview
Like (0)
Save
Tweet
11.48K Views

Join the DZone community and get the full member experience.

Join For Free
if you are starting to use puppet or chef, you must have vagrant .

learning puppet can be a tedious task, getting up the master, agents, writing your first manifests,… a good way to start is using vagrant, an oracle virtualbox command line automation tool, that allows easy puppet and chef provisioning on virtualbox vms.

vagrant projects are composed by base boxes , specifically configured for vagrant with puppet/chef, vagrant username and password, and anything else you may want to add, plus the configuration to apply to those base boxes, defined with puppet or chef. that way we can have several projects using the same base boxes shared where the only difference are the puppet/chef definitions. for instance a database vm and a web server vm can both use the same base box and just have different puppet manifests, and when vagrant starts them, it will apply the specific configuration. that also allows to share boxes and configuration files across teams , for instance having one base box with the linux flavor used in a team, we can just have in source control the puppet manifests to apply for the different configurations that anybody from operations to developers can use.

there is a list of available vms or base boxes ready to use with vagrant at www.vagrantbox.es . but you can build your own and share it anywhere, as they are just (big) virtualbox vm files, easily using veewee , or changing a base box and rebundling it with vagrant package .

usage

once you have installed vagrant and virtualbox.

vagrant init will create a sample vagrantfile, the project definition file that can be customized.

$ vagrant init myproject

then in the vagrantfile you can change the default box settings, and add basic puppet provisioning

config.vm.box = "centos-6"
config.vm.box_url = "https://vagrant-centos-6.s3.amazonaws.com/centos-6.box"

config.vm.provision :puppet do |puppet|
  puppet.manifests_path = "manifests"
  puppet.manifest_file = "site.pp"
end

in manifests/site.pp you can try any puppet manifest.

file { '/etc/motd':
  content => 'welcome to your vagrant-built virtual machine! managed by puppet.\n'
}

vagrant up will download the box the first time, start the vm and apply any configuration defined in puppet

$ vagrant up

vagrant ssh will open a shell into the box. under the hood vagrant is redirecting the host port 2222 to the vagrant box 22

$ vagrant ssh

the vm can be suspended and resumed at any time

$ vagrant suspend
$ vagrant resume

and later on destroyed, which will delete all the vm files.

$ vagrant destroy

and then we can start again from scratch with vagrant up getting a completely new vm where we can make any mistakes :)

Chef (software)

Published at DZone with permission of Carlos Sanchez, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Modernizing Testing With Data Pipelines
  • How to Leverage Method Chaining To Add Smart Message Routing in Java
  • Pattern Matching for Switch
  • Applying Kappa Architecture to Make Data Available Where It Matters

Comments

DevOps Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo