Skip to content

Instantly share code, notes, and snippets.

@nibalizer
Created May 28, 2012 15:12
Show Gist options
  • Select an option

  • Save nibalizer/2819655 to your computer and use it in GitHub Desktop.

Select an option

Save nibalizer/2819655 to your computer and use it in GitHub Desktop.
fizzbuzz
$foo = inline_template('<%= (1..100).to_a.join(" ")%>')
$foo2 = inline_template("<%= (1..100).to_a.each { | n | if n % 15 == 0 then 'fizzbuzz' elsif n % 5 == 0 then 'buzz' elsif n % 3 == 0 then 'fizz' else n end }%>")
notify {
"Fizzaaaa":
message => $foo,
}
$things = split($foo, ' ')
file {
'fizzbuzz-sleepsort.py':
mode => 777,
path => '/tmp/fizzbuzz-sleepsort.py',
content => "#!/usr/bin/python\n\nimport time\nimport sys\n\nnum = int(sys.argv[1])\ntime.sleep(0)\n\nif num % 15 == 0:\n print 'fizzbuzz'\nelif num % 5 == 0:\n print 'buzz'\nelif num % 3 == 0:\n print 'fizz'\nelse:\n print num",
}
define hai {
$quotient = $title
exec {
"$quotient-$name":
command => "/tmp/fizzbuzz-sleepsort.py $title",
logoutput => true,
require => File['fizzbuzz-sleepsort.py'],
}
}
hai { $things: }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment