Skip to content

Instantly share code, notes, and snippets.

View chadh's full-sized avatar

Chad Huneycutt chadh

View GitHub Profile
#!/bin/bash
export PATH="/sbin:/bin:/usr/sbin:/usr/bin"
readonly APTOPTS='-o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold"'
function install_puppet() {
pushd /root > /dev/null
wget http://apt.puppetlabs.com/puppetlabs-release-wheezy.deb
dpkg -i puppetlabs-release-wheezy.deb
apt-get update
@chadh
chadh / gist:2fd3f4d3222fff2a5fea
Last active January 28, 2016 18:45
puppet provider for pulp rpm repos.
require 'puppet/type'
require 'uri'
require 'puppet/parameter/boolean'
Puppet::Type.newtype(:pulp_repo) do
desc "Type to manage Pulp repos"
ensurable
newparam(:id, :namevar => true) do
desc "Id of the repo"
@chadh
chadh / rpm.rb
Created January 28, 2016 18:46
Puppet provider for pulp rpm repo
require 'json'
Puppet::Type::type(:pulp_repo).provide(:rpm) do
commands :pulp_admin => 'pulp-admin'
commands :mongoexport => 'mongoexport'
# magically define all getter methods (Thanks, Luke!)
mk_resource_methods
# query the pulp_database and merge some fields from multiple tables
@chadh
chadh / foo.pp
Last active July 11, 2018 02:10
reduce bug
$t = @(EOF)
<%=
# remove dynamic facts and class params
$facts.reduce( {} ) | $memo, $entry | {
if $entry[0] !~ /^(server.*|facts|system_uptime|uptime.*|rubysitedir|_timestamp|memoryfree.*|swapfree.*|.*temperature.*|hpraid.*|hparray.*power_on_hours|hparray.*estimated_life_remaining_based_on_workload_to_date|title|name|caller_module_name|module_name|lib|path|packages|version|mysql_instances|ilo_facterfile_age|ilo_ipv6_.*|sshfp_.*|environment|clientnoop)$/ {
$memo + { $entry[0] => $entry[1] }
}
}
%>
EOF
---
version: 5
defaults:
datadir: data
data_hash: yaml_data
default_hierarchy:
- name: 'OS-specific Module Data'
path: "%{facts.os.family}.yaml"
- name: 'Common Module Data'
path: 'common.yaml'
---
version: 5
defaults:
datadir: hiera
lookup_key: eyaml_lookup_key
options:
pkcs7_private_key: '/etc/puppetlabs/puppet/eyaml/private_key.pkcs7.pem'
pkcs7_public_key: '/etc/puppetlabs/puppet/eyaml/public_key.pkcs7.pem'
hierarchy:
@chadh
chadh / get_spec.rb
Created December 21, 2018 17:53
function test
require 'spec_helper'
require 'json'
describe 'dcm::get' do
let(:uri) { 'https://baz.bar.org/api/v2/x/y?host=foo.bar.org' }
let(:response_string) { '{"count":1,"next":null,"previous":null,"results":[{"id":2061,"dataset":"foo","port":3314}]}' }
let(:response) { JSON.parse(response_string) }
let(:result) { 'foo' }
module Role
def self.add_facts
add_role
add_subrole
add_num
fqdn = Facter.value(:fqdn)
if fqdn =~ /^\w+\.dev\.mycorp\.com/
add_fact(:subproject, 'none')
add_fact(:project, 'rsglab')
require 'digest/md5'
require 'fileutils'
require 'net/http'
require 'uri'
require 'timeout'
require 'json'
# Retrieves info from DCM
Puppet::Functions.create_function(:'dcm::cached_request') do
# Retrieves info from http endpoint and caches response
@chadh
chadh / bolt_plugin.json
Created October 9, 2019 04:16
bolt dcm inventory plugin
{
"config": {
"mirror": {
"type": "String"
}
}
}