Module: Hiera::Backend::Eyaml::GpgPuppetserver

Extended by:
RubyGpg
Defined in:
lib/hiera/backend/eyaml/encryptors/gpg/puppet_gpg.rb

Class Method Summary collapse

Class Method Details

.run_command(command, input = nil) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/hiera/backend/eyaml/encryptors/gpg/puppet_gpg.rb', line 11

def self.run_command(command, input = nil)
  tmpfile = Puppet::FileSystem::Uniquefile.new('puppet-eyaml-hiera-gpg-input', modes: File::WRONLY | File::BINARY)
  tmpfile.write(input)
  tmpfile.close

  real_command = "#{command} #{tmpfile.path}"

  output = Puppet::Util::Execution.execute(real_command, combine: false, failonfail: true)
  tmpfile.unlink

  if output.exitstatus != 0
    raise "GPG command (#{real_command}) failed with status #{output.exitstatus}: '#{output}'"
  end

  output
end