diff --git a/CHANGELOG.adoc b/CHANGELOG.adoc index 48ff116..6247662 100644 --- a/CHANGELOG.adoc +++ b/CHANGELOG.adoc @@ -1,5 +1,12 @@ = Changelog +== 1.7.0 + + * feat: added a `-p` flag to configure parallelism + * feat: enhanced the executor output when raising `Tfctl::Error`, it will now + report the `account_name` that raised the error along with the full command + that was being run + == 1.6.1 * fix: pagination problem when listing accounts in an OU. diff --git a/bin/tfctl b/bin/tfctl index e14103b..9dd1879 100755 --- a/bin/tfctl +++ b/bin/tfctl @@ -26,6 +26,7 @@ options = { unbuffered: false, debug: false, use_cache: false, + parallelism: 8, } optparse = OptionParser.new do |opts| @@ -56,6 +57,9 @@ optparse = OptionParser.new do |opts| opts.on('-d', '--debug', 'Turn on debug messages') do options[:debug] = true end + opts.on('-p', '--parallelism=num', 'How many terraform processes to execute in parallel') do |o| + options[:parallelism] = o.to_i + end opts.on('-v', '--version', 'Show version') do puts Tfctl::VERSION exit @@ -93,7 +97,7 @@ begin raise OptionParser::InvalidOption, 'Please specify target' end rescue OptionParser::InvalidOption, OptionParser::MissingArgument - warn $ERROR_INFO.to_s + warn $ERROR_INFO warn optparse exit 2 end @@ -202,7 +206,7 @@ begin # Execute Terraform in target accounts - Parallel.each(accounts, in_processes: 8) do |ac| + Parallel.each(accounts, in_processes: options[:parallelism]) do |ac| run_account(config, ac, options, ARGV, log) end diff --git a/lib/tfctl/executor.rb b/lib/tfctl/executor.rb index df71319..b199e4f 100644 --- a/lib/tfctl/executor.rb +++ b/lib/tfctl/executor.rb @@ -88,7 +88,7 @@ def run(account_name:, config_name:, log:, cmd: nil, argv: [], unbuffered: true) FileUtils.rm_f plan_file if args[0] == 'apply' # tidy up the plan file unless status.exitstatus.zero? - raise Tfctl::Error, "#{cmd} failed with exit code: #{status.exitstatus}" + raise Tfctl::Error, "#{account_name}: #{runcmd} failed with exit code: #{status.exitstatus}" end end end diff --git a/lib/tfctl/version.rb b/lib/tfctl/version.rb index 5187e6f..a6c8ee2 100644 --- a/lib/tfctl/version.rb +++ b/lib/tfctl/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module Tfctl - VERSION = '1.6.1' + VERSION = '1.7.0' end