@@ -273,7 +273,60 @@ Puppet modules.
273273 $ facter operatingsystem
274274 Ubuntu
275275
276-
276+ Writing Modules in Puppet is pretty straight forward. Puppet Manifests together form
277+ Puppet Modules. Puppet manifest end with an extension of ``.pp ``.
278+ Here is an example of 'Hello World' in Puppet.
279+
280+ .. code-block :: puppet
281+
282+ notify { 'This message is getting logged into the agent node':
283+
284+ #As nothing is specified in the body the resource title
285+ #the notification message by default.
286+ }
287+
288+ Here is another example with system based logic. Note how the operatingsystem fact
289+ is being used as a variable prepended with the ``$ `` sign. Similarly, this holds true
290+ for other facts such as hostname which can be referenced by ``$hostname ``
291+
292+ .. code-block :: puppet
293+
294+ notify{ 'Mac Warning':
295+ message => $operatingsystem ? {
296+ 'Darwin' => 'This seems to be a Mac.',
297+ default => 'I am a PC.',
298+ },
299+ }
300+
301+ There are several resource types for Puppet but the package-file-service paradigm is all
302+ you need for undertaking majority of theconfiguration management. The following Puppet code makes sure
303+ that the OpenSSH-Server package is installed in a system and the sshd service is notified to restart
304+ everytime the sshd configuration file is changed.
305+
306+ .. code-block :: puppet
307+
308+ package { 'openssh-server':
309+ ensure => installed,
310+ }
311+
312+ file { '/etc/ssh/sshd_config':
313+ source => 'puppet:///modules/sshd/sshd_config',
314+ owner => 'root',
315+ group => 'root',
316+ mode => '640',
317+ notify => Service['sshd'], # sshd will restart
318+ # whenever you edit this
319+ # file
320+ require => Package['openssh-server'],
321+
322+ }
323+
324+ service { 'sshd':
325+ ensure => running,
326+ enable => true,
327+ hasstatus => true,
328+ hasrestart=> true,
329+ }
277330 `Puppet Labs Documentation <http://docs.puppetlabs.com >`_
278331
279332Blueprint
0 commit comments