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
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. Using Puppet to Deploy with a Push

Using Puppet to Deploy with a Push

Mike Dirolf user avatar by
Mike Dirolf
·
Nov. 16, 11 · Interview
Like (1)
Save
Tweet
Share
12.85K Views

Join the DZone community and get the full member experience.

Join For Free

Prior to Fiesta my ops background was pretty minimal. Managing ops for Fiesta quickly taught me the value of a configuration management system like Puppet. I think it’s a great tool and we’ll probably do some more posts about how we’re putting it to use. In this post I’m going to explain how we use Puppet to manage deploying new versions of our codebase.

Deploying from Git

One of the goals I had in mind with our deployment infrastructure was the ability to deploy new code just by doing a `git push`. This minimizes the friction involved in a deploy and incentivizes us to deploy often.

The first step in the deployment process is for puppet to update a version of our repository on each Puppet node (this happens every time that Puppet runs). Here’s the section of our configuration file that manages that:

vcsrepo { "/home/fiesta/fiesta":
  owner => fiesta,
  group => fiesta,
  ensure => latest,
  revision => "prod",
  provider => git,
  require => [ Package["git"],
               Sshkey["git.fiesta.cc"] ],
  source => "ssh://git@git.fiesta.cc/home/git/fiesta.git"
}

For those of you who are new to Puppet, I’ll walk through this rule. We are configuring a new `vcsrepo`, which is a resource type for working with version control systems. The repository will be located at “/home/fiesta/fiesta”, and we configure it with a series of parameters. “owner” and “group” specify Unix permissions for the repository. The “ensure” parameter tells Puppet to always update the repository to the latest version. “revision”, “provider” and “source” establish the branch we want to update, the type of VCS we are using, and where to update the repository from, respectively.

Lastly, we specify several requirements (using the “require” parameter). The requirements are used by Puppet to establish a dependency chain and properly order the operations that need to be performed in a given Puppet run. Here, we say that updating this repository depends on having Git installed and having the proper SSH key in place. Both of those steps are managed elsewhere in our configuration file.

After updating the repository, we still need to restart the various server processes that run based on that code. We do that by configuring each of those services in Puppet, here’s the configuration for one of our web servers:

service { "www":
  ensure => running,
  subscribe => Vcsrepo["/home/fiesta/fiesta"],
  start => "/home/fiesta/fiesta/www.py start",
  stop => "/home/fiesta/fiesta/www.py stop",
  status => "/home/fiesta/fiesta/www.py status",
  require => Service["mongod"]
}

We can see some of the same patterns as above. This time, we’re configuring a `service`, which we want Puppet to ensure is running. We specify “start”, “stop”, and “status” commands, which Puppet can use to determine the status of the service and start/stop/restart it as needed. Our service depends on another service, “mongod”, which we’ve configured elsewhere.

The interesting piece for the problem at hand is the “subscribe” parameter. We subscribe the “www” service to the `vcsrepo` that we configured above. That means that every time the repository is updated the “www” service will be restarted using the new code.

Next Steps

What we’ve configured so far is a system that will restart the web server when new code is pushed to the “prod” branch. The deployment happens only when Puppet next runs, though (we schedule Puppet runs for approximately every 30 minutes). It’d be interesting to look at adding a git post-receive hook to our server that could run the deployment immediately after a push. Another thing to look at would be improving our ability to roll-back deployed code.

Is anybody else using a set up similar to this? What issues have you encountered and how are you handling them?

Git Repository (version control)

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • DevOps for Developers — Introduction and Version Control
  • What Is Continuous Testing?
  • Top 11 Git Commands That Every Developer Should Know
  • Strategies for Kubernetes Cluster Administrators: Understanding Pod Scheduling

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: