Skip to content

Instantly share code, notes, and snippets.

View TJM's full-sized avatar

Tommy McNeely TJM

View GitHub Profile
@TJM
TJM / sync_pulp.sh
Created June 30, 2020 15:07
Sync all repos (or a list of repos) in pulp
#!/bin/bash -e
if [ $# -gt 0 ]; then
REPOS=$*
else
REPOS=$(pulp-admin repo list | awk '/Id:/ {print $NF}')
fi
for repo in $REPOS
do
@TJM
TJM / k8s-storage-shell.sh
Last active July 11, 2023 03:22
K8s-Storage-shell - Connect to PVC with interactive shell
#!/bin/bash
#
# Start a debug-storage container mounting a specific volume (pvc)
#
IMAGE='centos:7'
if [ $# == 1 ]; then
PVC=$1
else
@TJM
TJM / average_compile_time.sh
Last active August 5, 2019 22:14
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
TJM / .sync.yml
Created July 2, 2019 18:15
Puppet PDK .sync.yml for our control-repo
---
.gitignore:
paths:
- /modules
- .vagrant
- vagrant/*/environments/production/*
- vagrant/*/spec/fixtures/modules/*
- .DS_Store
- .DS_Store?
@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(' ') %>)
@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 / 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 / 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 / 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 / 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,
) {