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

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

@legal90

Description

@legal90

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions