Skip to content

Instantly share code, notes, and snippets.

@a4h8
Forked from dayne/README.md
Last active June 26, 2021 03:22
Show Gist options
  • Select an option

  • Save a4h8/c39df10361da23abe1d21f4d06af6b74 to your computer and use it in GitHub Desktop.

Select an option

Save a4h8/c39df10361da23abe1d21f4d06af6b74 to your computer and use it in GitHub Desktop.
Cowsay Fortunes

Chef essentials training result

... a cowsay fortune tool

Requirements

Dependencies

  • cowsay
  • fortune
  • lolcat Setup's
  • ruby
  • chef-client

installing (on your chef essentials vm)

curl the silly moo.rb recipe file

curl -o moo.rb https://gist.github.com/a4h8/c39df10361da23abe1d21f4d06af6b74/raw/moo.rb*

chef client local mode install it and try it out:

sudo chef-client -z moo.rb 
cowfortune 

usage

cowfortune -h cowfortune help menu

Forked from

https://gist.github.com/dayne

#!/usr/bin/env ruby
# cowsay files directory change it to your own.
$cowfiles = Dir.glob('/usr/share/cows/*.cow').collect{ |i| File.basename(i, '.cow') }
def cowfortune
cf = $cowfiles[rand($cowfiles.size)]
fortune = `fortune`
lolcat = `lolcat`
`cowsay -f #{cf} \`fortune\``
end
if ARGV.delete("-l")
loop do
system('clear')
cowfortune
sleep 5
end
elsif ARGV.delete("-c")
puts `cowfortune | lolcat`
elsif ARGV.delete("-ca")
puts `cowfortune | lolcat -a`
elsif ARGV.delete("--help")
puts "cowfortune help menu. \n"
puts " cowfortune to get a random cow type with random fortune. \n"
puts " -l to give yourself a looping cowfortune."
puts " -c random cowsay and colored content with lolcat."
puts " -ca animated random cowsay and colored content with lolcat."
puts " -h or --help for help."
exit
else
puts `cowfortune`
end
#!/usr/bin/env ruby
# chef cookbook to install cowsay, fortune, and cowfortune
[ 'cowsay', 'fortune-mod', 'ruby' ].each { |p| package p }
gem_package 'sinatra'
remote_file '/usr/local/bin/cowfortune' do
source 'https://gist.github.com/a4h8/c39df10361da23abe1d21f4d06af6b74/raw/cowfortune.rb'
mode '0755'
owner 'chef'
group `chef`
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment