Skip to content

Instantly share code, notes, and snippets.

View stefanlasiewski's full-sized avatar

Stefan Lasiewski stefanlasiewski

  • LBNL (Lawrence Berkeley National Laboratory)
  • Berkeley, CA
View GitHub Profile
@stefanlasiewski
stefanlasiewski / validateyaml2.sh
Created July 2, 2014 23:55
Parse all YAML files in my Hiera datadir
find /etc/puppet/hieradata/ -name "*.yaml" | while read file; do echo "file=$file"; ruby -e "require 'yaml'; YAML.load_file('$file')"; done
### Use case
[root@puppet3 hieradata]# find /etc/puppet/hieradata/ -name "*.yaml" | while read file; do echo "file=$file"; ruby -e "require 'yaml'; YAML.load_file('$file')"; done
file=/etc/puppet/hieradata/common.yaml
file=/etc/puppet/hieradata/virtual/vmware.yaml
file=/etc/puppet/hieradata/osfamily/Debian.yaml
file=/etc/puppet/hieradata/osfamily/RedHat.yaml
/usr/lib/ruby/1.8/yaml.rb:133:in `load': syntax error on line 4, col 26: ` vmwaretools::working_dir: /opt/vmware' (ArgumentError)
from /usr/lib/ruby/1.8/yaml.rb:133:in `load'
@stefanlasiewski
stefanlasiewski / gist:6d4db8075ffd07444709
Last active August 29, 2015 14:03
Print Hiera arrays in Puppet
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
# Compiled source #
###################
*.com
*.class
*.dll
*.exe
*.o
*.so
# Packages #
@stefanlasiewski
stefanlasiewski / gist:9c709251c5569c928f1b
Last active August 29, 2015 14:22
FPM on CentOS 6 fails with ruby-devel 1.8.6 (SCL repository is not activated)
[root@buildhost ~]# yum install ruby-devel gcc --quiet -y
[root@buildhost ~]# gem install fpm
Building native extensions. This could take a while...
Successfully installed json-1.8.3
Successfully installed cabin-0.7.1
Successfully installed backports-3.6.4
Successfully installed arr-pm-0.0.10
Successfully installed childprocess-0.5.6
Successfully installed fpm-1.3.3
6 gems installed
@stefanlasiewski
stefanlasiewski / checkIfRunning.sh
Last active September 18, 2015 18:32
This example script will check to make sure that an earlier instance isn't already running before executing again. Useful for cronjobs that run every 5 minutes, and you don't want a backlog of processes piling up because of a slowness issue
#!/bin/sh
# This example script will check to make sure that an earlier instance isn't already running before executing again.
# Useful for cronjobs that run every 5 minutes, and you don't want a backlog of processes piling up because of a slowness issue
# Borrowed from http://stackoverflow.com/questions/1440967/how-do-i-make-sure-my-bash-script-isnt-already-running
# Modified to work on FreeBSD as well as Linux
# Example usage:
#$ ./checkIfRunning.sh
#Sleeping for 600 seconds.
@stefanlasiewski
stefanlasiewski / macports-selfupdate.sh
Created May 31, 2013 22:41
Update MacPorts base to latest released version using 'selfupdate', Then upgrade all outdated ports (upgrade outdated), and uninstall old version of each port (-u)
#!/bin/sh
# Update MacPorts base to latest released version using 'selfupdate'
# Then upgrade all outdated ports (upgrade outdated), and uninstall old version of each port (-u)
# http://guide.macports.org/#using.common-tasks.updating
# http://guide.macports.org/#using.port.upgrade
# Can be called from Cron
@stefanlasiewski
stefanlasiewski / gist:5688376
Created May 31, 2013 22:28
Shell script scripts to get hostnames from IPs and VIPs listed in ifconfig
#!/bin/sh
# Shell script scripts to get hostnames from IPs and VIPs listed in ifconfig
# -------------------------------------------------------------------------
# Copyright (c) 2005 nixCraft project <http://cyberciti.biz/fb/>
# This script is licensed under GNU GPL version 2.0 or above
# -------------------------------------------------------------------------
# This script is part of nixCraft shell script collection (NSSC)
# Visit http://bash.cyberciti.biz/ for more information.
# -------------------------------------------------------------------------
# Based off of http://bash.cyberciti.biz/misc-shell/read-local-ip-address/

Add the following chunk to your existing ISC dhcpd.conf file.

if exists user-class and ( option user-class = "iPXE" ) {
    filename "http://boot.smidsrod.lan/bootstrap.ipxe";
}
else {
    filename "undionly.kpxe";
}

(or see https://gist.github.com/4008017 for a more elaborate setup

@stefanlasiewski
stefanlasiewski / gist:be6776296e07e709e9d978d36c3681c5
Last active December 8, 2016 19:13
Ubuntu is noisy due to dpkg messages: apt-get -qq update && apt-get -qq upgrade && apt-get -qq install build-essential
$ docker run -it ubuntu
root@14d8108342b9:/# cat /etc/issue
Ubuntu 16.04.1 LTS \n \l
root@14d8108342b9:/# apt-get -qq update && apt-get -qq upgrade && apt-get -qq install build-essential
debconf: delaying package configuration, since apt-utils is not installed
(Reading database ... 7259 files and directories currently installed.)
Preparing to unpack .../libc6_2.23-0ubuntu5_amd64.deb ...
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76.)
debconf: falling back to frontend: Readline