Skip to content

Instantly share code, notes, and snippets.

@ajroetker
ajroetker / .vimrc
Created September 24, 2013 16:48
This is my vim configuration!
"-----------------------------------------------------------------------
"Andrew's vimrc based on Hunner, BaSS & ciaran
"-----------------------------------------------------------------------
"-----------------------------------------------------------------------
" terminal setup
"-----------------------------------------------------------------------
" {{{1
" Add path for windows
@ajroetker
ajroetker / gist:ea494d8518a93fa31728
Created June 11, 2014 19:58
bounce_service from installer
# 1. Name of service .
bounce_service() {
prepare_platform
# If all three of these are true it is using upstart, so we need to grep the results of service rather than trusting the return code, which will probably just be 0 in all cases.
if ([ -h /etc/init.d/${1?} ] && [ $(readlink -f /etc/init.d/${1?}) = "/lib/init/upstart-job" ]) || [ -f /etc/init/${1?}.conf ]; then
if (service "${1?}" status | ${PLATFORM_EGREP?} -q "stop/waiting") > /dev/null 2>&1; then
run_suppress_output "service ${1?} start | ${PLATFORM_EGREP?} -q 'start/running'"
else
run_suppress_output "service ${1?} restart | ${PLATFORM_EGREP?} -q 'start/running'"
@ajroetker
ajroetker / error
Created December 8, 2014 21:14
error
#<RuntimeError: PuppetAcceptance::DSL::Helpers.with_puppet_running_on failed (check backtrace for location) because: Host 'debian-7-amd64.vm' exited with 1 running:
env PATH="/usr/bin:/opt/puppet-git-repos/hiera/bin:${PATH}" RUBYLIB="/opt/puppet-git-repos/hiera/lib:/opt/puppet-git-repos/hiera-puppet/lib:${RUBYLIB}" puppet agent --test
Last 10 lines of output were:
Server hostname 'debian-7-amd64.vm' did not match server certificate; expected one of debian-7-amd64.hsd1.or.comcast.net, DNS:debian-7-amd64, DNS:debian-7-amd64.hsd1.or.comcast.net, DNS:puppet
Info: Retrieving plugin
Error: /File[/var/lib/puppet/lib]: Failed to generate additional resources using 'eval_generate': Server hostname 'debian-7-amd64.vm' did not match server certificate; expected one of debian-7-amd64.hsd1.or.comcast.net, DNS:debian-7-amd64, DNS:debian-7-amd64.hsd1.or.comcast.net, DNS:puppet
Error: /File[/var/lib/puppet/lib]: Could not evaluate: Could not retrieve file metadata for puppet://debian-7-amd64.vm/plugins: Server hostnam
@ajroetker
ajroetker / blah
Created January 29, 2015 19:15
resources
SELECT paged_results.* FROM (SELECT reports.certname, reports.configuration_version, reports.containment_path, reports.end_time, reports.environment, reports.event_status, reports.file, reports.hash, reports.line, reports.message, reports.new_value, reports.old_value, reports.property, reports.puppet_version, reports.receive_time, reports.report_format, reports.resource_title, reports.resource_type, reports.start_time, reports.status, reports.timestamp, reports.transaction_uuid FROM ( select reports.hash,
reports.certname,
reports.puppet_version,
reports.report_format,
reports.configuration_version,
reports.start_time,
reports.end_time,
reports.receive_time,
reports.transaction_uuid,
environments.name as environment,
@ajroetker
ajroetker / bootstrap.sh
Last active August 29, 2015 14:18
PuppetDB smoke-testing bootstraping script
#! /usr/bin/env bash
cat <<PUPPETDBCONF > /etc/puppet/puppetdb.conf
[main]
server=$(facter fqdn)
port=8081
PUPPETDBCONF
cat <<ROUTESYAML > /etc/puppet/routes.yaml
---
q_all_in_one_install=y
q_enable_future_parser=y
q_upgrade_with_unknown_disk_space=y
q_puppet_symlinks_install=y
q_backup_and_purge_old_configuration=n
q_backup_and_purge_old_database_directory=n
q_database_host=monolithic.vm
q_database_install=y
q_database_port=5432
q_database_root_password=0DLykKg1Leqcrwl2cNTp
@ajroetker
ajroetker / pe_migrate.clj
Created July 7, 2015 02:37
Example PE migrations
(def pe-migrations
{35 {:pre bring-up-historical-resources-tables
:post add-key-constraints-for-those-tables}
36 {:pre tear-down-contraints-so-foss-can-upgrade-normally}
40 {:post reinstantiate-those-constraints})
usermod: user puppetdb is currently used by process 15306
Updating : puppetdb-3.0.0-0.1SNAPSHOT.2015.07.09T1006.el7.noarch 1/2
Migrating configuration files /tmp/puppetdb-orig-configs/jetty.ini /tmp/puppetdb-orig-configs/database.ini /tmp/puppetdb-orig-configs/config.ini to /etc/puppetlabs/puppetdb/conf.d
Replacing: /etc/puppetlabs/puppetdb/conf.d/jetty.ini with /tmp/puppetdb-orig-configs/jetty.ini
Replacing: /etc/puppetlabs/puppetdb/conf.d/database.ini with /tmp/puppetdb-orig-configs/database.ini
Replacing: /etc/puppetlabs/puppetdb/conf.d/config.ini with /tmp/puppetdb-orig-configs/config.ini
Checking to see if we need to update default settings
Backing up /etc/puppetlabs/puppetdb/conf.d/config.ini to /etc/puppetlabs/puppetdb/conf.d/config.ini.bak.1436463075 before making changes
Updated setting vardir in /etc/puppetlabs/puppetdb/conf.d/config.ini.
Replacing: /opt/puppetlabs/server/data/puppetdb with /var/lib/puppetdb
@ajroetker
ajroetker / merge-conflict.rb
Created July 15, 2015 20:06
WHAT DO IT DO?!!?!?
<<<<<<< HEAD
def get_package_version(host, version = nil)
version = PuppetDBExtensions.config[:package_build_version].to_s
# version can look like:
# 3.0.0
# 3.0.0.SNAPSHOT.2015.07.08T0945
# Rewrite version if its a SNAPSHOT in rc form
if version.include?("SNAPSHOT")
@ajroetker
ajroetker / state_overview_single_query.sql
Last active August 29, 2015 14:25 — forked from wkalt/gist:856c87c322f1ef75d43c
single query for state-overview example from Wyatt, touched up a little
SELECT (CASE WHEN certnames.latest_report_id IS NULL THEN 'unreported'
/* NOW() would instead be a parameterized value */
WHEN reports.end_time < NOW() - interval '1 hour' THEN 'unresponsive'
WHEN reports.noop = TRUE THEN 'noop'
ELSE resport_statuses.status
END) AS latest_report_status,
certnames.certname
FROM certnames
LEFT JOIN reports ON certnames.latest_report_id = reports.id
LEFT JOIN report_statuses ON reports.status_id = report_statuses.id;