voxpupuli / hiera-eyaml

A backend for Hiera that provides per-value asymmetric encryption of sensitive data
MIT License
529 stars 131 forks source link

Parsing of encrypted hiera from raw ruby #262

Open sergii-zemlianyi opened 6 years ago

sergii-zemlianyi commented 6 years ago

Dear all,

We are using a set of ruby+capistrano scripts altogether with hiera to run deployments . Currently we intend to start using eyaml backend. This is what I have: here I just initialize eyaml backend and load keys from eyaml files. Backend.datasourcefiles(:eyaml, scope, 'eyaml', Config[:hierarchy]) do |source, yamlfile| data = @cache.read_file(yamlfile) do |chunk| YAML.load(chunk) || {} end ...

So my first question is: should I then call the following method to decrypt values? new_answer = parse_answer(data, scope)

if I do so I get the following error

/usr/local/rvm/gems/ruby-1.9.3-p551/gems/hiera-eyaml-2.1.0/lib/hiera/backend/eyaml/encryptors/pkcs7.rb:51:in decrypt': undefined local variable or methodprivate_key' for Hiera::Backend::Eyaml::Encryptors::Pkcs7:Class (NameError)

I believe this is cause Hiera::Backend::Eyaml::Encryptor.option method returns a full hash @@options rather than single private_key value

if all above doesn't make sense which method should I pass my encrypted data into?

Thanks a lot in advance, Sergey

spuder commented 4 years ago

Did you ever find a solution to how to use hiera-eyaml in a ruby script?

This may help https://github.com/voxpupuli/hiera-eyaml/issues/153