voxpupuli / hiera-eyaml

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

How to setup hiera-eyaml for puppet masterless windows servers? #203

Open goutham27 opened 8 years ago

goutham27 commented 8 years ago

Hi,

I am trying to setup hiera-eyaml for our puppet -masterless windows servers. Could you pls let me know how to set it up?

So far I have installed the gem using puppet packaged ruby, created keys added them to hiera.yaml file But it is not working when i ran puppet-apply..it just copies the encrypted value it doesn't decrypt it.

    ---
:backends:
  - eyaml
  - yaml
:hierarchy:
  - "%{::clientcert}"
  - "%{::osfamily}"
:logger: console
:yaml:
  :datadir: data
:eyaml:
  :datadir: data
  :pkcs7_private_key: keys/private_key.pkcs7.pem
  :pkcs7_public_key: keys/public_key.pkcs7.pem
  :extension: 'yaml'
ncjones commented 8 years ago

I got stuck for nearly a day with the same symptoms for masterless Puppet on Linux. Here are some of the things to look out for:

If this is still not working then it helps to use puppet apply with the --debug flag. If still no insights then it's time to get out the debugger. Install pry and pry-byebug gems:

/opt/puppetlabs/puppet/bin/gem install pry pry-byebug

Then set your breakpoint by adding the following to line the "hiera_config" function (line 59 of "/opt/puppetlabs/puppet/lib/ruby/vendor_ruby/hiera_puppet.rb"):

require 'pry'
binding.pry

Next time you run puppet apply you'll hit the breakpoint in the pry repl. You can use the pry-byebug commands to control the debugger (eg, "step", "next", "continue", "up", "down") and use pry as normal to inspect variable state.

petemounce commented 7 years ago

For future googlers, I was able to install hiera-eyaml on Windows into puppet's vendored ruby by

Invoke-WebRequest 'https://raw.githubusercontent.com/rubygems/rubygems/master/lib/rubygems/ssl_certs/index.rubygems.org/GlobalSignRootCA.pem' -UseBasicParsing -OutFile 'GlobalSignRootCA.pem'
$ruby_gems_location = & 'C:\Program Files\Puppet Labs\Puppet\sys\ruby\bin\gem.bat' which rubygems | split-path
mv "GlobalSignRootCA.pem" "$ruby_gems_location/rubygems/ssl_certs"

& 'C:\Program Files\Puppet Labs\Puppet\sys\ruby\bin\gem.bat' install --no-ri --no-rdoc hiera-eyaml

I install puppet-agent 4.10.2 for Windows, which comes with a version of rubygems that doesn't have the GlobalSignRootCA cert, and the manual instructions at http://guides.rubygems.org/ssl-certificate-update/#installing-using-update-packages are basically what the first few lines of script do.

If you're not using puppet, dear future reader, your ruby will be in a different place than puppet's vendored one.

manheraz commented 6 years ago

Thank you, @petemounce!

My setup:

In my case, the last line was the only one required to install hiera-eyaml:

& 'C:\Program Files\Puppet Labs\Puppet\sys\ruby\bin\gem.bat' install --no-ri --no-rdoc hiera-eyaml

It should be executed from an elevated (with administrator privileges) PowerShell shell.