Skip to content

Instantly share code, notes, and snippets.

Tommy McNeely TJM

  • Lark Information Technology, Inc. (@LarkIT)
  • Broomfield, CO, USA
Block or report user

Report or block TJM

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@TJM
TJM / average_compile_time.sh
Last active Aug 5, 2019
Average Puppet Catalog compile time
View average_compile_time.sh
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
TJM / .sync.yml
Created Jul 2, 2019
Puppet PDK .sync.yml for our control-repo
View .sync.yml
---
.gitignore:
paths:
- /modules
- .vagrant
- vagrant/*/environments/production/*
- vagrant/*/spec/fixtures/modules/*
- .DS_Store
- .DS_Store?
@TJM
TJM / app_hosts.sh
Created Jun 5, 2019
Morpheus parse application instance
View app_hosts.sh
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(' ') %>)
@TJM
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
# http://docs.puppetlabs.com/guides/language_guide.html#nodes for more on
# node definitions.)
@TJM
TJM / run_puppet.sh
Created Apr 26, 2019
Run puppet during provisioning - puppet exit code > 1 on changes caused provisioning system to think it had failed
View run_puppet.sh
#!/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 / artifactory-forge-for-puppet-enterprise.md
Last active Dec 14, 2018
Setup Puppet Enterprise Code Manager to use Artifactory as Puppet Forge
View artifactory-forge-for-puppet-enterprise.md

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 / A-ExtractPuppetEnvironmentsAndRolesForMorpheus.md
Last active Dec 14, 2018
Extract roles from puppet for Morpheus OptionList
View A-ExtractPuppetEnvironmentsAndRolesForMorpheus.md

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 / 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
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
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 / catalog
Created Oct 17, 2018
Puppet Catalog script
View catalog
#!/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
You can’t perform that action at this time.