Skip to content

Instantly share code, notes, and snippets.

View smbambling's full-sized avatar

Steven Bambling smbambling

View GitHub Profile
@smbambling
smbambling / available_ips.sh
Created February 5, 2016 13:59
Find available IP addresses using DNS and DIG ( -x axfr )
#!/usr/bin/env bash
# Find available IP addresses from by using dig -x axfr
usage() {
cat <<-EOF
usage: ${0} <network>
example: ${0} 10.1.10
EOF
}
@smbambling
smbambling / change_user_uid_gid.sh
Created February 11, 2016 12:48
Change User/Primary Group UID and GID
#!/usr/bin/env bash
usage() {
cat <<-EOF
usage: ${0} -l <login> -u <new uid> [-g <new gid>]
-h this help screen
-l login account login account name
-p primary group for account login
-u uid new UID to assign to account
-g new GID to assign to account group
@smbambling
smbambling / cmd_exists.sh
Created February 11, 2016 13:43
Check if a command called in a script exists.
# Reference Commands
cmd_list='usermod groupmod find chgrp getent id awk tr wc'
# Function to check if referenced command exists
cmd_exists() {
if [ $# -eq 0 ]; then
echo 'WARNING: No command argument was passed to verify exists'
fi
cmd=${1}
#!/usr/bin/env bash
node_fqdn=$(hostname -f)
prettyjson='python -m json.tool'
# Generate Token for code-deployer RBAC user (5y Lifetime)
token_file_loc='/root/.puppetlabs/code-deployer_token'
# Trigger Code-Manager Deployment of ALL environments
function trigger_run() {
@smbambling
smbambling / Git to Stash Mirror
Created March 18, 2016 12:43 — forked from skl/Git to Stash Mirror
Mirror public git repositories to an Atlassian Stash instance
#!/bin/bash
set -e
function stash_create_repo()
{
local username="$1"
local password="$2"
local hostname="$3"
local port="$4"
local project="$5"
@smbambling
smbambling / pe_filesync_client_status.rb
Last active May 17, 2016 15:35
Verify that Puppet Enterprise FileSync clients have updated environments and are on the same GIT commit hash as the Master of Masters
#!/opt/puppetlabs/puppet/bin/ruby
require "rest-client"
require "json"
require "rugged"
require 'optparse'
options = { :verbose => nil, :pretty => nil }
parser = OptionParser.new do|opts|
opts.banner = "Usage: #{$0} [options]"
#!/usr/bin/env python
# This git-hook triggers the Code-Manager per branch and checks for status to be returned
# Requirements: This requires the python request module ( sudo yum install python-requests )
import requests
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
import json
import sys
#!/usr/bin/env python
# Requirements:
# - request module ( sudo yum install python-requests )
# - slacker ( sudo pip install slacker)
# * https://github.com/os/slacker
# Suppress Deprecation Warning....because...python 2.6 is old
import warnings
postgresql::server::role { 'marmot':
password_hash => 'foobar',
}
Error: /Stage[main]/Profile::Postgresql/Postgresql::Server::Role[marmot]/Postgresql_psql[CREATE ROLE "marmot" ENCRYPTED PASSWORD 'foobar' LOGIN NOCREATEROLE NOCREATEDB NOSUPERUSER CONNECTION LIMIT -1]: Could not evaluate: undefined method `exitcode' for [" 0\n\n", #<Process::Status: pid 8127 exit 0>]:Array
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/vendor/rgen/lib/rgen/array_extensions.rb:25:in `method_missing'
/vagrant/puppet/environments/dev/modules/postgresql/lib/puppet/type/postgresql_psql.rb:41:in `matches'
/vagrant/puppet/environments/dev/modules/postgresql/lib/puppet/type/postgresql_psql.rb:92:in `should_run_sql'
/vagrant/puppet/environments/dev/modules/postgresql/lib/puppet/type/postgresql_psql.rb:16:in `retrieve'
/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/puppet/type.rb:1072:in `block in retrieve'
## Snippet from puppet agent run
Debug: Prefetching puppetserver_gem resources for package
Debug: Executing: '/opt/puppetlabs/bin/puppetserver gem list --local'
Debug: Executing: '/opt/puppetlabs/bin/puppetserver gem list --local ^deep_merge$'
Debug: Executing: '/opt/puppetlabs/bin/puppetserver gem install --no-rdoc --no-ri deep_merge'
Error: Could not install: ERROR: Could not find a valid gem 'deep_merge' (>= 0) in any repository
Error: /Stage[main]/Hiera::Deep_merge/Hiera::Install[deep_merge]/Package[puppetserver deep_merge]/ensure: change from absent to present failed: Could not install: ERROR: Could not find a valid gem 'deep_merge' (>= 0) in any repository