Skip to content

Instantly share code, notes, and snippets.

@thomasbiddle
Created October 22, 2012 23:24
Show Gist options
  • Save thomasbiddle/3935444 to your computer and use it in GitHub Desktop.
Save thomasbiddle/3935444 to your computer and use it in GitHub Desktop.
Librarian-Puppet Rake Task for Templating the Puppetfile
#!/usr/bin/ruby
require 'erb'
desc "Templates the Puppetfile to the specified environment"
task :template_puppetfile, [:env] do |t, args|
unless args[:env].nil?
@environment = args[:env]
read_file = 'Puppetfile.erb'
write_file = 'Puppetfile'
erb = ERB.new(File.read(read_file))
File.open(write_file, 'w') { |file| file.write(erb.result) }
else
puts "An environment must be specified."
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment