Sie sind auf Seite 1von 1

Hello and welcome to introduction to puppet and server orchestration.

In this
tutorial, you will learn how to utilize puppet for server orchestration.
Requirement for this tutorial is a modern linux distribution with puppet 3.3 or
higher.

Let's make puppet do something. The code you see will create a file
/tmp/tutorial.txt containing "This is tutorial about puppet". In order to execute
the code, you will usualy run "puppet apply". In it's output, puppet will tell you
what it just executed, and was it successfull or not. Let's break the code just to
see what it looks like in an unperfect world. To do that, we'll declare a file in a
nonexistent path, like /tmp/nonexistent/tutorial.txt. As puppet is noisy when it
encounters an error, take a moment or two to study it's output.

Let's tell puppet to create the missing directory and notify when everything is
done. Notice that puppet notified us before tutorial.txt was created. That is
because puppet doesn't know what order of resources you want. To enforce the order
of resources, puppet introduces concept of relations. Any resource can require any
other resource, or it can subscribe to it. The difference is that "require"
relation only requires that parent resource is present, while "subscribe" relation
will execute resource when ever it's parent resource changes.

We'll ilustrate this on a new example. Let's say you need to create a directory,
and download google's index.html in it. Exec resource needs directory where command
will be executed, or CWD, path, as puppet doesn't pick up your PATH shell variable,
and the command itself. We require that directory is created first. If you apply
this puppet code once, it will work as expected, but any subsequent puppet apply
will create new html file. For the sake of this example, let's say we want puppet
to download new html only once. That's achieved through refreshonly directive, like
so. Now you can execute this puppet code multiple times, knowing it will execute
wget command only once. If you want puppet to execute it every time /tmp/exec
changes, you need to use subscribe directive, instead of require.

Sometimes it's easier to write relations in oposite direction. For example, instead
of subscribe in exec, you can use notify in file without changing the relation
itself. So, in short, notify is the same as subscribe, and before is the same as
require. The only difference is where you declare your relation.

That would be all for this tutorial. For a reference of all puppet resources, you
can go to http://docs.puppetlabs.com/references/stable/type.html

Das könnte Ihnen auch gefallen