Skip to content

Instantly share code, notes, and snippets.

View TJM's full-sized avatar

Tommy McNeely TJM

View GitHub Profile
@TJM
TJM / Feedback.md
Last active April 23, 2018 18:53
Puppet Language Basics Feedback

Puppet Language Basics Feedback

I am taking this course as an "expert" for feedback purposes. I am being particularly nit-picky because that is what I would want if I asked for feedback :)

General Feedback

  • Put the section "title" at the top. Maybe this would only help during the feedback phase, but I had to wait till I got to the next section to find out the title of the first one. (on the back button)
  • If the test button is "disabled" there needs to be a reason
  • There are several places where it is obvious that rspec is being used (from the errors), but upon success, I get the output passed which really doesn't need to be there. I recommend omitting the "passed" output if that is all there is, stick with the bold text "success" that is already there. In several cases, it might be better to have the puppet output, but in others it is probably not useful.
  • The "errors" from the rspec-puppet tests made sense to me, but I think for a "Puppet 101" course, rspec-puppet is not going to be useful. The
@TJM
TJM / Jenkinsfile
Last active October 25, 2018 20:23
First (workable) attempt at using Pipeline for Puppet control-repo code testing and deployment - Uses the Mesos plugin to spin up slaves as "cloud1" and the Puppet Enterprise plugin for deployment https://wiki.jenkins.io/display/JENKINS/Puppet+Enterprise+Pipeline+Plugin
#!/usr/bin/env groovy
// NOTE:
// * This is designed to work as a Multi-Branch PIPELINE buid.
// * Our Jenkins Slave is mesos and labeled "cloud1" (you may need to adjust)
// * This uses the Puppet Enterprise Jenkins plugin. It assumes that is setup
// * Also there needs to be a credential (API KEY) with the id of "puppet"
pipeline {
//agent { label 'cloud1' }
@TJM
TJM / catalog
Created October 17, 2018 21:26
Puppet Catalog script
#!/bin/bash
#
# catalog
# John Simpson <jms1@jms1.net> 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
@TJM
TJM / dash.wsgi
Last active October 23, 2018 14:00
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"
import os
import sys
my_directory=os.path.dirname(__file__)
if my_directory not in sys.path:
sys.path.insert(0,my_directory)
# Virtual Environment (./venv)
activate_this = os.path.join(my_directory, 'venv', 'bin', 'activate_this.py')
@TJM
TJM / nginxplus.pp
Created December 10, 2018 17:22
Puppet Profile for nginxplus
# == 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
TJM / A-ExtractPuppetEnvironmentsAndRolesForMorpheus.md
Last active December 14, 2018 16:23
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
TJM / artifactory-forge-for-puppet-enterprise.md
Last active December 14, 2018 16:04
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: https://www.jfrog.com/confluence/display/RTF/Puppet+Repositories

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

@TJM
TJM / run_puppet.sh
Created April 26, 2019 19:18
Run puppet during provisioning - puppet exit code > 1 on changes caused provisioning system to think it had failed
#!/bin/bash
for (( i=0; i<5; i++ )); do
echo "Running Puppet Agent..."
/opt/puppetlabs/puppet/bin/puppet agent -t
rc=$?
if [ $rc = 0 ]; then
echo " *** SUCCESS!"
exit 0
elif [ $rc = 1 ]; then
>&2 echo " *** ERROR!"
@TJM
TJM / site.pp
Created April 27, 2019 22:40
control-repo/manifests/site.pp to select based on pp_role or role fact.
## 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
# http://docs.puppetlabs.com/guides/language_guide.html#nodes for more on
# node definitions.)
@TJM
TJM / app_hosts.sh
Created June 5, 2019 23:03
Morpheus parse application instance
echo '<%=instance.apps.first().instances.collect{it.name}%>'
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(' ') %>)