Skip to content
This repository has been archived by the owner on Jul 14, 2021. It is now read-only.

Proposal: Create Rake tasks for running bunch jobs with Policyfiles #684

Open
legal90 opened this issue Feb 16, 2016 · 0 comments
Open

Proposal: Create Rake tasks for running bunch jobs with Policyfiles #684

legal90 opened this issue Feb 16, 2016 · 0 comments
Labels
Components: Policyfile Issues realted to Policyfiles

Comments

@legal90
Copy link

legal90 commented Feb 16, 2016

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
@cheeseplus cheeseplus added the Components: Policyfile Issues realted to Policyfiles label Aug 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Components: Policyfile Issues realted to Policyfiles
Development

No branches or pull requests

2 participants