Skip to content

Instantly share code, notes, and snippets.

View smbambling's full-sized avatar

Steven Bambling smbambling

View GitHub Profile
@smbambling
smbambling / gist:a4b26986d46cd7bac1e5
Created March 27, 2015 11:08
Sort files by human readable size
du -sk * | sort -rn | awk '{print $2}' | xargs -ia du -hs "a"
@smbambling
smbambling / exists.rb
Last active August 29, 2015 14:25 — forked from j4m3s/exists.rb
#
# exists.rb
#
# James Fellows 8/8/12: cloned from git://gist.github.com/1160472.git then
# modified to resolve puppet:/// paths
#
# Copyright 2011 Puppet Labs Inc.
# Copyright 2011 Krzysztof Wilczynski
#
# Licensed under the Apache License, Version 2.0 (the "License");
@smbambling
smbambling / change-idrac-password.rst
Last active October 27, 2023 08:56 — forked from andrewspiers/change-idrac-password.rst
Change iDRAC password using OpenManage

How to change an iDRAC password using Racadm for a Dell R720 and similar servers.

TLDR:

#  racadm config -g cfgUserAdmin -o cfgUserAdminPassword -i 2 <newpassword>

This guide assumes you have OpenManage installed. It was tested with the following version of OpenManage:

@smbambling
smbambling / fetch_resource_types.rb
Last active November 2, 2015 18:08
Puppet Function to return list (array) of resource types (classes) from the Puppet API from a supplied regex
require "net/http"
require "net/https"
require "uri"
require "json"
require "socket"
require "puppet"
module Puppet::Parser::Functions
newfunction(:fetch_resource_types, :type => :rvalue) do |args|
@smbambling
smbambling / create_groups.pp
Last active October 16, 2016 07:44
Example Puppet Class to create PE Groups automatically from Role Classes
class node_manager::create_groups {
$environments = split(fetch_environments(), ',')
$environments.each | $env | {
$classes = split(fetch_resource_types("production", "^role::"), ',')
$classes.each | $class | {
require "net/http"
require "net/https"
require "uri"
require "json"
require "socket"
require "puppet"
module Puppet::Parser::Functions
newfunction(:fetch_environments, :type => :rvalue) do |args|
@smbambling
smbambling / puppetserver_irb.rb
Last active November 5, 2015 12:36
Snippet used with puppetserver irb to get info
require 'irb/completion'
require 'puppet'
Puppet.settings.preferred_run_mode = :agent # or whatever section you need
Puppet.settings.initialize_global_settings(["--config=/the/config/file"])
Puppet.settings.initialize_app_defaults(
Puppet::Settings.app_defaults_for_run_mode(Puppet.run_mode)
)
Puppet.push_context(Puppet.base_context(Puppet.settings))
@smbambling
smbambling / pe_classifier_group.pp
Last active November 11, 2015 14:11
Puppet Class to auto create PE Classifier Environment groups based on PuppetServer environments
## This class requires env_utils, node_manager and stdlib
# Array of PE Environment Groups excluding the default 'Agent-specified environment' group
$pe_environment_groups = delete(node_groups().filter |$key, $val| { $val["environment_trumps"] == true }.map |$key, $val| { $val["name"] }, 'Agent-specified environment')
# Obtain PuppetServer environments and munge to look like PE Classifier environment Groups
$puppet_environments = regsubst(capitalize(environments()), '$', ' environment', 'G')
# Array of PE Environment Groups that should be removed based
# the PuppetServer environment no longer exists
$managed_groups = hiera_array(managed_groups)
notice ( $managed_groups )
$managed_groups.each | $group | {
$g = hiera_hash(accounts::groups).filter | $key, $val | { $key == $group }
create_resources('group', $g)
}
$managed_users = hiera_array(managed_users)
@smbambling
smbambling / .vimrc
Created November 24, 2015 19:33
Bambling .vimrc
" Use Vim settings, rather then Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible " be iMproved, required
filetype off " required
" ================ General Config ====================
set number "Line numbers are good
set backspace=indent,eol,start "Allow backspace in insert mode
set history=1000 "Store lots of :cmdline history