Sunday, November 8, 2015

Getting started with Puppet - Part 2 - Hello World

This is the second post in the series for getting started with Puppet. We are going to run a really simple Puppet module that is hosted on GitHub.

Tools needed:
Git client (of course)
VM or Nitrous.io or anything similar
Puppet client installed (discussed in Part 1)

Step 1: Download the Hello World module

git clone https://github.com/adityai/puppetStarter.git

Step 2: Run the Puppet hello world sample

cd puppetStarter
sudo puppet apply --modulepath . helloWorld/site.pp

This is how we apply a puppet module from the command line directly on the target machine or on your development workstation.

The output will have some information about verifying or compiling along with a message 'Hello World!"

➜  puppetStarter git:(master) sudo puppet apply --modulepath . helloworld/manifests/site.pp
Notice: Compiled catalog for ruby-on-rails-139787.us-west-2.compute.internal in environment production in 0.05 seconds
Notice: Hello World
Notice: /Stage[main]/Helloworld/Notify[Hello World]/message: defined 'message' as 'Hello World'
Notice: Finished catalog run in 0.04 seconds



➜  puppetStarter git:(master) sudo puppet apply --modulepath . helloworld/manifests/site.pp
Notice: Compiled catalog for ruby-on-rails-139787.us-west-2.compute.internal in environment production in 0.05 seconds
Notice: Hello World
Notice: /Stage[main]/Helloworld/Notify[Hello World]/message: defined 'message' as 'Hello World'
Notice: Finished catalog run in 0.04 seconds
➜  puppetStarter git:(master) sudo puppet apply --modulepath . helloworld/manifests/site.pp
Notice: Compiled catalog for ruby-on-rails-139787.us-west-2.compute.internal in environment production in 0.05 seconds
Notice: Hello World
Notice: /Stage[main]/Helloworld/Notify[Hello World]/message: defined 'message' as 'Hello World'
Notice: Finished catalog run in 0.04 seconds
Step 3: Take a look around. 
Observe the folder structure. The module folder is helloWorld. There are other default folders besides manifests inside the module that will be required for advanced topics. Try to understand the code in the init.pp, motd.pp and site.pp. We will dig into it in Part 3 and try to do something more fun.