Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Slides and code samples from PuppetConf 2012

branch: master

Merge pull request #1 from thomasbiddle/api_patches

Adding option to change protocol. Adding option to not use storedconfigs...
latest commit 5be304eb20
Dave Dash davedash authored
Octocat-spinner-32 api-examples Initial commit. September 26, 2012
Octocat-spinner-32 LICENSE Initial commit. September 26, 2012
Octocat-spinner-32 README.md Initial commit. September 26, 2012
Octocat-spinner-32 api.py Adding option to change protocol. Adding option to not use storedconf… December 05, 2013
Octocat-spinner-32 cleanup_old_certs.py Initial commit. September 26, 2012
Octocat-spinner-32 presentation.pdf Initial commit. September 26, 2012
Octocat-spinner-32 puppet_to_hosts.py Initial commit. September 26, 2012
README.md

Puppet API and Related Code Examples

The script api.py is an example of a REST API for Puppet Dashboard and Puppet storeconfigs data. This script is a self-contained application written using Python's Flask microframework.

This script was designed specifically for Pinterest's infrastructure, so it might not directly be relevant for your environment. We wanted to publish some sample code to show how our REST API works, and we hope this is at least a starting point for those of you that choose to create your own API.

Copyright (c) 2011-2012 Pinterest, Inc. See LICENSE for details.

Prerequisites:

  1. You must be using Puppet Dashboard 1.2 or higher, preferably version 1.2.10 or above.
  2. Your puppetmaster must be configured to use storeconfigs (storeconfigs=true in your puppetmaster's /etc/puppet/puppet.conf).
  3. This scripts requires Python 2.7 the Python libraries PyMySQL and Flask.

Usage: python api.py <port> to run a single-threaded web server process on the given port. Defaults to port 9000.

We recommend running this in conjunction with Supervisor, a watchdog daemon for Python applications. Here's an example Supervisor config stanza to run 8 processes on ports 9000-9007:

[program:puppet_api]
directory=/usr/local/puppet-api
command=python api.py 90%(process_num)02d
process_name=%(program_name)s_%(process_num)02d
numprocs=8
priority=999
autostart=true
autorestart=true
startsecs=10
user=nobody
Something went wrong with that request. Please try again.