Skip to content

Instantly share code, notes, and snippets.

Avatar

Nick Lewis nicklewis

  • Puppet
  • Portland, OR
View GitHub Profile
View nodes.txt
foo.example.com
bar.example.com
baz.example.com
View Dockerfile
FROM ubuntu:16.04
ARG vcs_ref
ARG build_date
ARG version="2019.0.1.8"
ENV PE_VERSION="2019.0"
ENV PEPER_VERSION="2019.0.2.1"
ENV JAVA_VERSION="2019.0.1.8.0.191"
ENV PUPPET_AGENT_VERSION="6.0.4"
ENV ORCHESTRATION_SERVICES_VERSION="$version"
@nicklewis
nicklewis / package_versions.pp
Last active Sep 6, 2018
A Bolt plan to show aggregated package versions, using only built-in content.
View package_versions.pp
# Example:
# $ bolt plan run package_versions nodes=foo.example.com,bar.example.com,baz.example.com package=openssl
# Starting: plan package_versions
# Finished: plan package_versions in 7.62 sec
# {
# "1:1.0.2k-12.el7": [
# "foo.example.com",
# "bar.example.com"
# ],
# "1:1.0.2k-8.el7": [
@nicklewis
nicklewis / init.pp
Created Mar 28, 2018
recur module (PUP-8610)
View init.pp
plan recur() {
recur::recurf(0, 0)
}
@nicklewis
nicklewis / Dockerfile
Last active Nov 9, 2017
dockerfile for bolt
View Dockerfile
FROM alpine:latest
RUN apk --update add ruby ruby-json ruby-io-console openssh gcc ruby-dev make musl-dev libffi-dev curl tar
RUN gem install bolt --no-ri --no-rdoc
WORKDIR /var/lib/bolt
RUN mkdir package service
RUN curl -s https://forge.puppet.com/v3/files/puppetlabs-package-0.1.5.tar.gz | tar zxf - --strip-components=1 -C package --wildcards '*/tasks'
RUN curl -s https://forge.puppet.com/v3/files/puppetlabs-service-0.1.3.tar.gz | tar zxf - --strip-components=1 -C service --wildcards '*/tasks'
View query.sql
WITH inactive_nodes
AS (SELECT certname
FROM certnames
WHERE ( deactivated IS NOT NULL
OR expired IS NOT NULL ))
SELECT reports.certname AS certname,
Encode(reports.hash :: bytea, 'hex') AS hash,
reports.end_time AS end_time,
reports.noop AS noop,
report_statuses.status AS status,
@nicklewis
nicklewis / jira_epic_graph.rb
Created Jan 4, 2017
Generate a dot graph of the blocking relationships between all the tickets in a set of epics
View jira_epic_graph.rb
#!/usr/bin/env ruby
require 'net/http'
require 'json'
raise "Specify at least one epic" if ARGV.empty?
def make_request(client, url)
request = Net::HTTP::Get.new(url)
request.basic_auth ENV['JIRA_USERNAME'], ENV['JIRA_PASSWORD']
View gist:d6a1988c0e651111b7dc
ei!
tsathoggua
r'lyeh
in his house at r'lyeh dead cthulhu waits dreaming.
ph'nglui mglw'nafh cthulhu r'lyeh wgah'nagl fhtagn.
yuggoth
yoyodyne
cthulhu fhtagn!
ia! ia!
yogsothoth
@nicklewis
nicklewis / gist:6515299
Created Sep 10, 2013
postgres relation sizes
View gist:6515299
SELECT nspname || '.' || relname AS "relation",
pg_size_pretty(pg_relation_size(C.oid)) AS "size"
FROM pg_class C
LEFT JOIN pg_namespace N ON (N.oid = C.relnamespace)
WHERE nspname NOT IN ('pg_catalog', 'information_schema')
ORDER BY pg_relation_size(C.oid) DESC
LIMIT 20;
@nicklewis
nicklewis / gist:6384464
Created Aug 29, 2013
Hypothetical PuppetDB ternary operator
View gist:6384464
["and",
["=", "type", "Package"],
["?:",
["in", "certname",
["extract", "certname",
["select-facts",
["and", ["=", "name", "kernelrelease"], ["=", "value", "3.2.0-3-amd64"]]]]]
["=", "title", "linux-headers-3.2.0-3-amd64"],
["=", "title", "linux-headers-3.2.0-2-amd64"]]]