Big Picture

Version 2 (Anonymous, 03/13/2010 08:01 pm)

1 1
2 1
3 1
## TracNav
4 1
5 1
#### New To Puppet?
6 1
7 1
-   [[About Puppet]]
8 1
-   [[Puppet Compatibility]]
9 1
-   [[Whos Using Puppet]]
10 1
-   [[Getting Started]]
11 1
-   [[Puppet Best Practice]]
12 1
-   [[Downloading Puppet]]
13 1
-   [[Language Tutorial]]
14 1
-   [[Frequently Asked Questions]]
15 1
-   [[Documentation Start]]
16 1
-   [[Getting Help]]
17 1
-   [[Whos Using Puppet]]
18 1
19 1
#### Release Notes
20 1
21 1
-   [[Glossary Of Terms]]
22 1
-   [[Style Guide]]
23 1
-   [[Puppet Recipes]]
24 1
-   [[Facter Recipes]]
25 1
-   [[Recipe Requests]]
26 1
-   [[Module Organisation]]
27 1
-   [[Puppet Modules]]
28 1
-   [[Puppet Executables]]
29 1
-   [[Puppet Internals]]
30 1
31 1
#### References and Advanced Topics
32 1
33 1
-   [[Type Reference]]
34 1
-   [[Nagios Reference]]
35 1
-   [[Function Reference]]
36 1
-   [[Metaparameter Reference]]
37 1
-   [[Configuration Reference]]
38 1
-   [[Network Reference]]
39 1
-   [[Report Reference]]
40 1
-   [[Writing Your Own Functions]]
41 1
-   [[Parsing Architecture]]
42 1
43 1
44 1
45 1
# Big picture
46 1
47 1
Puppet is a **declarative language** for expressing system
48 1
configuration, a **client and server** for distributing it, and a
49 1
**library** for realizing the configuration.
50 1
51 1
Rather than approaching server management by automating current
52 1
techniques, Puppet reframes the problem by providing a language to
53 1
express the relationships between servers, the services they
54 1
provide, and the primitive objects that compose those services.
55 1
Rather than handling the detail of how to achieve a certain
56 1
configuration or provide a given service, Puppet users can simply
57 1
express their desired configuration using the abstractions they're
58 1
used to handling, like service and node, and Puppet is responsible
59 1
for either achieving the configuration or providing the user enough
60 1
information to fix any encountered problems.
61 1
62 1
This document is a supplement to the [[Puppet Introduction]] and it
63 1
is assumed that readers are familiar with the contents of that
64 1
document.
65 1
66 1
## Less Detail, More Information
67 1
68 1
A correct configuration must obviously provide the appropriate
69 1
details, but a configuration tool should understand that the
70 1
details are generally the easy part. The hard part of system
71 1
configuration is understanding the complex relationships between
72 1
services and the objects that comprise those services. One of the
73 1
primary goals of Puppet is to allow users to push the details into
74 1
lower levels of the configuration and pull the relationships into
75 1
the foreground.
76 1
77 1
For instance, take a typical Apache web server deployment. Puppet
78 1
allows one to encapsulate all of the primitives necessary for
79 1
successful deployment into one reusable object, and that object can
80 1
even be abstracted to support multiple apache versions. Here's how
81 1
a simple apache definition might look for a Debian server (Debian
82 1
uses apache for 1.x versions and apache2 for 2.x versions):
83 1
84 1
    define apache(version, conf, user, group) {
85 1
        # abstract across apache1 and apache2
86 1
        $name = $version ? {
87 1
            1 => "apache",
88 1
            2 => "apache2",
89 1
        }
90 1
        package{ $name:
91 1
            install => true,
92 1
        }
93 1
    
94 1
        file { "$conf":
95 1
            user   => "$user",
96 1
            group  => "$group",
97 1
            source => "$conf",
98 1
        }
99 1
    
100 1
        # we want the service to restart if the config file changes
101 1
        # or if the package gets upgraded
102 1
        service { "$name":
103 1
            running  => true,
104 1
            subscribe => [file["$conf"], package["$name"]],
105 1
        }
106 1
    }
107 1
108 1
Now, with this configuration, one can easily set multiple servers
109 1
up to run different versions of apache. The key benefit here is
110 1
that the information necessary to run apache correctly is separated
111 1
from the decision to do so on a given host. For example:
112 1
113 1
    # import our apache definition file
114 1
    import "apache"
115 1
    
116 1
    node server1 {
117 1
        # use a locally-available config file
118 1
        apache {
119 1
            version => 1,
120 1
            conf  => "/nfs/configs/apache/server1.conf",
121 1
            user  => "www-data",
122 1
            group => "www-data",
123 1
        }
124 1
    }
125 1
    
126 1
    node server2 {
127 1
        # use a config that we pull from elsewhere
128 1
        apache {
129 1
            version => 2,
130 1
            conf    => "http://configserver/configs/server2/httpd.conf"
131 1
            user    => "www-data",
132 1
            group   => "www-data",
133 1
        }
134 1
    }
135 1
136 1
Notice that our node configuration only specifies 1) that a given
137 1
server is running Apache, and 2) the information necessary to
138 1
differentiate this instance of apache from another instance. If a
139 1
given detail is going to be the same for all apache instances (such
140 1
as the fact that the service should be running and that it should
141 1
be restarted if the configuration file changes), then that detail
142 1
does not have to be specified every time an Apache instance is
143 1
configured.
144 1
145 1
## Describing Configuration
146 1
147 1
Puppet's declarative language separates the "what" of the
148 1
configuration from the "how". The "how" is pushed into the library,
149 1
which generally provides the ability to manage a given entity on
150 1
multiple platforms, isolating the Puppet user from platform
151 1
details.
152 1
153 1
**Language Example: Class Hierarchy Using Inherit**
154 1
155 1
Inheritance can be used to override default values defined in base
156 1
classes:
157 1
158 1
    class base {
159 1
    
160 1
    
161 1
    
162 1
        file { "/etc/sudoers":
163 1
            owner => "root",
164 1
            group => "root",
165 1
            mode  => 440
166 1
        }
167 1
    }
168 1
    
169 1
    # FreeBSD has a "wheel" group instead of a "root" group
170 1
    class freebsd inherits base {
171 1
        file [ "/etc/sudoers" ] {
172 1
            group => "wheel",
173 1
        }
174 1
    
175 1
    }
176 1
177 1
## Distributing Configuration
178 1
179 1
The Puppet framework Library consists of a client and server.
180 1
181 1
(picture/diagram: client, server, site-config -> host-config)
182 1
183 1
A Puppet server is aware of the full configuration. As some
184 1
component's configuration aspects depend on the configuration of
185 1
other components (e.g. the firewall config includes the ports used
186 1
by webservers), generating configuration for a component requires
187 1
being aware of full configuration.
188 1
189 1
A Puppet client that runs on a specific host (or perhaps the same
190 1
host as its Puppet Server) is generally only concerned with the
191 1
components to be configured on that host.
192 1
193 1
Puppet Clients normally request or "pull" configuration from their
194 1
server. The Server processes the configuration request for the host
195 1
using a pre-generated tree model of the classes and definitions
196 1
from the site-config.
197 1
198 1
When configuration needs to be "pushed" to the clients, the Server
199 1
can be asked to attempt to trigger each client to request "pull" a
200 1
new host configuration.
201 1
202 1
Example: Puppet server, library
203 1
204 1
You can read more about the Puppet language in the [[Language
205 1
Tutorial]] .
206 1
207 1
## Realizing the Configuration
208 1
209 1
The Puppet Client Library contains the component knowledge of how
210 1
to reach desired states and configurations for several objects:
211 1
File, Package, etc.
212 1
213 1
Example: Puppet Client, library:
214 1
215 1
...todo: file: transfer, mode, ownership...
216 1
217 1
You can read more about the Puppet language in the [[Language
218 1
Tutorial]] .
219 1
220 1
Some components such as the webserver and firewall, from the
221 1
simple-website example, require additional code to reach "closure".
222 1
"Closure" is when the component is entirely responsible for
223 1
implementing its own configuration.
224 1
225 1
Much as database applications abstract the mechanics of storing,
226 1
indexing, and searching their data, a component ideally should
227 1
abstract the specifics of how to store, confirm, and implement its
228 1
requested configuration.