Skip to content

Instantly share code, notes, and snippets.

View discreet's full-sized avatar

Chris Pisano discreet

  • Morning Consult
  • Washington D.C.
View GitHub Profile
@discreet
discreet / serverDel.rb
Created September 29, 2014 14:34
Remove servers from Spacewalk
#!/usr/bin/env ruby
require 'xmlrpc/client'
require 'net/https'
require 'openssl'
#The following variables can take variables for puppet
@SATELLITE_URL = "serverurl/rpc/api"
@SATELLITE_LOGIN = "username"
@SATELLITE_PASSWORD = "password"
@discreet
discreet / rhelkey.rb
Created September 29, 2014 14:33
Spacewalk Registration Key
# facter rhelkey
#
# This fact will determine which patching group should be applied
# to the server when added to satellite so the need to manually
# add servers to groups will be eliminated.
Facter.add('rhelkey') do
setcode do
myenv = Facter.value('hostname').scan(/(^\D+\d)/).to_s
odd_even = Facter.value('hostname').scan(/^\D+\d\D+(\d+)/).to_s
@discreet
discreet / remove_udev.sh
Created September 29, 2014 14:32
Remove udev rules
#!bin/bash
#
# chkconfig: 35 20 30
# description: A problem exists when cloining a virtual machine
# that is currently up when using vmware. The problem
# this script solves is to remove the udev rule for
# networking.
# source function library
. /etc/rc.d/init.d/functions
@discreet
discreet / Overriding Smart-Class Parameters
Created July 15, 2014 01:23
Smart-Class Parameters in Foreman
Smart-class parameters are declared in your Puppet manifests. You will see them at the top of the manifest within (). They will be in the form of $variable = array/string/boolean/yaml/json/integer,. Arrays will be within [] with each object within either '' or "" depending on how they are to be interpreted. Strings will be within "" or '' depending on how they are to be interpreted.
Examples:
( $packages = ['package1', 'package2', 'package3'],
$ensure = 'running'
$enable = true
$path = "${libpath}/nagios",)
These are automatically imported into Foreman as Smart-Class parameters. Whatever value is set in the manifest (a value can be null) is the default value given to the parameter in Foreman. When a parameter requires a change in value (an override) you need to go to the Smart-Class parameter tab of either the class, host group or host. You will see a list of all the parameters available and which class they belong to. Simply click the override button for the parameter you wish to alter
@discreet
discreet / vmware-tools_service
Created July 8, 2014 12:51
vmware-tools as a service centos 6
cp /etc/vmware-tools/services.sh /etc/init.d/vmware-tools
vim /etc/init.d/vmware-tools
Paste the following just below the line ##VMWARE_INIT_INFO## and save:
chkconfig: 235 03 99
chkconfig --add vmware-tools
chkconfig vmware-tools on
@discreet
discreet / NSClient++_Version
Created June 30, 2014 00:03
NSClient++ Version
#NSClient++ Version
Facter.add("NSClient_Version") do
confine :osfamily => "Windows"
setcode do
NSClient_Version = Facter::Util::Resolution.exec("command to pull version")
#only use the below if and while in the case of normalizing version numbers
#the below code is assuming symantec versioning is being used (ex. 3.5.1)
#if NSClient_Version.length < 5
@discreet
discreet / NagiosCheck_Disk
Created June 30, 2014 00:02
Puppet Fact for Nagios Check_Disk
#Disks to check for Nagios alerting
Facter.add("Check_Disks") do
confine :osfamily => "RedHat"
setcode do
Check_Disks = Facter::Util::Resolution.exec("cat /etc/nagios/check_disk.cfg | cut -c 9-19")
end
end
@discreet
discreet / NRPE_Version
Created May 15, 2014 12:28
This will pull the NRPE version from RHEL/CentOS Servers. You may need to replace "nrpe" with "nagios-nrpe" depending on your install.
#This will pull the package version of the NRPE client
Facter.add("NRPE_Version") do
confine :osfamily => "RedHat"
setcode do
NRPE_Version = `/bin/rpm -q --queryformat "%{VERSION}" nrpe`
NRPE_Version
end
end
@discreet
discreet / Domain_Access
Last active August 29, 2015 14:01
This fact will pull a list of domain users and groups who have access
#This fact will pull securiy groups and users who have access if you are using PBIS.
Facter.add("Domain_Access") do
confine :osfamily => "RedHat"
setcode do
if File.directory? "/opt/likewise"
Domain_Access = `/opt/likewise/bin/lwconfig --detail RequireMembershipOf | grep '"' | sed -e 's/^"//' -e 's/"$//' | awk -F'\\' '{print $3}'`
$Access = split($Domain_Access, ' ')
Domain_Access
end
@discreet
discreet / Drive Path NRPE
Last active August 29, 2015 14:01
Drive Path for NRPE
#!/bin/bash
#This script pulls the drive path and sets the check command for NRPE. It is outputted to a file that is included int he nrpe.cfg file.
rm -f check_disk.cfg 2> /dev/null;
df -H | grep "/dev" | awk {'print $1'}> out.txt
sed -i "s|tmpfs|/dev/shm|g" out.txt;
no="0"
while read line
do
no=$[$no+1]