Skip to content

Instantly share code, notes, and snippets.


Tommy McNeely TJM

View GitHub Profile
Last active Aug 5, 2019
Average Puppet Catalog compile time
awk '/Compiled static catalog for/ { x=$(NF-1); sum+=x; total++ }; END { print "Average Compile Time: " sum / total }' /var/log/puppetlabs/puppetserver/puppetserver.log
TJM / .sync.yml
Created Jul 2, 2019
Puppet PDK .sync.yml for our control-repo
View .sync.yml
- /modules
- .vagrant
- vagrant/*/environments/production/*
- vagrant/*/spec/fixtures/modules/*
- .DS_Store
- .DS_Store?
Created Jun 5, 2019
Morpheus parse application instance
echo '<%=instance.apps.first().instances.collect{}%>'
node_hosts_363=(<%= instance.apps.first().instances.findAll{it.metadata.application_component == 'node'}.collect{ it.containers.collect{ it.hostname + '.' + it.domainName } }.flatten().join(' ') %>)
echo "Node 3.6.3: ${node_hosts_363}"
node_hosts=(<%= instance.apps.first().instances.findAll{it.metadata.application_component == 'node'}.collect{ it.hostname + '.DOMAIN.corp' }.flatten().join(' ') %>)
dmgr_hosts=(<%= instance.apps.first().instances.findAll{it.metadata.application_component == 'dmgr'}.collect{ it.hostname + '.DOMAIN.corp' }.flatten().join(' ') %>)
TJM / site.pp
Created Apr 27, 2019
control-repo/manifests/site.pp to select based on pp_role or role fact.
View site.pp
## site.pp ##
# This file (/etc/puppetlabs/puppet/manifests/site.pp) is the main entry point
# used when an agent connects to a master and asks for an updated configuration.
# Global objects like filebuckets and resource defaults should go in this file,
# as should the default node definition. (The default node can be omitted
# if you use the console and don't define any other nodes in site.pp. See
# for more on
# node definitions.)
Created Apr 26, 2019
Run puppet during provisioning - puppet exit code > 1 on changes caused provisioning system to think it had failed
for (( i=0; i<5; i++ )); do
echo "Running Puppet Agent..."
/opt/puppetlabs/puppet/bin/puppet agent -t
if [ $rc = 0 ]; then
echo " *** SUCCESS!"
exit 0
elif [ $rc = 1 ]; then
>&2 echo " *** ERROR!"
Last active Dec 14, 2018
Setup Puppet Enterprise Code Manager to use Artifactory as Puppet Forge

Setup Puppet Enterprise Code Manager to use Artifactory as Puppet Forge

Setup Artifactory

Actually installing Artifactory is outside the scope of this document. It is assumed that your have artifactory PRO or greater already running.

Here are the steps from their documentation on setting up the Puppet Repo:

In the additional files below, you will find a common.yaml and pe.conf fragment.

Last active Dec 14, 2018
Extract roles from puppet for Morpheus OptionList

Extract Puppet Environments and Roles for Morpheus

See inside for javascript to "translate" the output of Puppet API queries to name/value list for Morpheus.

Puppet Enterprise Setup

  • Generate a certificate on the Puppet Master (CA) for morpheus
    • puppet cert generate morhpeus-api
  • Grant Access to the environment_classes API
  • Add mod 'puppetlabs-puppet_authorization', '0.5.0' to Puppetfile (if its not already there)
TJM / nginxplus.pp
Created Dec 10, 2018
Puppet Profile for nginxplus
View nginxplus.pp
# == Class: profile::nginxplus
class profile::nginxplus (
Optional[String] $repo_cert = undef,
Optional[String] $repo_key = undef,
Boolean $manage_repo = true,
Boolean $enable_dashboard = true,
Boolean $dashboard_readonly = true,
Integer $dashboard_port = 8080,
) {
TJM / dash.wsgi
Last active Oct 23, 2018
WSGI file for a Dash / Plotly app with no hard coded paths. Picks up the "prefix" for DASH through the WSGI environment variable SCRIPT_NAME and uses the virtualenv "venv"
View dash.wsgi
import os
import sys
if my_directory not in sys.path:
# Virtual Environment (./venv)
activate_this = os.path.join(my_directory, 'venv', 'bin', '')
TJM / catalog
Created Oct 17, 2018
Puppet Catalog script
View catalog
# catalog
# John Simpson <> 2015-10-30
# Prints a Puppet node's catalog file.
# This *should* work with both OSP and PE.
# 2017-10-11 jms1 - adding "run" option