DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
11 Monitoring and Observability Tools for 2023
Learn more

Puppet: A Beginners Concept Guide (Part 1)

Abhishek Kumar user avatar by
Abhishek Kumar
·
Jun. 01, 12 · Interview
Like (2)
Save
Tweet
Share
37.32K Views

Join the DZone community and get the full member experience.

Join For Free
Someone asked me where to start with Puppet learning. I pointed them at PuppetLabs online docs for Puppet, which are actually nice for a proper understanding.

But for someone trying to start with Puppet, that documentation is a bit long to read, similar to a book.

I searched for a few blogs, but didn't find any content (short but enough, fundamentals, but usable) that I was looking for.  Here is what I've created to fill that void...
____________________________________________________


Puppet

Beginners concept guide (Part 1)


What  is it?  When  is  it  required?  (for all new guys, who came here while just browsing internet)

Puppet is an OpenSource automated configuration management framework (which means a tool that knows how to configure all machines to a deterministic state once you provide it the required set of manifests pulling the correct strings).
It has an enterprise level that is sold by an organization called PuppetLabs (http://puppetlabs.com/).

It is useful #1 when you have a helluva-lot of machines required to be configured in a similar form.
It is useful #2 when you have an infrastructure that requires the dynamic scaling-up and scaling-down of machines with a pre-determined (or at least metadata-calculated) configuration.
It is useful #3 to have control over all of your configured machines, so a centralized (master-server or repo-based) change gets propagated to all automatically.
And more scenarios come up as you require it.

_____________________________________


Hello World with Puppet

Install Ruby, Rubygems on your machine where you aim to test it.

$ gem install puppet --no-ri --no-rdoc
Download installers @Windows  @MacOSX :: & :: Docs to installing.

Checking if it's installed properly and acting good...

Now, 'puppet --version' shall give you the version of the installation.
Executing 'facter' will give you a list of System Environment related major information.

Have a quick puppet instance run.  This shall create a directory '/tmp/pup' if one doesn't exist. It creates a file '/tmp/pup/et' with 'look at me' as its content.
{If you're using a platform without the '/tmp' location. Like for Windows, change '/tmp' to 'C:/' or the equivalent}

$ puppet apply -e "file{'/tmp/pup':
                               ensure => 'directory'}
                             file{ '/tmp/pup/et':
                               ensure => 'present',
                               content => 'look at me',
                               require => File['/tmp/pup']}
                           "
_____________________________________


Dumb  usage  structure.
Create a huge manifest for your node with all resources & data mentioned in it. Then directly apply that manifest file instead of '-e "abc{.....xyz}"'.

If the example above is your entire huge configuration commandment for the node, copy all that to a file called 'mynode.pp'.
Then apply it similarly like
$ puppet apply mynode.pp
_____________________________________


How  it  evolves

Now, just as any application with pluggable library components has to be loaded and shared when required, Puppet too has a concept of modules. These modules can have manifests, files-serving and more.

Modules can be created in any design preference. Normally it works by having different modules per system component. To entertain different logical configuration states for any given system component (and also keeping it clean) further re-factoring can be done in the modules' manifest dividing it into different scopes.

Here is an example of a module for 'apache httpd'. For a very basic library, you might wanna structure your module like this

  • a directory base for your module:  <MODULE_PATH>httpd/
  • a directory in module to serve static files:   <MODULE_PATH>/httpd/files
  • static configuration file for httpd:  
    <MODULE_PATH>/httpd/files/myhttpd.conf
    AccessFileName .acl
  • directory to hold your manifests in module:  
    <MODULE_PATH>/httpd/manifests/
  • a complete solution manifest:  
    <MODULE_PATH>/httpd/manifests/init.pp
    class httpd{
      include httpd::install
      include httpd::config
      include httpd::service
    }
  • a manifest just installing httpd:   
    <MODULE_PATH>/httpd/manifests/install.pp
    class httpd::install {  package {'httpd': ensure => 'installed'}
    }
  • a manifest just configuring httpd:  
    <MODULE_PATH>/httpd/manifests/config.pp
    class httpd::config{  file {'/etc/httpd/conf.d/httpd.conf':
        ensure => 'present',
        source => 'puppet:///modules/httpd/myhttpd.conf'
      }
    }
  • a manifest just handling httpd service: 
    <MODULE_PATH>/httpd/manifests/service.pp
    class httpd::service{
      service{'httpd': ensure => 'running' }
    }

Now, using it
$ puppet apply --modulepath=<MODULE_PATH>  -e "include httpd"
would install, custom-configure and start the httpd service.
  $ puppet apply --modulepath=<MODULE_PATH>  -e "include httpd::install
"
would just install the httpd service.

Coming next... Part 2...
Concept (generic programming) Manifest file

Published at DZone with permission of Abhishek Kumar, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Keep Your Application Secrets Secret
  • Journey to Event Driven, Part 1: Why Event-First Programming Changes Everything
  • Spinnaker vs. Argo CD: Best Tools for Continuous Delivery
  • 7 Most Sought-After Front-End Frameworks for Web Developers

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: