require 'mixlib/shellout' require 'logger' module Ruby module Terraform module ExecutionSupport def execute(opts = {}) working_dir = opts[:dir] || (self.dir if self.respond_to?(:dir)) shellout_opts = {} shellout_opts[:cwd] = working_dir if working_dir if opts[:live] shellout_opts[:live_stdout] = STDOUT shellout_opts[:live_stderr] = STDERR end if opts[:show_command] formatter = proc do |severity, datetime, progname, msg| "#{msg}\n" end shellout_opts[:logger] = Logger.new(STDERR, formatter: formatter) end cmd = Mixlib::ShellOut.new(command, shellout_opts) cmd.run_command cmd.error! end def tf_binary executable = Executable.new executable.download executable.extract executable.binary end end end end