How to install Puppet

This is step by step how you will install Puppet to your Xubuntu 12.04.03.

What is Puppet?

Update your packages and install Puppet

$ sudo apt-get update && sudo apt-get -y install puppet

Test if Puppet works. One line command to Puppet.

$ puppet apply -e 'file { "/tmp/helloPuppet": content => "Hello World!\n" }'
notice: /Stage[main]//File[/tmp/helloPuppet]/ensure: defined content as '{md5}8ddd8be4b179a529afa5f2ffae4b9858'
notice: Finished catalog run in 0.01 seconds

Let’s make sure if the file was created.

$ cat /tmp/helloPuppet
Hello World!

Make hellotest module

$ mkdir puppet
$ cd puppet/
$ mkdir -p modules/hellotest/manifests/
$ nano modules/hellotest/manifests/init.pp

class hellotest {
    file { '/tmp/testModule':
        content => "Come visit Soivi.net!\n"
    } 
}

Apply Puppet module and test if the file is created.

$ puppet apply --modulepath modules/ -e 'class {"hellotest":}'
notice: /Stage[main]/Hellotest/File[/tmp/testModule]/ensure: defined content as '{md5}f0033e0a0e954ec5096ef8af2126fc21'
notice: Finished catalog run in 0.03 seconds
$ cat /tmp/testModule
Come visit Soivi.net!

Make module that installs gedit.

$ mkdir -p modules/gedit/manifests/
$ nano modules/gedit/manifests/init.pp

class gedit {
    package { "gedit":
        ensure     => present,
    }
}

Apply Puppet module that installs Gedit

$ sudo puppet apply --modulepath modules/ -e 'class {"gedit":}'

notice: /Stage[main]/Gedit/Package[gedit]/ensure: ensure changed 'purged' to 'present'
notice: Finished catalog run in 16.29 seconds

Let’s test that Gedit will start

$ gedit

Now you have successfully installed Puppet and tested it.

Sources
http://terokarvinen.com/2013/hello-puppet-revisited-%E2%80%93-on-ubuntu-12-04-lts
http://docs.puppetlabs.com/learning/ral.html
http://docs.puppetlabs.com/learning/ordering.html

This post is part of course