Language: Ruby
Untitled Ruby (6-Apr @ 01:09)
Syntax Highlighted Code
- Óà‰NDƒÁ?‰>‰n ??Uÿj?‰F@H‰FH¸«ªªª‰V(÷áÑê‰VL‹G(UPÿW ‹N ‰F,‹W(j?QRÿW ‰F4‹F@‹O(j?PQÿW ‰F8??K?¸? j?Óà‰†??? ‹W(PRÿW ‹N,ƒÄ0…ɉF?tP‹N4…ÉtI‹N8…ÉtB…Àt>‹Ž??? W‹ÑÆF??Ñê???P???H?ȉ–˜? ‹T$,‰ŽŒ? ‹L$?‰V|‰Nxè1 ƒÄ?_^][áìÚ ?W‰G?èû? ƒÄ?¸üÿÿÿ_^][Ã_^]¸úÿÿÿ[Ã????????‹D$?3É;ÁVta‹p?;ñtZ9H tU9H$tP‰H?‰H?‰H?Ç@,? ‹V?‰N?‰V ‹V?;Ñ}?‰N?‹V?V÷Ú?ÒƒâGƒÂ*‰V?Ç@0? ‰N?èÑ6 Vè?? ƒÄ?3À^øþÿÿÿ^Ã??????????????????????????S‹\$?UV…ÛW?„“? ‹s?…ö?„ˆ? ‹l$?ƒý????{? …í?Œs? ‹C …À?„_? ƒ; u?‹C?…À?…O? ‹F?=š? u ƒý??…<? ‹K?…Éu?¡ðÚ ?_^‰C?]¸ûÿÿÿ[ËN?ƒø*‰?‰L$?‰n?ux‹N$‹FxÁá ??é x HÑøƒø?v?¸? Áà??È‹F`…Àt?ƒÉ ‹Á3Ò¿? ÇF?q ÷÷+Ê?ÏQVèà? ‹F`ƒÄ?…Àt?‹S0Áê?RVèÉ? ‹C0%ÿÿ PVèº? ƒÄ?ÇC0? ‹F?…Àt?SèÓ? ‹C?ƒÄ?…Àu3ÇF?ÿÿÿÿ_^]3À[ËC?…Àu?;l$???ƒý?t?‹
- Contribute a better translation
Plain Code
Óà‰NDƒÁ?‰>‰n ??Uÿj?‰F@H‰FH¸«ªªª‰V(÷áÑê‰VL‹G(UPÿW ‹N ‰F,‹W(j?QRÿW ‰F4‹F@‹O(j?PQÿW ‰F8??K?¸? j?Óà‰†??? ‹W(PRÿW ‹N,ƒÄ0…ɉF?tP‹N4…ÉtI‹N8…ÉtB…Àt>‹Ž??? W‹ÑÆF??Ñê???P???H?ȉ–˜? ‹T$,‰ŽŒ? ‹L$?‰V|‰Nxè1 ƒÄ?_^][áìÚ ?W‰G?èû? ƒÄ?¸üÿÿÿ_^][Ã_^]¸úÿÿÿ[Ã????????‹D$?3É;ÁVta‹p?;ñtZ9H tU9H$tP‰H?‰H?‰H?Ç@,? ‹V?‰N?‰V ‹V?;Ñ}?‰N?‹V?V÷Ú?ÒƒâGƒÂ*‰V?Ç@0? ‰N?èÑ6 Vè?? ƒÄ?3À^øþÿÿÿ^Ã??????????????????????????S‹\$?UV…ÛW?„“? ‹s?…ö?„ˆ? ‹l$?ƒý????{? …í?Œs? ‹C …À?„_? ƒ; u?‹C?…À?…O? ‹F?=š? u ƒý??…<? ‹K?…Éu?¡ðÚ ?_^‰C?]¸ûÿÿÿ[ËN?ƒø*‰?‰L$?‰n?ux‹N$‹FxÁá ??é x HÑøƒø?v?¸? Áà??È‹F`…Àt?ƒÉ ‹Á3Ò¿? ÇF?q ÷÷+Ê?ÏQVèà? ‹F`ƒÄ?…Àt?‹S0Áê?RVèÉ? ‹C0%ÿÿ PVèº? ƒÄ?ÇC0? ‹F?…Àt?SèÓ? ‹C?ƒÄ?…Àu3ÇF?ÿÿÿÿ_^]3À[ËC?…Àu?;l$???ƒý?t?‹
Contribute a better translation
Untitled Ruby (12-Jan @ 20:58)
Syntax Highlighted Code
- class MCollective::Application::Facts<MCollective::Application
- description "Reports on usage for a specific fact"
- # this will be available in configuration[:fact]
- [51 more lines...]
Plain Code
class MCollective::Application::Facts<MCollective::Application
description "Reports on usage for a specific fact"
# this will be available in configuration[:fact]
option :script,
:description => "Fact to report on",
:arguments => ["--fact FACT", "-f FACT"]
def post_option_parser(configuration)
configuration[:fact] = ARGV.shift if ARGV.size > 0
end
def validate_configuration(configuration)
raise "Please specify a fact to report for" unless configuration.include?(:fact)
end
def show_single_fact_report(fact, facts, verbose=false)
puts("Report for fact: #{fact}\n\n")
facts.keys.sort.each do |k|
printf(" %-40sfound %d times\n", k, facts[k].size)
if verbose
puts
facts[k].sort.each do |f|
puts(" #{f}")
end
puts
end
end
end
def main
rpcutil = rpcclient("rpcutil", :options => options)
rpcutil.progress = false
facts = {}
rpcutil.get_fact(:fact => configuration[:fact]) do |resp|
begin
value = resp[:body][:data][:value]
if value
facts.include?(value) ? facts[value] << resp[:senderid] : facts[value] = [ resp[:senderid] ]
end
rescue Exception => e
STDERR.puts "Could not parse facts for #{resp[:senderid]}: #{e.class}: #{e}"
end
end
show_single_fact_report(configuration[:fact], facts, options[:verbose])
printrpcstats
end
end
Untitled Ruby (20-Jun @ 02:53)
Syntax Highlighted Code
- = F 8 6 k j i h = 9 8 7 6 5 g @ ? > < 3 2 1 0 /
- !<^K?ÔöÈ&;}>zÄ[€°4qÞ\íháËEª#…2 !#Å@»-EC*¥ÌC¥°(Ž!Z/ê,ZÍ<ÅO{`§ !~câp[üÎŒ·”^ŽÈÙ¢õ$r³;Ânî+a½þü !€³3!gË2èYwQADü‰Ê£ ò˜!æ¬sÕÍ• !;(¶²DUªŠo›ýÚÊ]AÉcQȇßP1õ¤|ãkÇú !z÷=ÍÌ)ë´/gŒê„E}|/ñ&3àH ü^£="ƒ !&ŒÆ¿˜²ñqìàŠ°ï´P*0%Æ%…6-6o[á !õ¯¥øy‰³8ͺOœþèaQä:’ð¦ÑÝ¾Ò !¦‚6à\ü\°ûp‡çöæ&ëd&]š{}úfs=ñs'ÁZ !z<Ä>SþTbå²û–Œ0<Ce¸Ük¸ùskN’.8] !!‚÷î8®£6L+€/Ós’*õÊ'2¬±uQ¦%ìž !ÿÉ£9Ih‡-ð@.¨~ÄpT;(±[(2“ ¼˜q8 !èAžÏÖïã QÅ Õ“lsœ§úü ´5‹ !ÍJF´Ù
- ¼…¥a&w»¶Æäw³·êÀ`Y-Qbwu !q`Y¦È >¼`L¸ýÒ¶òÞù}aFgAøãjÇ !¼Ëƒ“ŽSˆñrÛ|‚X “¢Ã j½ÛFoÒòýJ !ÿÌ’‘}‘1(
- [62 more lines...]
Plain Code
= F 8 6 k j i h = 9 8 7 6 5 g @ ? > < 3 2 1 0 /
!<^K?ÔöÈ&;}>zÄ[€°4qÞ\íháËEª#…2 !#Å@»-EC*¥ÌC¥°(Ž!Z/ê,ZÍ<ÅO{`§ !~câp[üÎŒ·”^ŽÈÙ¢õ$r³;Ânî+a½þü !€³3!gË2èYwQADü‰Ê£ ò˜!æ¬sÕÍ• !;(¶²DUªŠo›ýÚÊ]AÉcQȇßP1õ¤|ãkÇú !z÷=ÍÌ)ë´/gŒê„E}|/ñ&3àH ü^£="ƒ !&ŒÆ¿˜²ñqìàŠ°ï´P*0%Æ%…6-6o[á !õ¯¥øy‰³8ͺOœþèaQä:’ð¦ÑÝ¾Ò !¦‚6à\ü\°ûp‡çöæ&ëd&]š{}úfs=ñs'ÁZ !z<Ä>SþTbå²û–Œ0<Ce¸Ük¸ùskN’.8] !!‚÷î8®£6L+€/Ós’*õÊ'2¬±uQ¦%ìž !ÿÉ£9Ih‡-ð@.¨~ÄpT;(±[(2“ ¼˜q8 !èAžÏÖïã QÅ Õ“lsœ§úü ´5‹ !ÍJF´Ù
¼…¥a&w»¶Æäw³·êÀ`Y-Qbwu !q`Y¦È >¼`L¸ýÒ¶òÞù}aFgAøãjÇ !¼Ëƒ“ŽSˆñrÛ|‚X “¢Ã j½ÛFoÒòýJ !ÿÌ’‘}‘1(
fhDì¾?>ñ´»ÉsÀå¸QÆ-¯&y !®?„Šiy‰¶Œ]¢]j™ð’ñ ]m³<ªƒÐô© !l›Ht@0÷f*e’„ŸHJˆxX!ìyqD© 9Ÿ !:÷ö×B•gF5R‚[eÔ{|èMåíqPÌÃþ !¬Týä]À,%#^€U5vÎØ~–é7lwÿÅ.´êICÓË !ov`¸†¨g,ZÁ§¸E-K¸§È'‘àbÜ›àøuNŽ !•ÐR@ÛDɘ]éV±cùxDhÑ:`/ß²c±Y‚ !©üƒýò6oÜö؇t¹ú\áôÉÖ¯1á#t¯ ![ä[ŸØêÙûaz5#äÓ)ë$ù5Ño^²—b›Æ !®ÐöȰZEWk/¨ZUõ¢¦Ç…Q绿RÛèQØ !*ÍYo‹j—!¹÷²´m¾=†°]ŽÌê4¤ƒ©Kjñ !‘ÉàZD¸HÆž·ƒØi²ó™ÞCäB¶/8á"ÄRKÙç !
^;fª$vÍù&Kco´–07oMgeŽãÃô¦¿™ !h£7—ÞF÷çäG¨Â·|Ч æPä’$ëªè¸ˆ !§Q)+Ìãøæª%çÙYV¯d ”×ÙcÝøMbÎ0ó !kôkZĺ!m»½æ£§Fe›XUÏõæ>¸Þà ¡-Ò !x«k:$tÝbtà2D`$C;C€‚¸-‡E}\¦l !ɘyÔ_AIoÔ
¯>QZ¹@‘5•`Z–#'¡ß !srˆ»«³»¦LXÒä¤Ñlâ
âÿ»®ãeë"âl— !¾œÉ¾Wò8ùn%éIJդwè2Ó‚·¿a…r; !ôIÝåƒ#<„=CB³5¸•M¶oê~X¢¹JÜo„ºhŒ~ !eAW„2תñ²$;ï
ö…“FÃ˪VβoQ !ÅÑÔå;9’E‚äÝp1æàªÐ„óʾ
J;q¼ !´øgºÓ2HÕ*U®¨«§º„ST«Ê¯ìbît !ZÃÓ>â †C–£r7žŠu¬g«Dz1ûó4MÒA§ !ÒoJrš-ä»CY_ìzß°ëx‘ò%IñÓ¬z !¤0è3ß,kúITÒR¤£Þ¯—\Î|;Vüàp !NËu'Ž€iz¼œK’nOª<;—M26© Évµ& !æ}ô8¾Ùxwok…=—å3†È’Ÿ9e¤z±@eÆéý= !2¨¼-mZíù¾ô@3£§©%Ñü*ëG“]<p !,(öX“BÖWÄ …a>®°Ã[¯wFtô" !{›ˆ×ÚÜŽYrí†Xòìê&¶üÛ’œ4í§n !,½ñžC™:²Á{œKp]°Â¤Õ0Û }zÌçÿ˜XZ !Õ:ûIà7•ošÄ2ÏU¿PÈiÇÐ|J‚5òfì§e !òä[n\ó•œ:Ü“RYåyë iO±½ï)©% !ºû÷BÐW¡o¿óž$…ïtbº7 Ê*VA—œõ‘ÿm¢ !ŒóòõwûD!ÈöF!—¹Ác»JÔôRüÿìWwí !uÆœ=Ëc@ráá5NȱGÁ„{0Gwº©G !‘c9„J;QvþP6R…HÓZ`û>O†ä%®P@8 !Ê,p©A
jùç—¬ÞDašG³ª/0ÙRbÿP bBm !}Ä\RÝEïÒH“|L1Rͯý»'žŒmöú Þ !SÌ„M!ÿ%'$œ.P÷ýì9‡ÂPŒJºîG%€(\_ !•mÁôN€«÷¤óGZjÀi³Òp>rfaßTëðVÔëi !ÈI’V=âhR¿gSW
9sźçõÿ¨íÅËHÄ !p—ß’¨:ʃZæE¿®sœê9 y’Û1Sⳙ߆çè !)œxeçѰ‡Yv%
WS«™kW!£ÇýNŠ„ !=õ9ˆ^8Ž Ì.ÁÕV#`CÜïSá¯ÀJ°&àsbñ !¤Ÿ€ÄÚlt uHËí%šSþ¥‚†!”¥=E¶k¤6 !éÖÝK¨j%S„Z|©††Ÿó8’˜î½—(®
) !@°µÔçÕ¡rÑ_¼Êúq=,ÎF‚:ÛoÖñÈC«#} !VÏy¨¼ðN“ÎÛF¾7.4Išèp¸ÄEÓl|ê !_¯ógŸ ¤Æ¹ßªkbýÞé©•ÛMjm=¡UQ•ž’ !ÿ^:(µ™à:D7&G·Ñ“f˜¡aàj¸™rtp9ØÔ !Þ‡ÐÜ)öÓT}‚B«ß–c.ãß±S¢So”U;Íæ !³Š¼¹Z¢üûyø(]Ö]„ìÍeG9X àb€^ !
=n¨C…±u&©©ú£
asaà°A ö«èbZ)+ !°¶cg‡ˆcŠÒ:÷rvKkñ&¬¿¦\y„©Æ= !5X¥‚@+,H gÓþ‹¨ˆ$IBQ›˜ªfq9ÉT\A !):Cp7–؉švû7„¬—á½à/¹‡N¶YtËi !n±\SË&2p3à×ÈÔð!:Ÿ_•ÎRb: é6éüú !EЯ#§V,Ð*µÄBy¥v} ùh«BìpØê¡ë÷¯ !€ÉØéqåθågïwý1¼¥³Søµ<;³lÆ}õ˜ !Ø;}]yoëòúñCX×N•§(‹§±¨”Òv¾^…
!ÞÚ#Y¥:L_X÷%Öá•Ø /žbêe'•:ž©† !Ýhá ŵø~âŸHo'ó.IÝü1Ÿ&ƒÖÝãDz3 !„ÑÌÊÚUq;`oYUZíæîâ—ØBíºÏ|Ɖ¼¼ !\QÈŽðb¾XËlÄîú
·Z€ÁÓ –ü2óËF€ !DZ™ï•XY¬ ù
r2!‰Ù߇Բs¡¥,Äš !½š:Ÿ«º°Í¬V„Vßµß;´1¿ßÒ¥ ÁU¡ !»ÙQ’ÓÁk<íí}`“7g£¹³V˜¶þƒ‘ !u²ènãÓY·Œ!uÀ‚˜vN=íiZˆ“KdH!® !€¹CVëeýªTYÑÅ|ÒsÔ‚¹üúÜ:ŽÄùU !o=+íd‡È‡ÓÁënÞüH߯JÈ›RÊx¸•ó´: !|¨ÞïRí4ÔGzèŠ$ŽVúÖß`C¤ô”¶²pPBø !¯C÷ÛžŽO‰Z˾lŒ
”󾋸Ø\äœùëàF‡ !Œ1¨}]XBöð¯ã¸[HÑË·7PM%jÄ7l¹üþã !Y[Í3üµ!}‘ZÜQ˜+ÔÈ›·"AìŒiv¾;×CŸ !!˜OöíñdÑ?Iä: ùÙ8H¥glŽñÓ?[í !xÓ|ä?Å¥ Òî/:V²zW%°Wt¦mPiþ : !=hþ;'>JnV)PN|I²¿Âh~A
&Ñßéed•»V !ÝZTþZÁ·ú.LLZZOw¥É#|åñå~iË !XJ¡Qçœõ*WÄZ£ Pñ
*<]Ôì©÷qÌb@. !ÅB;³hÃF¸Y}fJu.½)+*œV6ßÕ Ãg
qw·{ !XÅ4ºY›" [x:ÈæH"ä—Ü„¼åX”ØA !Ǽ‚sd>L÷(]•rñ”²ûj†·)À…‘Iñ2»öF“ˆ !a;D„GFàOÿÎ<Ô ïØ"¼²ö*E‰»o¯@¾Wø\” !Vú|
7»¼AÁH‰¶¸Rüp肟AŒò†}ÎcTM !iÛ»7ôÏÈC.RºÏI3bmGgdþbŠOŒ“`† !w•Ú]ód룃5|ºV|Q³7£à…¦––ææz>ç$a !ìòÀ‘ÊÚ»ü°.Räî(LŠ*É´u¿nÕv¡ !ç÷Ç@CÄÌöÈàòã0î÷eIÉΆʶTžÜ|6*úéô !Ö?8W‚ÀÚO‘mQÙ*ñ$²HâaÇð_tä®È|eµ !ü¼çGÜìyg‡ä¿-LÇ¡`eëè‹Ê‹ X¶iS|Ï !Î5†&R.V@HÌýµ-õŸ_œ…§ê>üÑ›dÐØ !¾1=h}/dZmºßé.ÑÀª ÿê;>áa,Xן !Ý{§Ü"Ì‹$‘ØÓæÝJ ›]ÊDk8½!Ðe¼¦l !™QÓEðå¾ÜµñÙ_ê3b++n{4}z=gý–z !´lLj3¶ïÕäM@]‹ûÄ“Þ}ÑÁ«Pàÿ !?ÉÅ*{+#ƒ]‡!.éT2Œ°ë÷«HíHÄÍà !Pÿ±‹¯{\W°2ÈåÔý¹Osp…*—ƒÊWþDÀ !§Ø
аýÄ2N=5Ø;¶¼Œ§0©A&~v×v¨§¾þ !ÚTÁ„îk—Ër ±cà x›ÌonŸå5”¶jg !Å;ž.«¹“'œõh¢•ç«ÏAº¿33¿Tyµ|ƒÌI !¨,rÞÁÈÀßÓ³¥‰ÎC€ªæG¼™?½Õd1 !‘ìE2å‡Ù´¸nŸ ²ù³nø:Q=7ÍÕô9ø !°<``a!–%Ê«Q Æwwfè¡V«ÜcÍtÿѯ‰ !8¢Û†…¥Ã¤N>6cn²½Ý?
§™‘]´(‘ !úavÀL,Ë(Ÿ.„Ù…/}›"û\uT½”tJ$ !J¡ßoïÅíܨN?£%/’m&0ÎÕÌÄ&¶ìy† ! êyxS5a鸃r×{“ÝQXåÆr@ie-¸ Ú !t#2¦^ŸYOð‡yRu¡¤¼ÀÉö w‹øÄ@J/ !,³>Ÿ¶áBIÔ¥‰¹¶à*8¼éJ
¹·Ä0ã¼ø !ã-›³óè䃬ÜöÃvIj¦jAT%Ï sDV’Ç?#¥ !®ë˜SQ2†óüBgW¦tä»VÚ–A”ÜÁzÊÙ‘AÑݾ !üNoÓ¾Ò†€Àç ÆKŽœ… è7)íûtBŠÜ !àçÉVH|¢N);†L‘ÂO Óˆ%8Û«Úˆ6Ò) !•6Øá˜•»ßîr‹ûÎî~Ñ)®±ýÿ /ÄH¹ !B§ia¸Æ0Ïj¸X›‘¥!¶s F9Ø;nOŠÃ¹ª !;ŒnûXì|ÒŒØW¯;çý£!Ù<¡ßÑ„w !@59s¤E:Dzý¤¸¨”›í>¾Ÿ¤‚êÖ$[ !¢l8b1îRÉ«g-!ËE†8þ"«Ìœ¶äí'rÖ !”'0®©;Ñû&úÎ7À>Ö1ÑÎLRûØxÆú
à‡ !l’Úrªý¹²x …U»_XÄÚ
J¢¨Í€bœ‡$ !ýy–ÓÖR©ŠçÃH ¡žÿ™õD{\ÿýgùv h@ !í)ôahZ» aÉØØ¸ ›¤W§‹§°4—8HMèÄbŸå !e†Ýåc`—œ(ŠkЦ³A诙Éx(NšH !B™P;ð|ëm¤&„Ü:£qmGSÛ\!`ÞOÉTxb !*ÞÔÊc ™z¬*—_¬
oØù‡‚¦ú"íøæ‡ !úŠæ°}i%˜º5üµ;p¬†@,+ÖÒ§ýu÷ !<¥hy<¹²Ål ÷©Dè±(x¸ i+Ýëü§ÿ !tw³E%ØçøL^—·ÒD0±ScHÏŽ¼"t„ô,y !ö‹H6`DÚú9ç,&˜a ¾²&‰«nL%eÐ !Ç"Ü|7¤ÍÓ¸Dà«*ŽŒ¼æWuMai§@s.ÐÍ !†-»ÒI?ù=¯¯šMËaºs¡»gŸ î×2 !ieä¢gO}2Å?VÛo³|ñc Ó¶¨ëä¡!|è‡hÎ{ !úÄíx—{–±s>Éí6ýLðüm ß^ÈCä; !"}„çO
±Áví[Öþ(…“™7´É¬¦©ÿ®#T¼Læ !b£hc›^ˆ™«<wáú¡lÕä¼W£ü®M‰+,m« !ʘ¬Ò#¡žOàWã(jë.ä{½°¥$ÆëËò~iqP !Ü-ϤèCl‘Í—2zF›’q@y©ˆæ×?z¤ !xè·ÿ»XסÏ/>[ñ¡¢TÔÄ©
}Þ-ÙïÔf„Š7 !á}ÔžZ4¾‹šfvïÌ>‡'÷Ûiæ‘/íb4TÔq¬ !'ý|o)°:ÕfÚí1Ã$pë¡T1eI™´WsøMþ« ! è™ä¾äó´ “9iËÖJšØcôšíˆ !ØMÏOIŸîéø0cÞRO!©Z’¾Ù2.#"Þß^ !(euÑ;¡‰¹7÷#{ƒåÊ,—ªñž^yY€¨Äw¥ !`BwÃî(jg!Øù-0rWÏ9¯9Úkš?a.ùŒo !I€Ì‡ë ÈÕ!Õª¬ÂÎÕsâ¸]ù‘}úм·QÚ !s1ü áïqÐ7Ø.ݧl~ca‡í¡\õSÍÜ9< !
ZPtôdÆ4_¿ÇÒ¤)Ýè+d¬¹ž„›wÄÄ? !Ñž à· ÍŠ[9K\r^¯H¹™”ºÃ´€ÀrUféE“8 !tÈ ˆ+ÉÀÙ{ÚPvGÄ=ŸYŒ7Y•á6€À]æÞçþ !§Ö”VŽ"6gÞÖGÝ
ÍžÌUÈ,ÁñÝW, ´r !n^%9!8Zæà`M»bBÿyÝá½È£ëGR´ !€”‚™ê/ç{¹wÍÔýãëL½sàúkN¸E*…GÂ{ !ô+ O
âÛ5q^°èƇ.±»ŠÉð“hfuö©À¼ !”
ÀeíO {„[XÌÙý õÒäšÞwË
6K$nw !ǯѱ_ ÍQ3—Ž}ÓË“M
ð˜LOÌݲ !vâKçæ%/@Ûµ›vÿpÀ…Æ‹®ßÄ5š<iÍëïº !ù.ìŽ*ÉÞeƹþá¥+¦ºªìÀ$™×mG,Du !´Ò$Q·²ñ6ø’Â/.aª²ÛòvÏ1l7—“ëV¶ !Š!iÄ%veÒ® ù>5Yñ]Ym¶Ëe¶MŽ !I¥ËS@Ë(™µGŒÃãaÚRïYœ G_ªöúç2N !7‚EŽä ÿÖÜ o¸ð®÷@×Ö÷’eVNþÌ !j9Qäâdr6·øŒÙù@
Ì’™9òÖ¥¯†‡ !ëÐQ®Å{‹ÁªO¾Ñ`ö¥¦œ²;ü2 r¸S ß !'»j 긤×-¼»Y寥AÎRÃx‘, +±ÓOð !e˜«ÐÔT–c(„%¥q6V]Í!íU<ñFá‹“Ü
Ü !*³,-1)‚ ÿFÊ·Óªô_K¾Þ(òâÑÏ—ŠÊ !Sä§Áu–Ä€F.æÉׯ"¦…€P½´—‡%uGkg !úd‹µò\±|œJ*®K'·Ü'áƒ@¡´ÂÖ8Aà#O !Üg€³D vâîì‹Ö‚ðwT´€T¿¿¤€ !‹ULg-¬f†[¢Æš£µ—@h¯¶ÀŸ†â-˜^-Ú': !lÓÛZÔ¢#²Ü—,~Íj¦¨v!P^¯ÛÇ\_ ¨`+ç !õH—É*à%>±à6áHoO<¡\ï+б«%†ô!À !ž»HÝùä_ñëÀxä-ñë¦î˜ŽÅeü™
ѲD !ó´]‡gyêU0žÐª÷BNUM*zÜMÿ4-À !#œ ,ïyôAgü*+{D™ýÄÏÇh¯æ–5?‚9 !HT)|÷Òu¢$ò3®›† ZI
œi’ÐÊp9²g !2¹ÓªÉÕ·¨Aƒfýñ€º¦{ß«c8ëpÿÝΙûI°s !éþ7CŒí¢d¤R3¾`0Ó\£°Ñ8 Á-Úè{¶ºÃò !†âz‡ØÊù<Ÿè×w‹5JÁ+ra§¼Õszßù, !4
û… uýšî…w„ö¾aÕÍT‚0eœoÿæ‹™ !¡„8òåwîìÎþfJC+ß—ÒYãÜ D7~ÙzL@g !
,$dÞ‚êÖ
@ÔœUÓëÿÑЩfâ°yvîD£ !qæÐK‚
9F³ó›K7øL¶’•éAcò†7Ç 4#ôj !ìK¨ìu©˜rzY§|MjÖÅ€™;löfØ9žv¸ á !áð·ç-{*Á„%]ª´=ð¬èÎt:¾tZ³Ç¼ !òY&OÏViºý5†ÛMÐ
s8Ìïe×vH|$ !ï¦éu®¥Ô-à¼*pÜÊ÷V©iv8GØ:—cÙ‹f !ãÁUíBðÌûÑ$Î˺öêN`ê’Fˆ0T “"G !8§‘è7y¼”õr—}!&öJlBëß·BºÑl_˜-»ü !
Ä&²"¶$V(Q!ˆµæ.A½\ùšè\d—V«o !Úœ[ññù˜B`¾û»%»LhË×`È#]`@졳 !ì ©--
#ùÇí¥ý:F.…E¯ð~‰)n™Gå†nlÚ !r7{œ¥¬ÈI²‘Û ¡jo P¨úOÛsª2®c !1¼%
‡1Ëü“êChº”Þò!dãxý} ‚Ø !,Qgù¥³ª?ZEÒ]ÀW]ÝÌ…A?¥ðÔ¢ !ÊÌsTéRU’åá®jN @\…/£i¸6J¸–‚ÀJ’Í !ÓÀ¾×ãÝ_6{ýTc7@U» ¨–ÿôdVGsžd !µ–CïÙ–‚$ Íqê¾¹¸"ÓÞ—Ý-fäÏ3 !Fð/NUÚN,dÏ
ïpMÞþ§(1©Ø[HÆgØ_1Ä !3qÂEÖ-ð'ÖJz‹Ç;ÖJ-èÃ]t†ny]¾ÀW' !Xý@Â@q¼F©m§ ›Z#Dë•ÎGŸ]=¿+c !#Xùò`=³ûú¿õq·éåä34ÐF¶1›—ªc@f !¶l…ÙX¾ˆC…ª>ªP♀ÚHW÷QžN¯9_Vy !%\Âüùö×v<]vnS À‰ïÀhjdZçæõ EÊí !çk —Qá V¹Ð§À}ö¬=5Çç÷~I‰öèF !ÆÿÌ;‚†}þSàÿÖmƒtS@™RDZùSžñë !mKŸ„bEÍçrÌõVt] lo’ýº©Ù~D !UÞ…0§þ¨k1§½£2Zs‚ÚÄP´bÆyAÞÞ’!( !?8?Z—²JJYË ¾.±L0·iŽWvé! ! (Q;_!“†èõ@A UxÏ&•Aìá½³5[åâß !gÎÙÓsk }{õEþ^Ý¡{”q€˜ŒÊ>0á !J ‰ãc‰Ê '/]VJ¬,¤Èú®}äâ“Q1²l7 !\8K.y«æž±¦™9 YÉ>“ä#Ðyî5Šixñi@ !,Є.ôÊœ#z Ÿ@™=}èiusJÑïE×yÖ` !wkˆ+K:æ™aqɜä ÐT!µ}¥–;WoRZr !ÊÔÒè×QÍ^–ðòú®@/,WÎíìnUÇ]m˜ÞCM !²I÷åê}Ÿ2
—½µzí‡i²Ê=1w\Å»ú:¢ !`ÀyTE‡–$WC,[:}’Ó:2@6ÊÊ cÒ* !¦å8f“§éãxÒõ;7›ÀJ>È—ª”@L4å
oi !tf/^Üo¶7tcºKå^1ö"E™È+çÂk™ƒx !x¬F}Õ·ái[d—°u`–‰¾Ð{×ðÞÀÄ_Þ?P !ÛÐdO•pÂ7<Àb¾`¢Ýb4ðVÀ1òw_ !f«öä|»º–ÖfÄÂ$dŸ|4„úU(àÊ„w ’ÝV¶< !"çËÅXÛu®Ûñî›z±§øe/[×®Ÿ
¹7¼Þ! !©@Vi8Ë4Õ-¥w÷b0éí t«KjÊV†¼§n3 !jÛ7ès=ºëˆKŠN‰Åkuˆ)b=©çhOq¿ëO£ !ÌeáS>œdvP`°Û¦ãùwÑV²Dñ¤fW !s¶P=W%ß9kI57ÿPŒÊ
öw…¼é¯«
çÀ !¬2D–Wñ 0W!«¬Ê2¢^¬”—( Ž‚æG‰íhy¤ !mg8Èwº'zÃKsŽÓþáÒW pÉ Ð‘`vC> !™•½#IŒ‘® 6¹ëºdg](:¿YW}©³`cç !SQøÌóë2ì¥ñQÊGû8Kò!ò¬¹™äýÄ !¹:}V»<%lã¤wohÌ+ªÊ51%WšŸäP !5Q×à×4Ïx¡K!>¡Sýø>ÿF«/Ó!Íô¥OB !PðÃFõd9bZYãþ[%À,Q›Vj8Ó"Þ”ÄÙw‹ !7ZlírK3tÿY1,À
UöÚXb-fY‰ëʃþ¯®î• !’J¡òZxT‚éÈt£Ôx7à³Å~ÙË‹
³Rü¯A !Ÿ;/;ñ°·s ›2)˜¢¯qòu«èÖ”,¿Fm !Ì›¼õâ°ª\fUÅÕ<Cº Ö‡h•%ɲäN¢Ð !~gwXa— òW7Ž˜N[÷áµE®¯¸‡WÞ:H1× !a¸‚j”ÿo$˜™P.±Š¼Wû—÷±3ššoß|Çoe. !6߀%²®Mà ˜|5ÊdÙTuͰi¢c>Q‹ïï !Þ|3ã4¤@új¤6Y¸@ÿŸtxè€îè²”ØB]_íÜm !Ìz#þH!˜–²S€Ö «¯-Eø*<{çÕÁÁ×%§ !öÍÝŒ¸ ÿH1w.Ηn#mr7]Þ¾f ƒ÷ !«Ùƒ‰OUœŽ‡(´µ¦ª¹ˆeR¼zÞØû^í9y„ !éøjfL.çíö"w¸UšçkÒÜ-ödîãøJo²ò !<^K?ÔöÈ&;}>zÄ[€°4qÞ\íháËEª#…2 !•¿™OÞG1Y•ޤè±dº´£?ÀŽ÷ŽÁ#² !ÃH=H$©lôín ÎU2WbyxIt ê·ƒš_¢` !¦ñ%Lѯµ§ÝþŸ²ýp½¶þåì鎴w²/ !ƒžˆòŸ²R/rFÁÿ ÁT ßù¹Ÿº:;ìûyn !¶Ç£åªd]ëÿ[ FïjÅ4C°oG«è%YÖwZkr; !’ð¾Ïˆ[c¼ÕSé®Zuî¼RŒY,9ï\Ræ—w¦³ !ù½ä°cË;a5#?Õqش铱êí•\˜êóº¶3¶ !KŽ=_B+iPQKD
ÉíÖáÍwÅ–'ûè ! ó@0Ak¬&Î' {^âÇî5M‡ 8ãV1SX3 !H‚0<Ä´»ô+Ìïk‹J"R›+ÄôÓV„ƒÒ_wF !’¾H…®ä¶ý£Þ‹Ô
(壮Ʋ}¿ 1Ÿšß£
!«>ÌñBf
~Zò~÷|`°¬âBšÕ¹ad–‘×ùîî !ÓÓ1>¬c
ì*Rµ¨&(ŸÌ_׫À~ãƒ5cÝ 6V !gÉ'©9ÄaJ`Q#Ó2bBSªÂéiÚ¢ÆeYq; !pŠÿSžçÏ(>ëÛ¨³ù³'Òan)Á úÿwª…"/!˜i !<š<âyt=
½ªc˜ã
ñ|«Š tþ}ÀÙ‰«Æ„Þ !ç¡Û_gÙ‡âÎ
ϤÌI%õ=9rÌþByÌGþC^¤ !ºŒpMæýïe(B‡ÎU¿ø=×–¦ŠÄuP˶^b !ÓHE´@ ›l{ïN½•ÄoYx‹–"ê{ aÛ !f¬EƼ×Ò2ØÏf"ð<ÙÆ@ëåVÀš†ïÏ(«“í !#ôãtQÙ|ž‚!5Çô”ÓãÕÞ3-¥*ÏXSSKàñ !cîÐÝ4¢ø:úc€©ÉtS”Džë_jo»zÜÕ† JH ©@Vi8Ë4Õ-¥w÷b0éí t«KjÊV†¼§n3I http://crl.verisign.com/pca3.crl UH \8K.y«æž±¦™9 YÉ>“ä#Ðyî5Šixñi@I +http://svrintl-crl.verisign.com/SVRIntl.crl RH ¦å8f“§éãxÒõ;7›ÀJ>È—ª”@L4å
oiI (http://crl.verisign.com/Class3NewOFX.crl _H °<``a!–%Ê«Q Æwwfè¡V«ÜcÍtÿѯ‰I 5http://crl-2.trust.teliasonera.com/soneraclass2ca.crl http://ocsp.turktrust.com.tr http://ocsp.wisekey.com/ http://validation.diginotar.nl 2p Oõüq certs.opera.comr »s ô
Untitled Ruby (11-May @ 13:36)
Syntax Highlighted Code
- :hierarchy:
- - %{environment}/%{line}-wsps/%{tcname}
- - %{environment}/%{line}
- [34 more lines...]
Plain Code
:hierarchy:
- %{environment}/%{line}-wsps/%{tcname}
- %{environment}/%{line}
intra3.yaml line specific stuff, like what tomcats should be here
wsps:
mygreatapp1:
tcname: 'tc7_test1'
superapp2:
tcname: 'tc7_tasd1'
then a yaml for each tomcat or application
cat tc7_test1.yaml
---
vhostname: 'test1'
portrange: '123'
jvm_params:
xmx: '2048'
xms: '1024'
db_cons:
sd_puppet:
type: 'mysql'
jdbc: 'puppet_db'
dbserver: 'asdasd'
dbport: '3306'
user: 'puppet'
password: 'bnW$asd'
#max_active: 50
max_idle: 16
#init_size: 5
sddsd_puppet2:
type: 'mysql'
jdbc: 'puppet_db2'
dbserver: 'asdsd'
dbport: '3306'
user: 'puppet'
password: 'asdljdlasld'
Untitled Ruby (11-May @ 13:30)
Syntax Highlighted Code
- class wsp::mysql {
- $line = 'intra3'
- $wsps = hiera('wsps')
- #notify { "wps: $wsps": }
- [46 more lines...]
Plain Code
class wsp::mysql {
$line = 'intra3'
$wsps = hiera('wsps')
#notify { "wps: $wsps": }
create_resources(wsp::mysql::finddb, $wsps)
}
define wsp::mysql::finddb ($tcname=$tcname) {
#notify { "tcname: $tcname": }
#notify { "environment: $environment": }
$db_cons = hiera('db_cons', '')
#notify { "db_cons: $db_cons": }
#db_cons: {"enbw_puppet2"=>{"user"=>"puppet", "jdbc"=>"puppet_db2", "type"=>"mysql", "dbport"=>"3306", "password"=>"asdljdlasld", "dbserver"=>"asdadasd"},
"enbw_puppet"=>{"user"=>"puppet", "max_idle"=>16, "jdbc"=>"puppet_db", "type"=>"mysql", "dbport"=>"3306", "password"=>"asdasd$ETEUn", "dbserver"=>"asdasd"}}
if $db_cons != '' {
create_resources(wsp::mysql::createdb, $db_cons)
}
}
define wsp::mysql::createdb ($type, $dbserver, $dbport, $jdbc, $user, $password, $max_active=50, $max_idle=6, $init_size=5) {
if $dbserver == $hostname {
notify { "Create DB: $name": }
database { "${name}":
charset => 'latin1',
}
$hosts = hiera('hosts')
notify { "hosts: $hosts": }
# TODO: iterate over App Server
# another create_resources? then how do I still have the $name for the dbname?
# database_user { "${user}@localhost":
# password_hash => mysql_password('foo')
# }
# database_grant { 'user@localhost/database':
# privileges => ['all'] ,
# }
}
}
define wsp::mysql::grantuser () {
}
Untitled Ruby (11-May @ 10:41)
Syntax Highlighted Code
- backupninja_mysql:
- dbusername: 'foo'
- dbpassword: 'secret'
- dbhost:
- [1 more lines...]
Plain Code
backupninja_mysql:
dbusername: 'foo'
dbpassword: 'secret'
dbhost:
...
order: 10
Untitled Ruby (11-May @ 10:39)
Syntax Highlighted Code
- db_cons:
- -
- type: 'mysql'
- jdbc: 'puppet_db'
- [8 more lines...]
Plain Code
db_cons:
-
type: 'mysql'
jdbc: 'puppet_db'
server: 's3p5093.foo.bar:3306'
db: 'enbw_puppet'
user: 'puppet'
password: 'bnW$ETEUn'
max_active: 50
max_idle: 6
init_size: 5
so u get it in a hash
Untitled Ruby (11-May @ 09:12)
Syntax Highlighted Code
- cat test.pp
- notice("env: $environment")
- notice("This is the host ${fqdn}")
- [1 more lines...]
Plain Code
cat test.pp
notice("env: $environment")
notice("This is the host ${fqdn}")
puppet apply /tmp/test.pp
Untitled Ruby (9-May @ 16:53)
Syntax Highlighted Code
- class wsp {
- define cfg(
- # this db_cons are the db connections of one tomcat
- [20 more lines...]
Plain Code
class wsp {
define cfg(
# this db_cons are the db connections of one tomcat
# if I need to create a db connection to the same db name for another tomcat the $name variable in the mysql_create will result in a duplicate error
$db_cons = hiera -c /etc/puppet/hiera.yaml db_cons environment=produktiv linie=intra3 name=tc7_test1
{"pupp1et_db"=>{"user"=>"puppet", "type"=>"mysql", "password"=>"bnasdasdUn", "jdbc"=>"e_p5uppet", "server"=>"mygreatdbserver:3306"},
"pupp9et_db"=>{"user"=>"puppet", "type"=>"mysql", "password"=>"ba123", "jdbc"=>"e_p6uppet", "server"=>"mygreatdbserver:3306"}}
create_resources("wsp::mysql_create", $db_cons)
}
define mysql_create ($type, $server, $password, $user, $jdbc) {
@database_grant { "$user@$hostname/$jdbc":
privileges => ['all'] ,
}
@database { "$name":
charset => 'utf8',
}
}
}
Untitled Ruby (9-May @ 15:38)
Syntax Highlighted Code
- this one doesn't work
- cat tomcat7.conf
- # ------------------------------
- # puppet managed config
- [53 more lines...]
Plain Code
this one doesn't work
cat tomcat7.conf
# ------------------------------
# puppet managed config
# ------------------------------
# Where your java installation lives
JAVA_HOME="/usr/lib/jvm/java-<%= java_version %>"
_RUNJAVA="$JAVA_HOME/bin/java"
# Where your tomcat installation lives
CATALINA_BASE="/usr/share/<%= name %>"
CATALINA_HOME="/usr/share/tomcat7"
JASPER_HOME="/usr/share/tomcat7"
CATALINA_TMPDIR="/var/tmp/<%= name %>"
CATALINA_PID=$CATALINA_BASE/tomcat7.pid
CATALINA_LOCK=$CATALINA_BASE/<%= name %>
<% if java_opts != '' -%>
JAVA_OPTS="-DTC=<%= name %> -DPROD_LEVEL=<%= prodlevel %> <%= java_opts %> -verbose:gc -Xloggc:$CATALINA_BASE/logs/gc-`date +\"%Y-%m-%d-%H_%M\"`.log -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -server -Djava.awt.headless=true"
<% else -%>
JAVA_OPTS="-DTC=<%= name %> -DPROD_LEVEL=<%= prodlevel %> -Xmx<% if jvm_params != '' -%><%= jvm_params.fetch("xmx", "512") %>m<% jvm_params.each do |key,value| -%>
<% if key == 'xms' then -%> -Xms<%= value %>m<% end -%>
<% if key == 'perm' then -%> -XX:PermSize=<%= value %>m<% end -%>
<% if key == 'maxperm' then -%> -XX:MaxPermSize=<%= value %>m<% end -%>
<% if key == 'newsize' then -%> -XX:NewSize=<%= value %>m<% end -%>
<% end -%><% else -%>512m<% end -%> -XX:TargetSurvivorRatio=90 -verbose:gc -Xloggc:$CATALINA_BASE/logs/gc-`date +\"%Y-%m-%d-%H_%M\"`.log -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintTenuringDistribution -server -Djava.awt.headless=true"
<% end -%>
CATALINA_OPTS="-Dcom.sun.management.jmxremote"
# Use JAVA_OPTS to set java.library.path for libtcnative.so
#JAVA_OPTS="-Djava.library.path=/usr/lib"
# What user should run tomcat
TOMCAT_USER="tomcat7"
# You can change your tomcat locale here
#LANG="en_US"
# Run tomcat under the Java Security Manager
SECURITY_MANAGER="false"
# Time to wait in seconds, before killing process
SHUTDOWN_WAIT="30"
# Whether to annoy the user with "attempting to shut down" messages or not
SHUTDOWN_VERBOSE="false"
# If you wish to further customize your tomcat environment,
# put your own definitions here
# (i.e. LD_LIBRARY_PATH for some jdbc drivers)
<% if db_cons != '' -%><% db_cons.each_pair do |key, db_con| -%>
<% if db_con['type'] == 'oracle' -%>export LD_LIBRARY_PATH=$ORACLE_HOME/lib<% end -%>
<% end -%><% end %>
and I get:
Failed to parse template wsp/tomcat7/tomcat7.conf: undefined method `each_pair' for #<Array:0x7f8fd18c5c68>
Untitled Ruby (9-May @ 15:37)
Syntax Highlighted Code
- this one works:
- cat tomcat7.conf
- # ------------------------------
- # puppet managed config
- [55 more lines...]
Plain Code
this one works:
cat tomcat7.conf
# ------------------------------
# puppet managed config
# ------------------------------
# Where your java installation lives
JAVA_HOME="/usr/lib/jvm/java-<%= java_version %>"
_RUNJAVA="$JAVA_HOME/bin/java"
# Where your tomcat installation lives
CATALINA_BASE="/usr/share/<%= name %>"
CATALINA_HOME="/usr/share/tomcat7"
JASPER_HOME="/usr/share/tomcat7"
CATALINA_TMPDIR="/var/tmp/<%= name %>"
CATALINA_PID=$CATALINA_BASE/tomcat7.pid
CATALINA_LOCK=$CATALINA_BASE/<%= name %>
<% if java_opts != '' -%>
JAVA_OPTS="-DTC=<%= name %> -DPROD_LEVEL=<%= prodlevel %> <%= java_opts %> -verbose:gc -Xloggc:$CATALINA_BASE/logs/gc-`date +\"%Y-%m-%d-%H_%M\"`.log -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -server -Djava.awt.headless=true"
<% else -%>
JAVA_OPTS="-DTC=<%= name %> -DPROD_LEVEL=<%= prodlevel %> -Xmx<% if jvm_params != '' -%><%= jvm_params.fetch("xmx", "512") %>m<% jvm_params.each do |key,value| -%>
<% if key == 'xms' then -%> -Xms<%= value %>m<% end -%>
<% if key == 'perm' then -%> -XX:PermSize=<%= value %>m<% end -%>
<% if key == 'maxperm' then -%> -XX:MaxPermSize=<%= value %>m<% end -%>
<% if key == 'newsize' then -%> -XX:NewSize=<%= value %>m<% end -%>
<% end -%><% else -%>512m<% end -%> -XX:TargetSurvivorRatio=90 -verbose:gc -Xloggc:$CATALINA_BASE/logs/gc-`date +\"%Y-%m-%d-%H_%M\"`.log -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintTenuringDistribution -server -Djava.awt.headless=true"
<% end -%>
CATALINA_OPTS="-Dcom.sun.management.jmxremote"
# Use JAVA_OPTS to set java.library.path for libtcnative.so
#JAVA_OPTS="-Djava.library.path=/usr/lib"
# What user should run tomcat
TOMCAT_USER="tomcat7"
# You can change your tomcat locale here
#LANG="en_US"
# Run tomcat under the Java Security Manager
SECURITY_MANAGER="false"
# Time to wait in seconds, before killing process
SHUTDOWN_WAIT="30"
# Whether to annoy the user with "attempting to shut down" messages or not
SHUTDOWN_VERBOSE="false"
# If you wish to further customize your tomcat environment,
# put your own definitions here
# (i.e. LD_LIBRARY_PATH for some jdbc drivers)
<%= db_cons.inspect %>
and I get:
# If you wish to further customize your tomcat environment,
# put your own definitions here
# (i.e. LD_LIBRARY_PATH for some jdbc drivers)
{"pupp1et_db"=>{"type"=>"mysql", "user"=>"puppet", "server"=>"mygreatdbserver:3306", "password"=>"bnasdasdUn", "jdbc"=>"e_p5uppet"}, "pupp9et_db"=>{"type"=>"mysql", "user"=>"puppet", "server"=>"mygreatdbserver:3306", "password"=>"ba123", "jdbc"=>"e_p6uppet"}}
Untitled Ruby (9-May @ 15:33)
Syntax Highlighted Code
- # (i.e. LD_LIBRARY_PATH for some jdbc drivers)
- -{"pupp3et_db"=>{"type"=>"mysql", "user"=>"puppet", "server"=>"mygreatdbserver:3306", "password"=>"bnasdasdUn", "jdbc"=>"e_p5uppet"}, "pupp4et_db"=>{"type"=>"mysql", "user"=>"puppet", "server"=>"mygreatdbserver:3306", "password"=>"ba123", "jdbc"=>"e_p6uppet"}}
- +{"pupp1et_db"=>{"type"=>"mysql", "user"=>"puppet", "server"=>"mygreatdbserver:3306", "password"=>"bnasdasdUn", "jdbc"=>"e_p5uppet"}, "pupp9et_db"=>{"type"=>"mysql", "user"=>"puppet", "server"=>"mygreatdbserver:3306", "password"=>"ba123", "jdbc"=>"e_p6uppet"}}
- [4 more lines...]
Plain Code
# (i.e. LD_LIBRARY_PATH for some jdbc drivers)
-{"pupp3et_db"=>{"type"=>"mysql", "user"=>"puppet", "server"=>"mygreatdbserver:3306", "password"=>"bnasdasdUn", "jdbc"=>"e_p5uppet"}, "pupp4et_db"=>{"type"=>"mysql", "user"=>"puppet", "server"=>"mygreatdbserver:3306", "password"=>"ba123", "jdbc"=>"e_p6uppet"}}
+{"pupp1et_db"=>{"type"=>"mysql", "user"=>"puppet", "server"=>"mygreatdbserver:3306", "password"=>"bnasdasdUn", "jdbc"=>"e_p5uppet"}, "pupp9et_db"=>{"type"=>"mysql", "user"=>"puppet", "server"=>"mygreatdbserver:3306", "password"=>"ba123", "jdbc"=>"e_p6uppet"}}
wsp/tomcat7/tomcat7.conf: undefined method `each_pair'
and I'm sure that I'm in the right template, because I removed the each_pair loop and it works.
And I'm using the right hieradata, because I changed the $name of the DB resource
Untitled Ruby (9-May @ 15:22)
Syntax Highlighted Code
- <% if db_cons != '' -%><% db_cons.each do |key, db_con| -%>
- <% if db_con['type'] == 'oracle' -%>export LD_LIBRARY_PATH=$ORACLE_HOME/lib<% end -%>
- <% end -%><% end %>
- [4 more lines...]
Plain Code
<% if db_cons != '' -%><% db_cons.each do |key, db_con| -%>
<% if db_con['type'] == 'oracle' -%>export LD_LIBRARY_PATH=$ORACLE_HOME/lib<% end -%>
<% end -%><% end %>
Failed to parse template wsp/tomcat7/tomcat7.conf: undefined method `[]' for nil:NilClass
db_cons is this:
{"pupp4et_db"=>{"type"=>"mysql", "password"=>"ba123", "server"=>"mygreatdbserver:3306", "user"=>"puppet", "jdbc"=>"e_p6uppet"},
"pupp3et_db"=>{"type"=>"mysql", "password"=>"bnasdasdUn", "server"=>"mygreatdbserver:3306", "user"=>"puppet", "jdbc"=>"e_p5uppet"}}
Untitled Ruby (9-May @ 15:20)
Syntax Highlighted Code
- <% if db_cons != '' -%><% db_cons.each do |key, db_con| -%>
- <% if db_con['type'] == 'oracle' -%>export LD_LIBRARY_PATH=$ORACLE_HOME/lib<% end -%>
- <% end -%><% end %>
Plain Code
<% if db_cons != '' -%><% db_cons.each do |key, db_con| -%>
<% if db_con['type'] == 'oracle' -%>export LD_LIBRARY_PATH=$ORACLE_HOME/lib<% end -%>
<% end -%><% end %>
Untitled Ruby (9-May @ 14:51)
Syntax Highlighted Code
- class wsp {
- define cfg {
- db_cons = hiera('db_cons')
- [17 more lines...]
Plain Code
class wsp {
define cfg {
db_cons = hiera('db_cons')
create_resources(wsp::mysql_create, $db_cons)
}
define mysql_create ($type, $server, $db, $password, $user, $jdbc) {
notify { "mysql_create $name $user": }
}
}
db_cons is still:
[{"pupp3et_db"=>{"password"=>"bnasdasdUn", "type"=>"mysql", "user"=>"puppet", "server"=>"mygreatdbserver:3306", "jdbc"=>"e_p5uppet"}},
{"pupp4et_db"=>{"password"=>"ba123", "type"=>"mysql", "user"=>"puppet", "server"=>"mygreatdbserver:3306", "jdbc"=>"e_p6uppet"}}]
still the same Error 400 on SERVER: undefined method `[]' for nil:NilClass on the lines with create_resources(wsp::mysql_create, $db_cons)
Untitled Ruby (9-May @ 13:27)
Syntax Highlighted Code
- db_cons:
- [28 more lines...]
Plain Code
db_cons:
[{"pupp3et_db"=>{"server"=>"mygreatdbserver:3306", "type"=>"mysql", "user"=>"puppet", "password"=>"bnasdasdUn", "jdbc"=>"e_p5uppet"}},
{"pupp4et_db"=>{"server"=>"mygreatdbserver:3306", "type"=>"mysql", "user"=>"puppet", "password"=>"ba123", "jdbc"=>"e_p6uppet"}}]
create_resources(mysql_create, $db_cons)
define mysql_create ($type, $server, $db, $password, $user) {
if $type == 'mysql' {
@database_user { "$user@$hostname":
password_hash => mysql_password("$password")
}
@database_grant { "$user@$hostname/$jdbc":
privileges => ['all'] ,
}
@database { "$name":
charset => 'utf8',
}
}
}
Error 400 on SERVER: undefined method `[]' for nil:NilClass at the line with create_resources
Untitled Ruby (9-May @ 12:23)
Syntax Highlighted Code
- I get this from hiera:
- $db_cons = hiera('db_cons')
- [{"jdbc"=>"pupp3et_db", "db"=>"e_p5uppet", "type"=>"mysql", "user"=>"puppet", "server"=>"mygreatdbserver:3306", "password"=>"bnasdasdUn"},
- {"jdbc"=>"pupp4et_db", "db"=>"e_p6uppet", "type"=>"mysql", "user"=>"puppet", "server"=>"mygreatdbserver:3306", "password"=>"ba123"}]
- [30 more lines...]
Plain Code
I get this from hiera:
$db_cons = hiera('db_cons')
[{"jdbc"=>"pupp3et_db", "db"=>"e_p5uppet", "type"=>"mysql", "user"=>"puppet", "server"=>"mygreatdbserver:3306", "password"=>"bnasdasdUn"},
{"jdbc"=>"pupp4et_db", "db"=>"e_p6uppet", "type"=>"mysql", "user"=>"puppet", "server"=>"mygreatdbserver:3306", "password"=>"ba123"}]
which is a array consisting of 2 hashes.
Now I want to create the databases and the grants for both hashes:
mysql_create { $db_cons: }
define mysql_create {
# How do I access the hash? In this define?
if $db_con != '' {
@database_user { "$db_con['user']@$hostname":
password_hash => mysql_password("$db_con['password']")
}
@database_grant { "$db_con['user']@$hostname/$jdbc":
privileges => ['all'] ,
}
$db_name = inline_template("<%= scope.lookupvar(\"$db_con['jdbc']\") %>")
@database { "$db_name":
charset => 'utf8',
}
}
}
When I try something like
define mysql_create ($db_con) {
I get Error 400 on SERVER: Must pass db_cons to Wsp::Mysql_create[jdbcpupp3et_dbtypemysqlpasswordbnasdasdUndbe_p5uppetuserpuppetservermygreatdbserver:3306]
Untitled Ruby (10-Apr @ 15:15)
Syntax Highlighted Code
- Hi there,
- most of our current work is adding new virtualhosts to already existing web servers.
- I'm currently generating that virtualhost config with puppet:
- [13 more lines...]
Plain Code
Hi there,
most of our current work is adding new virtualhosts to already existing web servers.
I'm currently generating that virtualhost config with puppet:
puppet-apache-tomcat::cfg { "tc6_foobar":
vhostname => 'test-foobar6',
portrange => 118,
wwwdir => '/tmp/foobar6.foo.bar', }
What I also need to do is create the DNS entry for our intranet DNS server, which we are not allowed to manage directly, so puppet created DNS zone files, wouldn't work.
This has recently been automated to a simple script, which creates a csv file on a samba share with the DNS name (in this case the vhostname parameter from the puppet class) and the target CNAME.
That samba share folder then gets polled from another script, which then creates the entry in the DNS server and removes the csv file.
Because of that I would only need to create that csv file, when I add a new puppet-apache-tomcat::cfg resource to my manifest.
My question is: is there a "good" way to do that with puppet or should I just call this DNS script before I add a new puppet-apache-tomcat::cfg ?
Untitled Ruby (21-Mar @ 05:37)
Syntax Highlighted Code
- Ž h L 8 $
- ô Þ Î ´ – x ^ D 8 0 & s ñÍ[J % à à h H RSDSH,”ÂZ÷Jš°Ï€jš3 wiatwain.pdb * ‹ÿU‹ì¸csmà9Eu
- ÿuPèe YY]Ã3À]ÃÌÌÌÌÌ‹ÿU‹ìV‹u3Àë…Àu‹…ÉtÿуÆ;urì^]ÃÌÌÌÌÌh€ ÿD Y£@# £<# …Àu@à 3ÀÃÌÌÌÌÌ‹ÿU‹ìS3ÀVW9Eu&9 ~ÿ
- ‹=( P¾8# éå 3ÀéK ƒ}…> d‹
- [5 more lines...]
Plain Code
Ž h L 8 $
ô Þ Î ´ – x ^ D 8 0 & s ñÍ[J % à à h H RSDSH,”ÂZ÷Jš°Ï€jš3 wiatwain.pdb * ‹ÿU‹ì¸csmà9Eu
ÿuPèe YY]Ã3À]ÃÌÌÌÌÌ‹ÿU‹ìV‹u3Àë…Àu‹…ÉtÿуÆ;urì^]ÃÌÌÌÌÌh€ ÿD Y£@# £<# …Àu@à 3ÀÃÌÌÌÌÌ‹ÿU‹ìS3ÀVW9Eu&9 ~ÿ
‹=( P¾8# éå 3ÀéK ƒ}…> d‹
‹Y‹=( ‰EP¾8# ë;Ãthè ÿ j SVÿ×…ÀuçëÇE ¡4# j_…Àt jè ë9h` hX Ç4# èÿÿÿYY…À…zÿÿÿhT hP èM Y‰=4# 3ÛY9]uSVÿ, 9H# thH# è³ Y…Àt
ÿuWÿuÿH# ÿ ëwhè ÿ j jVÿ×…Àuê¡4# ƒøt
jèï YëM‹@# …Ût0‹=<# ƒÇüë‹…ÀtÿЃï;ûsñSÿ@ ƒ%<# ƒ%@# Yj VÇ4# ÿ, 3À@_^[] ÌÌÌÌÌj,hð èš ‹M3ÒB‰Uä3ö‰uü‰
;Îu95 u‰uäé ;Êt ƒù… ¡D# ;Æt6‰Uü‰ ÿuQÿuÿЉEäë‹Eì‹‹ ‰MàPQèýÿÿYYËeè3ö‰uä‰uü9u䄱 ÇEü ÿuÿuÿuèÖýÿÿ‰Eäë‹Eì‹‹ ‰MÜPQèKýÿÿYYËeè3ö‰uä‰uü9uä„o ‹MÇEü ÿuQÿuèº ‰Eäë‹Eì‹‹ ‰MØPQèýÿÿYYËeè3ö‰uä‰uüƒ}…œ 9uä…“ ÇEü VVÿuèr ë‹Eì‹‹ ‰MÔPQèÃüÿÿYYËeè3ö‰uüÇEü VVÿuèýÿÿë‹Eì‹‹ ‰MÐPQè”üÿÿYYËeè3ö‰uü¡D# ;Æt,ÇEü VVÿuÿÐë‹Eì‹‹ ‰MÌPQè_üÿÿYYËeè3ö‰uü9ut
ƒ}…€ ÇEü ÿuÿuÿuè¥üÿÿ‰Eäë‹Eì‹‹ ‰MÈPQèüÿÿYYËeè3ö‰uä‰uü¡D# ;Æt>95 t6ÇEü ÿuÿuÿuÿЉEäë‹Eì‹‹ ‰MÄPQèÓûÿÿYYËeè3ö‰uä‰uüÇEüþÿÿÿè ‹Eäè Â Ç ÿÿÿÿÃÌÌÌÌÌ‹ÿU‹ìƒ}uè½ ]é‰ýÿÿÌÌÌÌÌÿ%H ÌÌÌÌÌÌÌÌ‹ÿU‹ì‹M¸MZ f9t3À]ËA<Á8PE uï3Ò¹ f9H”‹Â]ÃÌÌÌÌÌÌÌÌÌÌÌ‹ÿU‹ì‹E‹H<È·ASV·q3ÒWD…öv‹}‹H;ùr ‹XÙ;ûr
BƒÀ(;Örè3À_^[]ÃÌÌÌÌÌjhp è‡ ƒeü ¾ Vè\ÿÿÿY…Àt=‹E+ÆPVè‹ÿÿÿYY…Àt+‹@$Áè÷ЃàÇEüþÿÿÿë ‹Eì‹ ‹ 3É=
Untitled Ruby (2-Mar @ 23:37)
Syntax Highlighted Code
- [eric@leterel ~/puppet-test]$ more file1.pp
- if $hostname =~ /sfsfsfst/ {
- import "file2.pp"
- [11 more lines...]
Plain Code
[eric@leterel ~/puppet-test]$ more file1.pp
if $hostname =~ /sfsfsfst/ {
import "file2.pp"
}
notice "Hey done with 1"
[eric@leterel ~/puppet-test]$ cat file2.pp
notice "Hey we're in 2"
[eric@leterel ~/puppet-test]$ puppet apply --confdir=/tmp ./file1.pp
notice: Scope(Class[main]): Hey we're in 2
notice: Scope(Class[main]): Hey done with 1
notice: Finished catalog run in 0.01 seconds
Untitled Ruby (3-Nov @ 23:03)
Syntax Highlighted Code
- % irb
- ruby-1.8.7-p352 :012 > require 'yaml'
- ruby-1.8.7-p352 :015 > puts [ { 'key' => 'value' }, { 'key2' => 'value2' } ].to_yaml
- ---
- [2 more lines...]
Plain Code
% irb
ruby-1.8.7-p352 :012 > require 'yaml'
ruby-1.8.7-p352 :015 > puts [ { 'key' => 'value' }, { 'key2' => 'value2' } ].to_yaml
---
- key: value
- key2: value2
=> nil
Untitled Ruby (1-Jul @ 17:11)
Syntax Highlighted Code
- #!/usr/bin/ruby
- require 'puppet'
- require 'json'
- [53 more lines...]
Plain Code
#!/usr/bin/ruby
require 'puppet'
require 'json'
require 'stomp'
def newevent
event = {:subject => nil,
:type => "archive",
:metrics => {},
:origin => "puppet report",
:extended_data => {},
:severity => 0,
:eventtime => nil,
:text => nil,
:name => nil}
end
events = []
report = YAML.load_file("/var/lib/puppet/state/last_run_report.yaml")
report.resource_statuses.find_all {|f| f[1].changed?}.each do |resource|
event = newevent
event[:eventtime] = report.time.utc.to_i
event[:name] = resource.first
event[:subject] = report.host
event[:metrics][:change_count] = resource[1].change_count
event[:metrics][:evaluation_time] = resource[1].evaluation_time
event[:metrics][:events] = resource[1].events.size
event[:metrics][:out_of_sync_count] = resource[1].out_of_sync_count
event[:extended_data][:resource_type] = resource[1].resource_type
event[:extended_data][:resource_title] = resource[1].title
event[:extended_data][:events] = resource[1].events
event[:extended_data][:catalog_version] = report.configuration_version
events << event
end
config = {}
config[:stomp] = {:user => "xx",
:password => "xx",
:server => "stomp",
:port => 6163}
config[:output] = ["/queue/unimatrix.portal"]
begin
Timeout::timeout(2) {
conn = Stomp::Connection.new(config[:stomp][:user], config[:stomp][:password], config[:stomp][:server], config[:stomp][:port])
events.each do |event|
conn.publish(config[:output], event.to_json)
end
}
rescue Exception => e
STDERR.puts "Failed to send: #{e.class}: #{e}"
exit 1
end
Untitled Ruby (1-Jul @ 16:32)
Syntax Highlighted Code
- # parsing the new last_run_report.yaml for events.
- >>> YAML.load_file("last_run_report.yaml").resource_statuses.find_all {|f| f[1].changed?}.each{|r| p r.first}
- "File[/etc/puppet/puppet.conf]"
- [1 more lines...]
Plain Code
# parsing the new last_run_report.yaml for events.
>>> YAML.load_file("last_run_report.yaml").resource_statuses.find_all {|f| f[1].changed?}.each{|r| p r.first}
"File[/etc/puppet/puppet.conf]"
"File[/etc/mcollective/facts.yaml]"
"Service[httpd]"
Untitled Ruby (24-May @ 18:47)
Syntax Highlighted Code
- module MCollective
- module Registration
- class Foo<Base
- def body
- [26 more lines...]
Plain Code
module MCollective
module Registration
class Foo<Base
def body
config = Config.instance
collective = config.pluginconf["registration.target_collective"] || nil
if collective
data = ["hello world!"]
target = Util.make_target("registration", :command, collective)
reqid = Digest::MD5.hexdigest("#{config.identity}-#{Time.now.to_f.to_s}-#{target}")
filter = {"agent" => "registration"}
req = PluginManager["security_plugin"].encoderequest(config.identity, target, data, reqid, filter)
Log.debug("Sending registration #{reqid} to #{target} in collective #{collective}")
PluginManager["connector_plugin"].send(target, req)
return nil
else
return data
end
rescue Exception => e
Log.warn("Failed to send registration: #{e.class}: #{e}")
return nil
end
end
end
end
Untitled Ruby (23-May @ 08:03)
Syntax Highlighted Code
- def say_hello subj
- puts "Hello, #{subj}"
- end
Plain Code
def say_hello subj
puts "Hello, #{subj}"
end
Untitled Ruby (23-May @ 08:00)
Syntax Highlighted Code
- def say_hello subj
- puts "Hello, subj"
- end
Plain Code
def say_hello subj
puts "Hello, subj"
end
Untitled Ruby (1-Apr @ 10:21)
Syntax Highlighted Code
- err: /Stage[main]/Base::Puppet-client/Package[puppet]: Could not evaluate: Could not get latest version: Could not list gems: Execution of '/usr/bin/gem list --remote puppet' returned 1: ERROR: http://rubygems.org/ does not appear to be a repository
- ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
- SocketError: getaddrinfo: Name or service not known (http://rubygems.org/yaml)
- [7 more lines...]
Plain Code
err: /Stage[main]/Base::Puppet-client/Package[puppet]: Could not evaluate: Could not get latest version: Could not list gems: Execution of '/usr/bin/gem list --remote puppet' returned 1: ERROR: http://rubygems.org/ does not appear to be a repository
ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError)
SocketError: getaddrinfo: Name or service not known (http://rubygems.org/yaml)
package { puppet:
provider => gem,
ensure => latest,
#source => "puppet:///puppet-client/puppet-$name.gem",
source => "/tmp/puppet-$puppet_version.gem",
}
Untitled Ruby (8-Mar @ 14:48)
Syntax Highlighted Code
- #!/usr/bin/ruby
- require 'mcollective'
- require 'pp'
- [53 more lines...]
Plain Code
#!/usr/bin/ruby
require 'mcollective'
require 'pp'
agent = "filemgr"
# the simplerpc request
request = {:action => "status",
:data => {:file => "/tmp"}}
classname = "MCollective::Agent::#{agent.capitalize}"
class NoopConnector
def method_missing(*args)
MCollective::Log.debug("connector #{args.pretty_inspect}")
true
end
end
configfile = "server.cfg"
# stub the connector with a noop one
MCollective::PluginManager << {:type => "connector_plugin", :class => NoopConnector.new}
connection = MCollective::PluginManager["connector_plugin"]
config = MCollective::Config.instance
config.loadconfig(configfile) unless config.configured
MCollective::PluginManager.loadclass(classname)
MCollective::PluginManager << {:type => "#{agent}_agent", :class => classname}
pp MCollective::PluginManager["#{agent}_agent"].handlemsg({:body => request}, connection)
OUTPUT
======
debug 2011/03/08 15:23:37: ddl.rb:56:in `findddlfile' Found filemgr ddl at /usr/libexec/mcollective/mcollective/agent/filemgr.ddl
debug 2011/03/08 15:23:37: pluginmanager.rb:73:in `[]' Returning plugin filemgr_agent with class MCollective::Agent::Filemgr
debug 2011/03/08 15:23:37: filemgr.rb:63:in `status' Asked for status of '/tmp' - it is present
{:statusmsg=>"OK",
:data=>
{:ctime=>Tue Mar 08 15:07:57 +0000 2011,
:type=>"directory",
:present=>1,
:uid=>0,
:mtime_seconds=>1299596877,
:gid=>0,
:ctime_seconds=>1299596877,
:atime_seconds=>1299529385,
:atime=>Mon Mar 07 20:23:05 +0000 2011,
:size=>4096,
:output=>"present",
:name=>"/tmp",
:md5=>0,
:mtime=>Tue Mar 08 15:07:57 +0000 2011,
:mode=>"41777"},
:statuscode=>0}
Untitled Ruby (2-Mar @ 21:28)
Syntax Highlighted Code
- module Puppet::Parser::Functions
- newfunction(:from_json, :type => :rvalue) do |args|
- PSON.load(args[0])
- end
- end
Plain Code
module Puppet::Parser::Functions
newfunction(:from_json, :type => :rvalue) do |args|
PSON.load(args[0])
end
end
Untitled Ruby (2-Mar @ 17:24)
Syntax Highlighted Code
- module MCollective
- module Agent
- class Smith < RPC::Agent
- def report_action
- [50 more lines...]
Plain Code
module MCollective
module Agent
class Smith < RPC::Agent
def report_action
reply[:libdir] = @config.libdir
reply[:agents] = Agents.agentlist
end
def updateagent_action
validate :name, String
validate :source, String
validate :method, String
validate :reload, /(true|false)/
update_methods = [ "http", "file"]
if !update_methods.include? request[:method] then
reply.fail ":method must be one of " + update_methods.join(", ")
else
destination = @config.libdir.to_s+"/mcollective/agent/"+request[:name]+".rb"
reply[:destination] = destination
end
case request[:method]
when "http":
require "rubygems"
require 'open-uri'
# Get the file from http (request[:source]) to its destination
fp=open(destination,"w")
fp.write(open(request[:source]).read)
fp.close
# is there a way to control this ??
reply[:result] = true
when "file":
require 'ftools'
# copy the file from request[:source] to the right place
begin File.syscopy(request[:source],destination)
reply[:result] = true
rescue
reply.fail "could not copy file while updating !"
end
end # end of case
if request[:reload] == "true" then
Log.instance.debug("Reload requested after update of an agent (#{request[:name]})")
end
end # end of updateagent_action method
end # end of class/class/module
end
end
Untitled Ruby (18-Feb @ 14:24)
Syntax Highlighted Code
- Facter.add(:fourthoctet) do
- setcode do
- fourthoctet = Facter.value(:ipaddress).split("\.")[3]
- end
- [2 more lines...]
Plain Code
Facter.add(:fourthoctet) do
setcode do
fourthoctet = Facter.value(:ipaddress).split("\.")[3]
end
end
Untitled Ruby (11-Feb @ 09:34)
Syntax Highlighted Code
- #!/usr/bin/ruby
- require 'mcollective'
- [31 more lines...]
Plain Code
#!/usr/bin/ruby
require 'mcollective'
include MCollective::RPC
rpcutil = rpcclient("rpcutil")
hosts = {}
count = 0
rpcutil.inventory do |resp|
facts = resp[:body][:data][:facts]
pp resp[:body][:data] if facts["hostname"].nil?
next if facts["hostname"].nil?
role = facts["hostname"]
role = $1 if role =~ /gt-(.+?)\d+/
hosts[role] ||= []
hosts[role] << {:fqdn => facts["fqdn"], :address => facts["ipaddress"]}
count += 1
end
hosts.keys.sort.each do |group|
hosts[group].each do |node|
puts "[%s;%s]" % [group, node[:fqdn]]
puts "\taddress %s" % node[:address]
puts
end
end
STDERR.puts "Dumped #{count} hosts in #{hosts.keys.size} groups"
Untitled Ruby (7-Feb @ 08:53)
Syntax Highlighted Code
- #!/usr/bin/ruby
- require 'mcollective'
- [6 more lines...]
Plain Code
#!/usr/bin/ruby
require 'mcollective'
include MCollective::RPC
u = rpcclient("rpcutil")
u.get_fact(:fact => "uptime_days") do |resp|
puts "%-30s - %s" % [ resp[:senderid], resp[:body][:data][:value].class ]
end
Untitled Ruby (2-Feb @ 15:25)
Syntax Highlighted Code
- module MCollective
- module Agent
- class Echo<RPC::Agent
- metadata :name => "Echo Agent",
- [17 more lines...]
Plain Code
module MCollective
module Agent
class Echo<RPC::Agent
metadata :name => "Echo Agent",
:description => "Simple Echo Agent",
:author => "Me",
:license => "Apache v.2",
:version => "1.0",
:url => "http://www.devco.net/",
:timeout => 2
action "echo" do
validate :msg, String
reply.fail! "Boom!" if rand(10) % 2 == 0
reply[:msg] = request[:msg]
reply[:time] = Time.now.to_s
end
end
end
end
Untitled Ruby (2-Feb @ 15:15)
Syntax Highlighted Code
- module MCollective
- module Registration
- # A registration plugin that sends in all the meta data we have for a node:
- #
- [41 more lines...]
Plain Code
module MCollective
module Registration
# A registration plugin that sends in all the meta data we have for a node:
#
# - all facts
# - all agents
# - all classes if applicable
#
# will add cf classes soon
#
# http://code.google.com/p/mcollective-plugins/wiki/RegistrationMetaData
# Author: R.I.Pienaar <rip@devco.net>
# Licence: Apache 2
class Meta<Base
def initialize
@statefile = Config.instance.pluginconf["puppetd.statefile"] || "/var/lib/puppet/state/state.yaml"
@last_registration = -1
end
def body
if File.exists?(@statefile)
last_puppet_run = File.stat(@statefile).mtime.to_i
raise "no puppet run since last registration" unless last_puppet_run > @last_registration
@last_registration = Time.now.to_i
end
result = {:agentlist => [],
:facts => {},
:classes => []}
cfile = Config.instance.classesfile
Log.instance.info("Reading classes from #{cfile}")
if File.exist?(cfile)
result[:classes] = File.readlines(cfile).map {|i| i.chomp}
end
result[:agentlist] = Agents.agentlist
result[:facts] = PluginManager["facts_plugin"].get_facts
result
end
end
end
end
Untitled Ruby (27-Jan @ 12:21)
Syntax Highlighted Code
- #!/usr/bin/ruby
- require 'puppet'
- require 'yaml'
- require 'facter'
- [65 more lines...]
Plain Code
#!/usr/bin/ruby
require 'puppet'
require 'yaml'
require 'facter'
localconfig = ARGV[0] || "#{Puppet[:clientyamldir]}/catalog/#{ Facter.fqdn }.yaml"
unless File.exist?(localconfig)
puts("Can't find #{ Facter.fqdn }.yaml")
exit 1
end
lc = File.read(localconfig)
begin
pup = Marshal.load(lc)
rescue TypeError
pup = YAML.load(lc)
rescue Exception => e
raise
end
def user_key_files
# also the filename from AuthorizedKeysFile in the sshd configfile
sshkeys = [ ".ssh/authorized_keys", ".ssh/authorized_keys2" ]
found_keyfiles = []
File.open("/etc/passwd", 'r').each do | record |
homedir = record.split(":").values_at(5)
sshkeys.each do | keyfile |
found_keyfiles.push "#{homedir}/#{keyfile}" if File.exists? "#{homedir}/#{keyfile}"
end
end
return found_keyfiles
end
# horrid - make recursion work properly instead
@puppet_keys = []
def extract_resource(resource)
if resource.class == Puppet::Resource::Catalog
resource.edges.each do |b|
extract_resource b
end
elsif resource.class == Puppet::Relationship and resource.target.class == Puppet::Resource and resource.target.title != nil and resource.target.file != nil
target = resource.target
if target.type == "File" and target.title.include? "/authorized_keys"
@puppet_keys.push target.title
return target.title
end
end
end
extract_resource(pup)
unmanaged = user_key_files - @puppet_keys
if unmanaged
puts "CRIT: #{unmanaged.length} unmanaged key files - #{unmanaged.join(", ")}"
exit 2
else
puts "OK: all #{unmanaged.length} found key files are managed"
exit 0
end
Untitled Ruby (22-Jan @ 12:43)
Syntax Highlighted Code
- #!/usr/bin/ruby
- require 'rubygems'
- require 'stomp'
- [12 more lines...]
Plain Code
#!/usr/bin/ruby
require 'rubygems'
require 'stomp'
require 'pp'
c = Stomp::Connection.open("admin", "secret", "localhost", 6163, true)
10.times { c.publish("/queue/foo", "foo") }
c.subscribe("/queue/foo")
c.subscribe("/temp-queue/bar", { "transformation" => "jms-map-xml"})
c.publish("/queue/ActiveMQ.Statistics.Broker", "", {"reply-to" => "/temp-queue/bar"})
loop do
pp c.receive
end
Untitled Ruby (22-Jan @ 00:45)
Syntax Highlighted Code
- #!/usr/bin/ruby
- # simple prototype of a file upload server supposed to run on a
- # pair of drbd machines making a filesystem available. front it
- [114 more lines...]
Plain Code
#!/usr/bin/ruby
# simple prototype of a file upload server supposed to run on a
# pair of drbd machines making a filesystem available. front it
# with a load balancer and get a cheap cluster web file server
# that supports failover and scaling using shards of redudant
# storage servers
#
#
# - rest service |
# / - drbd
# client | ----- | load balancer |
# \ - drbd
# - rest service |
#
#
# On the DRBD lives a file 'owner' that is mode 000 and each REST
# service checks for the existence of this file to determine if it
# should serve requests. The load balancer health checks with GET
# on / which also checks for the existance of this file thus the
# load balancer picks the active host to send file writes and
# deletes to. Any IO failure results in a 500 error which the
# load balancer also understands as failure
#
# File reads to the CDN that fronts this will still be doing using
# normal apache or lighttpd
#
# This is a prototype showing the protocol, final version will be
# based on node.js
#
# upload with curl
# curl -F "file=@file.txt" http://localhost:4567/some/long/path/to/file/file.txt
#
# delete with telnet
# telnet localhost 4567
# DELETE /some/long/path/to/file/file.txt HTTP/1.0
#
# test with curl
# curl http://localhost:4567/
#
# R.I.Pienaar <rip@devco.net>
require 'rubygems'
require 'sinatra'
require 'fileutils'
# uploads to /tmp/uploads only if /tmp/uploads/owner exist
DEST="/tmp/uploads"
OWNERFILE="owner"
class Filer
class << self
def storage_owner?
File.exist?(File.join([DEST, OWNERFILE]))
end
def delete(file)
fpath = File.join([DEST, file])
FileUtils.rm(fpath) if File.exist?(fpath)
File.exist?(fpath) ? false : true
end
def upload(file, tempfile)
fpath = File.join([DEST, file])
dirname = File.dirname(fpath)
FileUtils.mkdir_p(dirname) unless File.exist?(dirname)
File.open(fpath, "w") do |f|
while blk = tempfile.read(65536)
f.print blk
end
end
return fpath
end
end
end
before { halt 500, "Not the storage owner\n" unless Filer.storage_owner? }
get "/" do
"ok\n"
end
post "/*" do
halt 500, "please specify a file name\n" unless params[:splat][0]
halt 500, "No file uploaded\n" unless params[:file] && params[:file][:tempfile]
tmpfile = params[:file][:tempfile]
saved_file = ""
begin
saved_file = Filer.upload(params[:splat][0], tmpfile)
rescue Exception => e
halt 500, "Failed to handle file upload: #{e}\n"
ensure
tmpfile.delete
end
"saved " << saved_file << "\n"
end
delete "/*" do
halt 500, "please specify a file name\n" unless params[:splat][0]
begin
if Filer.delete(params[:splat][0])
return "file deleted\n"
else
halt 500, "could not delete file\n"
end
rescue Exception => e
halt 500, "Failed to handle file delete: #{e}\n"
end
end
Untitled Ruby (21-Jan @ 13:26)
Syntax Highlighted Code
- # calculate duration
- if duration > 0 then
- end_date = "'now() + interval \'1 day\''"
- else
- [17 more lines...]
Plain Code
# calculate duration
if duration > 0 then
end_date = "'now() + interval \'1 day\''"
else
end_date=nil
end
puts "insertion de #{target}"
DB[:network_filter].insert(
:network => target,
:hardblock => bgp,
:explanation_id => 1,
:custom_message => message,
:start_date => nil,
:end_date => end_date,
:state => 1,
:cause_id => 1,
:cause => cause,
:contact => contact,
:removal_cause => '')
Untitled Ruby (20-Jan @ 21:35)
Syntax Highlighted Code
- receive_data: "CONNECT"
- receive_data: "\n"
- receive_data: "login:rip"
- receive_data: "\n"
- [22 more lines...]
Plain Code
receive_data: "CONNECT"
receive_data: "\n"
receive_data: "login:rip"
receive_data: "\n"
receive_data: "content-length:0"
receive_data: "\n"
receive_data: "passcode:xxx"
receive_data: "\n"
receive_data: "content-type: text/plain; charset=UTF-8"
receive_data: "\n"
receive_data: "\n"
receive_data: "\000"
Connecting
Sending frame CONNECTED
session:wow
receive_data: "SUBSCRIBE"
receive_data: "\ndestination:/topic/meh\ncontent-length:0\ncontent-type: text/plain; charset=UTF-8\n\n\000"
receive_data: "SEND\ndestination:/topic/meh\ncontent-length:5\ncontent-type: text/plain; charset=UTF-8\n\nhello\000"
Sending frame MESSAGE
message-id:msg-#stompcma-1
content-type:text/plain; charset=UTF-8
destination:/topic/meh
content-length:5
hello
Untitled Ruby (19-Jan @ 15:01)
Syntax Highlighted Code
- packagename = case node[:platform]
- when "debian" then "snmpd"
- when "freebsd" then "net-snmp"
- end
- [6 more lines...]
Plain Code
packagename = case node[:platform]
when "debian" then "snmpd"
when "freebsd" then "net-snmp"
end
package packagename do
action :install
if node[:platform] == "freebsd" then
source "ports"
end
end
Untitled Ruby (19-Jan @ 10:35)
Syntax Highlighted Code
- # handle debian flooding the logs
- if node[:platform] == "debian" then
- cookbook_file "snmpd_default" do
- [4 more lines...]
Plain Code
# handle debian flooding the logs
if node[:platform] == "debian" then
cookbook_file "snmpd_default" do
path "/etc/default/snmpd"
source "debian-default"
notifies :restart, "service[snmpd]", :immediatly
end
end
Untitled Ruby (18-Jan @ 18:34)
Syntax Highlighted Code
- >> rpc(:list, :pattern => "init") {|r| pp r}
- #<MCollective::RPC::Result:0xb7e881b0
- @action="list",
- @agent="process",
- [62 more lines...]
Plain Code
>> rpc(:list, :pattern => "init") {|r| pp r}
#<MCollective::RPC::Result:0xb7e881b0
@action="list",
@agent="process",
@results=
{:statusmsg=>"OK",
:data=>
{:pslist=>
[{:flags=>4194560,
:processor=>0,
:session=>1,
:cminflt=>185351732,
:euid=>0,
:rt_priority=>0,
:tty_nr=>0,
:kstkeip=>14746626,
:cutime=>417813,
:wchan=>0,
:endcode=>134544728,
:blocked=>0,
:utime=>0,
:name=>"init",
:uid=>0,
:egid=>0,
:cmdline=>"init [3]",
:startstack=>3219631088,
:username=>"root",
:signal=>0,
:ppid=>0,
:majflt=>18,
:cstime=>156676,
:vsize=>2228224,
:tpgid=>-1,
:cmajflt=>6610,
:gid=>0,
:nswap=>0,
:minflt=>1075,
:sigignore=>1475401980,
:pid=>1,
:cwd=>"/",
:comm=>"init",
:sigcatch=>671819267,
:environ=>
{"TERM"=>"linux",
"SELINUX_INIT"=>"YES",
"HOME"=>"/",
"PATH"=>"/bin:/usr/bin:/sbin:/usr/sbin"},
:rss=>151,
:nice=>0,
:cnswap=>0,
:policy=>0,
:itrealvalue=>0,
:starttime=>16,
:exit_signal=>0,
:pgrp=>1,
:exe=>"/sbin/init",
:rlim=>4294967295,
:state=>"S",
:kstkesp=>3219629772,
:stime=>8,
:priority=>15,
:fd=>{"10"=>"/dev/initctl"},
:startcode=>134512640,
:root=>"/"}]},
:statuscode=>0}>
Finished processing 1 / 1 hosts in 120.47 ms
Untitled Ruby (18-Jan @ 13:48)
Syntax Highlighted Code
- module MCollective
- module Agent
- # An agent that uses Opscode to manage services
- # Made from the puppet version
- [51 more lines...]
Plain Code
module MCollective
module Agent
# An agent that uses Opscode to manage services
# Made from the puppet version
class Service<RPC::Agent
metadata :name => "SimpleRPC Service Agent",
:description => "Agent to manage services",
:author => "R.I.Pienaar",
:license => "GPLv2",
:version => "1.2",
:url => "http://mcollective-plugins.googlecode.com/",
:timeout => 60
["stop", "start", "restart"].each do |act|
action act do
do_service_action(act)
end
end
private
# Does the actual work with the chef provider and sets appropriate reply options
def do_service_action(action)
validate :service, String
service = request[:service]
require 'chef'
require 'chef/client'
require 'chef/run_context'
begin
Chef::Config[:solo] = true
Chef::Config[:log_level] = :debug
Chef::Log.level(:debug)
client = Chef::Client.new
client.run_ohai
client.build_node
run_context = Chef::RunContext.new(client.node, Chef::CookbookCollection.new(Chef::CookbookLoader.new))
recipe = Chef::Recipe.new("adhoc", "default", run_context)
resource = recipe.send(:service, service)
resource.send("action",action)
Log.instance.debug("Doing '#{action}' for service '#{service}'")
Chef::Runner.new(run_context).converge
reply["status"] = true
rescue Exception => e
reply.fail "#{e}"
end
end
end
end
end
# vi:tabstop=4:expandtab:ai:filetype=ruby
Untitled Ruby (18-Jan @ 09:36)
Syntax Highlighted Code
- munin.mc:
- inventory do
- format "[%s;%s]\n\taddress %s\n\n"
- [12 more lines...]
Plain Code
munin.mc:
inventory do
format "[%s;%s]\n\taddress %s\n\n"
fields { [ facts["location"], identity, facts["ipaddress"] ] }
end
% mc-inventory --script munin.mc
[hetzner;xen3.xx.net]
address 213.x.x.x
[hetzner;ns1.yy.net]
address 78.x.x.x
Untitled Ruby (18-Jan @ 09:10)
Syntax Highlighted Code
- class MCollective::Application::Facts<MCollective::Application
- description "Reports on usage for a specific fact"
- # this will be available in configuration[:fact]
- [51 more lines...]
Plain Code
class MCollective::Application::Facts<MCollective::Application
description "Reports on usage for a specific fact"
# this will be available in configuration[:fact]
option :script,
:description => "Fact to report on",
:arguments => ["--fact FACT", "-f FACT"]
def post_option_parser(configuration)
configuration[:fact] = ARGV.shift if ARGV.size > 0
end
def validate_configuration(configuration)
raise "Please specify a fact to report for" unless configuration.include?(:fact)
end
def show_single_fact_report(fact, facts, verbose=false)
puts("Report for fact: #{fact}\n\n")
facts.keys.sort.each do |k|
printf(" %-40sfound %d times\n", k, facts[k].size)
if verbose
puts
facts[k].sort.each do |f|
puts(" #{f}")
end
puts
end
end
end
def main
rpcutil = rpcclient("rpcutil", :options => options)
rpcutil.progress = false
facts = {}
rpcutil.get_fact(:fact => configuration[:fact]) do |resp|
begin
value = resp[:body][:data][:value]
if value
facts.include?(value) ? facts[value] << resp[:senderid] : facts[value] = [ resp[:senderid] ]
end
rescue Exception => e
STDERR.puts "Could not parse facts for #{resp[:senderid]}: #{e.class}: #{e}"
end
end
show_single_fact_report(configuration[:fact], facts, options[:verbose])
printrpcstats
end
end
Untitled Ruby (16-Jan @ 21:02)
Syntax Highlighted Code
- class nagios::hostgroup::activemq_servers {
- $nodes = search_nodes("{'classes' => 'activemq', 'facts.monitors' => /${fqdn}/}")
- if $nodes != [] {
- [5 more lines...]
Plain Code
class nagios::hostgroup::activemq_servers {
$nodes = search_nodes("{'classes' => 'activemq', 'facts.monitors' => /${fqdn}/}")
if $nodes != [] {
nagios::hostgroup{"activemq_servers":
nodes => $nodes,
description => "ActiveMQ Servers"
}
}
}
Untitled Ruby (14-Jan @ 13:03)
Syntax Highlighted Code
- #!/usr/bin/ruby
- require 'mcollective'
- [15 more lines...]
Plain Code
#!/usr/bin/ruby
require 'mcollective'
include MCollective::RPC
rpc = rpcclient("puppetd")
enabled = running = 0
rpc.status do |resp|
begin
enabled += resp[:body][:data][:enabled]
running += resp[:body][:data][:running]
rescue Exception => e
STDERR.puts "Failed to get results: #{e}"
end
end
puts "enabled: #{enabled} runnig: #{running}"
Untitled Ruby (14-Jan @ 09:17)
Syntax Highlighted Code
- ====================
- #<Stomp::Message:0xb7e3d8e0
- @body=
- "{\"ConnectionInfo\": {\n \"commandId\": 0,\n \"responseRequired\": true,\n \"connectionId\": {\n \"value\": \"ID:xx.xx.net-57901-1294599217160-5:3943\"\n },\n \"clientId\": \"ID:xx.xx.net-57901-1294599217160-5:3943\",\n \"userName\": \"\",\n \"password\": \"\",\n \"brokerMasterConnector\": false,\n \"manageable\": false,\n \"clientMaster\": true,\n \"faultTolerant\": false,\n \"failoverReconnect\": false\n}}",
- [14 more lines...]
Plain Code
====================
#<Stomp::Message:0xb7e3d8e0
@body=
"{\"ConnectionInfo\": {\n \"commandId\": 0,\n \"responseRequired\": true,\n \"connectionId\": {\n \"value\": \"ID:xx.xx.net-57901-1294599217160-5:3943\"\n },\n \"clientId\": \"ID:xx.xx.net-57901-1294599217160-5:3943\",\n \"userName\": \"\",\n \"password\": \"\",\n \"brokerMasterConnector\": false,\n \"manageable\": false,\n \"clientMaster\": true,\n \"faultTolerant\": false,\n \"failoverReconnect\": false\n}}",
@command="MESSAGE",
@headers=
{"timestamp"=>"0",
"message-id"=>
"ID:xx.xx.net-57901-1294599217160-2:0:0:0:63185",
"expires"=>"0",
"destination"=>"/topic/ActiveMQ.Advisory.Connection",
"priority"=>"0",
"type"=>"Advisory",
"originBrokerURL"=>"tcp://xx.xx.net:6166",
"originBrokerId"=>"ID:xx.xx.net-57901-1294599217160-0:0",
"originBrokerName"=>"xx-xx"},
@original=
"MESSAGE\nmessage-id:ID:xx.xx.net-57901-1294599217160-2:0:0:0:63185\noriginBrokerName:xx-xx\ntype:Advisory\ndestination:/topic/ActiveMQ.Advisory.Connection\ntimestamp:0\nexpires:0\npriority:0\noriginBrokerURL:tcp://xx.xx.net:6166\noriginBrokerId:ID:xx.xx.net-57901-1294599217160-0:0\n\n{\"ConnectionInfo\": {\n \"commandId\": 0,\n \"responseRequired\": true,\n \"connectionId\": {\n \"value\": \"ID:xx.xx.net-57901-1294599217160-5:3943\"\n },\n \"clientId\": \"ID:xx.xx.net-57901-1294599217160-5:3943\",\n \"userName\": \"\",\n \"password\": \"\",\n \"brokerMasterConnector\": false,\n \"manageable\": false,\n \"clientMaster\": true,\n \"faultTolerant\": false,\n \"failoverReconnect\": false\n}}\000">
====================
Untitled Ruby (13-Jan @ 15:41)
Syntax Highlighted Code
- class ipsec::servers::monitor1 {
- $clients = search_nodes("{'classes' => 'ipsec::endpoint::monitor1'}")
- ipsec::endpoints_from_nodes{$clients: }
- [20 more lines...]
Plain Code
class ipsec::servers::monitor1 {
$clients = search_nodes("{'classes' => 'ipsec::endpoint::monitor1'}")
ipsec::endpoints_from_nodes{$clients: }
}
define ipsec::endpoints_from_nodes {
$node = load_node($name)
ipsec::endpoint{$node["fqdn"]:
dest => $node["facts"]["ipaddress"]
}
}
define ipsec::endpoint($dest, $ensure = "present", $mode = "transport") {
$safe_name = regsubst($name, '-', '_', 'G')
file{"/etc/sysconfig/network-scripts/ifcfg-ipsec.${safe_name}":
owner => root,
group => root,
mode => 644,
ensure => $ensure,
content => template("ipsec/${mode}-mode-endpoint.erb")
}
}
Untitled ActionScript (13-Jan @ 11:30)
Syntax Highlighted Code
- #!/usr/bin/ruby
- require 'mcollective'
- [6 more lines...]
Plain Code
#!/usr/bin/ruby
require 'mcollective'
include MCollective::RPC
rpc = rpcclient("rpcutil")
rpc.get_fact(:fact => "foo").each do |resp|
puts "%40s: %s %s" % [ resp[:sender], resp[:statuscode], resp[:statusmsg]]
end
Untitled Ruby (13-Jan @ 02:57)
Syntax Highlighted Code
- define ipsec::endpoints_from_nodes {
- $node = load_node($name)
- ipsec::endpoint{$node["fqdn"]:
- [8 more lines...]
Plain Code
define ipsec::endpoints_from_nodes {
$node = load_node($name)
ipsec::endpoint{$node["fqdn"]:
dest => $node["facts"]["ipaddress"]
}
}
class ipsec::servers::monitor1 {
$clients = search_nodes("{'classes' => 'ipsec::endpoint::monitor1'}")
ipsec::endpoints_from_nodes{$clients: }
}
Untitled Ruby (13-Jan @ 02:34)
Syntax Highlighted Code
- class ipsec::servers::monitor1 {
- $clients = search_nodes("{'classes' => 'ipsec::endpoint::monitor1'}")
- ipsec::endpoints_from_nodes{$clients: }
- [8 more lines...]
Plain Code
class ipsec::servers::monitor1 {
$clients = search_nodes("{'classes' => 'ipsec::endpoint::monitor1'}")
ipsec::endpoints_from_nodes{$clients: }
}
define ipsec::endpoints_from_nodes {
$node = load_node($name)
ipsec::endpoint{$node["facts"]["fqdn"]:
dest => $node["facts"]["ipaddress"]
}
}
Untitled Ruby (9-Dec @ 09:50)
Syntax Highlighted Code
- # traditional ways
- "a : bcd(1234: xyz)".gsub(/(\(\w*:)( )(\w*\))/, '\1ijk\3')
- [1 more lines...]
Plain Code
# traditional ways
"a : bcd(1234: xyz)".gsub(/(\(\w*:)( )(\w*\))/, '\1ijk\3')
# look-behind assertions
"a : bcd(1234: xyz)".gsub(/(?<=\w:) /, 'ijk')
Untitled Ruby (5-Oct @ 14:57)
Syntax Highlighted Code
- require 'net/http'
- require 'hpricot'
- require 'rss/maker'
- require 'uri'
- [61 more lines...]
Plain Code
require 'net/http'
require 'hpricot'
require 'rss/maker'
require 'uri'
class EMB
attr_writer :realm, :user, :password
def initialize ( realm = 'chs_programming', user='zichun', password='paksux' )
@realm, @user, @password = realm, user, password
@cookies = []
@cookie_string = ''
end
def get_cookie
http = Net::HTTP.new('smb.chs.edu.sg', 80)
resp,data = http.post('/cgi-bin/emb/login.pl',
"userid=#{@user}&password=#{@password}&login=+++Login+++",
{'referer'=>'http://smb.chs.edu.sg/emb/'+@realm+'/',
'user_agent'=>'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9) Gecko/2008051206 Firefox/3.0'
})
resp.get_fields('set-cookie').each { |x|
@cookies << x
@cookie_string += x.split("\; ")[0] + "\;"
}
@cookie_string
end
def get_main
http = Net::HTTP.new('smb.chs.edu.sg', 80)
http.get('/cgi-bin/emb/view.pl?date', {'Cookie'=>@cookie_string})
end
def get_msg (link)
url = URI.parse(link)
http = Net::HTTP.new('smb.chs.edu.sg',80)
http.get( url.path+'?'+url.query, {'Cookie'=>@cookie_string} )
end
end
emb_client = EMB.new
emb_client.get_cookie
res = emb_client.get_main
version = "2.0"
content = RSS::Maker.make(version) { |m|
m.channel.title = "EMB CHS_PROGRAMMING"
m.channel.link = "http://smb.chs.edu.sg/emb/chs_programming"
m.channel.description = "Extracted messages from chs_programming EMB"
m.items.do_sort = true
doc = Hpricot(res.body)
for i in 2...(doc/"form").length
item = m.items.new_item
x = (doc/"form")[i]
item.title = (x/"a").text
item.link = "http://smb.chs.edu.sg/emb/chs_programming/"
item.date = Time.parse(((x/"font")[0]).innerHTML.strip)
emb_body = Hpricot(emb_client.get_msg( x.at("a")['href'] ).body)
item.description = emb_body.at("pre")
item.author = (x/"td")[2].innerHTML.strip
end
}
$stdout.write(content)
Untitled Ruby (30-Sep @ 09:13)
Syntax Highlighted Code
- require 'rubygems'
- require 'sinatra'
- [34 more lines...]
Plain Code
require 'rubygems'
require 'sinatra'
get '/' do
haml <<END
!!!
%html
%head
%title Greetings
%body
%p Prepare to be greeted
%form{:action => 'hello', :method => 'post'}
%input{:type => 'text', :name => 'name'}
%input{:type => 'submit', :value => 'Greet'}
END
end
get '/hello/:name' do
greet(params[:name])
end
post '/hello' do
greet(params[:name])
end
private
def greet(name)
haml <<END
!!!
%html
%head
%title Greetz
%body
%h1 Heya!
%p= "Hello <em> #{name} </em>"
END
end
Untitled Ruby (21-Sep @ 22:20)
Syntax Highlighted Code
- puts "hello World"
Plain Code
puts "hello World"
Untitled Ruby (13-Sep @ 23:31)
Syntax Highlighted Code
- puts "hola que tal?"
Plain Code
puts "hola que tal?"
Untitled Ruby (27-Aug @ 10:05)
Syntax Highlighted Code
- p = ['a', 'b', 'c']
- p.each do |item|
- puts item
- end
Plain Code
p = ['a', 'b', 'c']
p.each do |item|
puts item
end
Untitled Ruby (28-Jul @ 10:22)
Syntax Highlighted Code
- before :deploy, "solr:stop"
- after :deploy, "solr:start"
Plain Code
before :deploy, "solr:stop"
after :deploy, "solr:start"
Untitled Ruby (4-Jul @ 09:50)
Syntax Highlighted Code
- a = String.new
- puts a.methods
Plain Code
a = String.new
puts a.methods
Untitled Ruby (18-Jun @ 21:58)
Syntax Highlighted Code
- class Carro
- def initialize
- [2 more lines...]
Plain Code
class Carro
def initialize
end
end
Untitled Ruby (28-May @ 10:32)
Syntax Highlighted Code
- class Example
- def foo
- put 'bar'
- end
- end
Plain Code
class Example
def foo
put 'bar'
end
end
Untitled Ruby (27-May @ 22:53)
Syntax Highlighted Code
- a = 123
- b = 123
- puts a + b
Plain Code
a = 123
b = 123
puts a + b
Untitled Ruby (12-May @ 08:05)
Syntax Highlighted Code
- include "hpricot"
Plain Code
include "hpricot"
Untitled Ruby (10-May @ 10:48)
Syntax Highlighted Code
- def test
- :foo => "bar"
- end
Plain Code
def test
:foo => "bar"
end