Using fileserver in Puppet

Puppet Server includes a file server for transferring static file content to agents; this is what’s used whenever a file resource has a source => puppet:///... attribute specified.
 Mostly files can be served via modules but if we need to serve larger files that shouldn’t be with a module, you can make a custom file server mount point and let Puppet serve those files from another directory.

Creating a File Server:

1. Create a directory which puppet Can access and copy files which needs to be exported  to this directory. 

2. Create filserver.conf  and define directory and hosts which can access this directory. 
             
                    $ touch   /etc/puppetlabs/puppet/fileserver.conf
 
Defining File Server:

fileserver.conf uses a one-off format that resembles an INI file without the equals (=) signs. It is a series of mount-point stanzas, where each stanza consists of:

  • A [mount_point_name] surrounded by square brackets. This will become the name used in puppet:/// URLs for files in this mount point.
  • A path directive, where is an absolute path on disk. This is where the mount point’s files are stored.
  • An allow * directive.
Example: 
 
        # cat /etc/puppetlabs/puppet/fileserver.conf
        [scripts]
        path /apps/puppetlabs/code/environments/production/scripts
        allow *
        [packages]
        path /apps//puppetlabs/code/environments/production/packages
        allow *

      

In the above example I am creating two locations from which files will be served. One is scripts directory and the other location is packages . Both this directory can be created under the same location where modules directory is available.To identify  module's location , we can use the following parameter.

          # puppet config print modulepath
           /etc/puppetlabs/code/environments/production/modules:
         


Now, I will show a manifests which is used to  access files from above directories served by file-server.

  file { '/home/agile/apache.sh':
       path => '/home/agile/apache.sh',
       ensure => present,
       mode => "755",
       owner => agile,
       source => "puppet:///scripts/apache.sh",
    }


  file { "/usr/local/httpd-2.2.22.tar.gz":
        path => "/usr/local/httpd-2.2.22.tar.gz",
        ensure => present,
        owner => agile,
        group => agile,
        source => "puppet:///packages/httpd-2.2.22.tar.gz",
   }


Happy Serving!  using Puppet FileServer
  

Comments

Popular posts from this blog

PSSH : Parallel SSH to execute commands on a number of hosts

How to add check_http as a service in Nagios Monitoring using NRPE

Configuring Nagios to monitor services using NRPE