It would be great if chef-dk gem will include prepared Rake tasks allowing to run chef update / chef push for bunch of Policyfiles.
Currently I use the following blocks in my custom Rakefile in order to run chef update for all files in ./policyfiles/*.rb:
require 'chef-dk/cli'
namespace :policyfile do
desc 'Run "chef update" for all files `policies/*.rb`'
task :update do
Dir.glob('policies/*.rb').each do |file|
cli = ChefDK::CLI.new(['update', file])
subcommand_name, *subcommand_params = cli.argv
subcommand = cli.instantiate_subcommand(subcommand_name)
subcommand.run_with_default_options(subcommand_params)
end
end
desc 'Run "chef update -a" for all files `policies/*.rb`'
task :update_a do
Dir.glob('policies/*.rb').each do |file|
cli = ChefDK::CLI.new(['update', '-a', file])
subcommand_name, *subcommand_params = cli.argv
subcommand = cli.instantiate_subcommand(subcommand_name)
subcommand.run_with_default_options(subcommand_params)
end
end
end
It would be great if
chef-dkgem will include prepared Rake tasks allowing to runchef update/chef pushfor bunch of Policyfiles.Currently I use the following blocks in my custom
Rakefilein order to runchef updatefor all files in./policyfiles/*.rb: