I've recently started using Puppet.  One of the things I first struggled with was creating a hello world application.

If you look at the getting started documentation you are pointed to a Puppet hello world.  This  was promising but turned out to be more complicated than I had hoped as it was configuring a client and a server.

Puppet Standalone

The installation guide mentioned Puppet Standalone. This sounded like what I wanted but I couldn’t find any other information about installing in this mode.

This isn’t surprising as the documentation is aimed at enterprise use and this wouldn’t be valuable in that context.

Install Standalone puppet

After some trial and error I realised that to install standalone puppet you simply download the puppet agent MSI.

Once installed, we just need to write a script to do something.  The simplest thing I could think of is to create a folder and write a file into the new folder.

Hello World Script

Puppet declares the steps to set up a machine in puppet classes.  Once I found an example the file type on Puppet Cookbooks it was pretty simple to create this script;

class MyFirstScript{

file{'c:\HelloWorld\hellowWorld.txt':       

ensure =>file,        

content => 'Hello world!',       

}

file{"c:\HelloWorld":
ensure =>"directory",

}

}

include MyFirstScript

Save this as MyFirstScript.pp.  pp is the extension used for puppet scripts.

The script creates a file called hellowWorld.txt in the c:\HelloWorld folder and adds some content to the file.

Running the script

Now we’re going to check the script is valid and execute the script.

Open a command window and use the puppet command to check the syntax of the script;

puppet parser validate MyFirstScript.pp

Now to run this locally at the command line.

puppet apply MyfirstScript.pp

You should now be able to  navigate to the file to check it’s been created.

Next steps

This isn’t particularly useful but it shows how to install and run your first script in puppet.

Puppet labs have some great resources to learn about puppet and there are plenty of example modules and cookbooks.