Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@dcarley
dcarley / gist:1294929
Created October 18, 2011 08:38
Puppet config_version requires shebang
dan@dan-MacPro:~$ echo '/bin/date' > /tmp/version
dan@dan-MacPro:~$ chmod +x /tmp/version
dan@dan-MacPro:~$ /tmp/version
Tue Oct 18 09:22:49 BST 2011
dan@dan-MacPro:~$ puppet apply -v --config_version /tmp/version -e 'notice("foobar")'
Unable to set config_version: Execution of '/tmp/version' returned 1: on node dan-macpro.xxx.com
dan@dan-MacPro:~$ echo -e '#!/bin/bash\n/bin/date' > /tmp/version
dan@dan-MacPro:~$ puppet apply -v --config_version /tmp/version -e 'notice("foobar")'
@dcarley
dcarley / gist:1303492
Created October 21, 2011 10:04
Oh, Ruby.
irb(main):001:0> def foo(one="one", two="two", three="three")
irb(main):002:1> "one: #{one}, two: #{two}, three: #{three}"
irb(main):003:1> end
=> nil
irb(main):004:0> foo()
=> "one: one, two: two, three: three"
irb(main):005:0> foo(three=3)
=> "one: 3, two: two, three: three"
@dcarley
dcarley / gist:1303820
Created October 21, 2011 13:12
IPtables negating ports in a rule
[root@puppet ~]# cat /etc/redhat-release
CentOS release 5.7 (Final)
[root@puppet ~]# service iptables stop
Flushing firewall rules: [ OK ]
Setting chains to policy ACCEPT: filter [ OK ]
Unloading iptables modules: [ OK ]
[root@puppet ~]# iptables -t filter -A INPUT -p tcp -m tcp -m multiport --dports 80,443 -m comment --comment "foo" -j ACCEPT
@dcarley
dcarley / gist:1315760
Created October 26, 2011 08:13
Hack for puppetlabs-firewall util loading related to bug #4248
diff --git a/lib/puppet/provider/firewall/iptables.rb b/lib/puppet/provider/firewall/iptables.rb
index d4c7faa..0e8ec79 100644
--- a/lib/puppet/provider/firewall/iptables.rb
+++ b/lib/puppet/provider/firewall/iptables.rb
@@ -1,4 +1,4 @@
-require 'puppet/provider/firewall'
+require File.expand_path('../firewall', File.dirname(__FILE__))
require 'digest/md5'
Puppet::Type.type(:firewall).provide :iptables, :parent => Puppet::Provider::Firewall do
@dcarley
dcarley / gist:1334240
Created November 2, 2011 17:10
rpmbuild --showrc with and without redhat-rpm-config
--- with 2011-11-02 18:44:32.000000000 +0000
+++ without-redhat 2011-11-02 18:45:02.000000000 +0000
@@ -9,7 +9,7 @@
compatible os's : linux
RPMRC VALUES:
-macrofiles : /usr/lib/rpm/macros:/usr/lib/rpm/ia32e-linux/macros:/usr/lib/rpm/redhat/macros:/etc/rpm/macros.*:/etc/rpm/macros:/etc/rpm/ia32e-linux/macros:~/.rpmmacros
+macrofiles : /usr/lib/rpm/macros:/usr/lib/rpm/ia32e-linux/macros:/etc/rpm/macros.*:/etc/rpm/macros:/etc/rpm/ia32e-linux/macros:~/.rpmmacros
optflags : -O2 -g -m64 -mtune=generic
@dcarley
dcarley / gist:1363634
Created November 14, 2011 09:52
puppetlabs-firewall duplicate resources
[root@fw0 ~]# iptables -F
[root@fw0 ~]# cat test.pp
firewall {
"500 http":
dport => 80,
action => "accept";
"500 https":
dport => 443,
action => "accept";
@dcarley
dcarley / unpack.py
Created November 14, 2011 10:19
Ruby silently unpacks vars to nil, then interpolates to "".
dan@dan-MacPro:~$ python unpack.py
foo: foo
bar: bar
dan@dan-MacPro:~$ ruby unpack.rb
foo: foo
bar:
@dcarley
dcarley / gist:1370219
Created November 16, 2011 14:47
spark all up in your mtr
0 	xxx.xxx.xxx.xxx       	▁▁▁▁▁█▁▁▁▂▁▂▁▁▁▁▁▁▁▁▁▂▁▁▁▁▁▁▁▁
1 	xxx.xxx.xxx.xxx       	▆▆▅▅▆██▅▅▆▅▅▄▅▆▅▆▆▅▅▅▅▅▅▆▅▅▅▅▆
2 	xxx.xxx.xxx.xxx       	▇████▇█▇▇█▇█▇█▇██▇▇▇▇▇██▇▇▇▇██
3 	xxx.xxx.xxx.xxx       	▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂▂█▂▂▂▂▂▂▂
4 	xxx.xxx.xxx.xxx       	██████████████████████████████
5 	xxx.xxx.xxx.xxx       	▆▆█▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆▆
6 	xxx.xxx.xxx.xxx       	▆▇▇▆▆▆▇▇▆▆▆▆▇▇█▆▆▇▇▇▆▇▇▆▇▆▇▆▇▇
7 	62.172.57.233       	▅▅▅▅▅▅▅▅▅▅▅▅█▅▅▅▅▆▅▅▅▅▅▅▅▅▅▅▅▅
8 62.6.198.137 ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▆▇█▁▁█▃
@dcarley
dcarley / str_to_i.rb
Created November 23, 2011 17:55
Ruby string/integer typing rage.
# The principle of moderate-to-infuriating surprise.
irb(main):001:0> "23".to_i
=> 23
irb(main):002:0> "23foobar".to_i
=> 23
irb(main):003:0> "foo23bar".to_i
=> 0
irb(main):004:0> "".to_i
=> 0
@dcarley
dcarley / anaconda.log
Created November 25, 2011 16:14
Kickstart firewall rules disappearing in CentOS 5.7
10:23:21 WARNING : not adding Base group
10:23:21 INFO : moving (1) to step postselection
10:23:21 INFO : selected kernel package for kernel
10:23:21 DEBUG : selecting kernel-devel
10:23:22 DEBUG : Checking for virtual provide or file-provide for authconfig.ia32e
10:23:22 DEBUG : no package matching authconfig.ia32e
10:23:23 DEBUG : Checking for virtual provide or file-provide for chkconfig.ia32e
10:23:23 DEBUG : no package matching chkconfig.ia32e
10:23:23 DEBUG : Checking for virtual provide or file-provide for mkinitrd.ia32e
10:23:23 DEBUG : no package matching mkinitrd.ia32e