Skip to content

Instantly share code, notes, and snippets.

Dan Carley dcarley

Block or report user

Report or block dcarley

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@dcarley
dcarley / gist:1294929
Created Oct 18, 2011
Puppet config_version requires shebang
View gist:1294929
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")'
View gist:1303492
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 Oct 21, 2011
IPtables negating ports in a rule
View gist:1303820
[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 Oct 26, 2011
Hack for puppetlabs-firewall util loading related to bug #4248
View gist:1315760
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 Nov 2, 2011
rpmbuild --showrc with and without redhat-rpm-config
View gist:1334240
--- 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 Nov 14, 2011
puppetlabs-firewall duplicate resources
View gist:1363634
[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 Nov 14, 2011
Ruby silently unpacks vars to nil, then interpolates to "".
View unpack.py
dan@dan-MacPro:~$ python unpack.py
foo: foo
bar: bar
dan@dan-MacPro:~$ ruby unpack.rb
foo: foo
bar:
@dcarley
dcarley / gist:1370219
Created Nov 16, 2011
spark all up in your mtr
View gist:1370219
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 Nov 23, 2011
Ruby string/integer typing rage.
View str_to_i.rb
# 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 Nov 25, 2011
Kickstart firewall rules disappearing in CentOS 5.7
View anaconda.log
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
You can’t perform that action at this time.