lauantai 6. huhtikuuta 2013

Puppet manifest basic examples

I wanted to understand puppet better so I did my first homework again. Here are some basic manifests and I will also explain those.

Create a folder for Puppet mount it and create file named init.pp.

$ mkdir puppet
$ mkdir manifests
$ cd pupppet/manifests
$ nano init.pp

Inside the init file we write:

file {'just testing puppet': 
path => '/tmp/this is just testfile',
ensure => present, 
mode => 0640, 
content => "contains test content", }

cd to manifests folder which we just created, cd puppet/manifests

$ puppet apply init.pp
notice: /Stage[main]//File[just testing]/ensure: created 
notice: Finished catalog run in 0.02 seconds

See your tmp folder and notice it created that file.

Second manifest. Lets install apache and make sure it is running. You can edit the init.pp or create a new file ending .pp

package { 'apache2': 
 ensure => installed } 
service { 'apache2':
 ensure => running }

Lets run that. Notice that you have to run it with root rights because you have to install new service.

$ sudo puppet apply init.pp 
warning: Could not retrieve fact fqdn 
notice: Finished catalog run in 0.39 seconds

For me it worked out of the box. I just read that someone had to apply it twice because it tries to run the service before installing it.

To see if apache2 is running use:
$ sudo service apache2 status
Apache2 is running (pid12758).

Ei kommentteja:

Lähetä kommentti