crayfishx / hiera-gpg

GPG Backend to HIera
http://github.com/crayfishx/hiera-gpg
Other
101 stars 25 forks source link

Also issues with undefined method `empty? #24

Open berndmweber opened 11 years ago

berndmweber commented 11 years ago

Hey,

Don't seem to be able to get this to work. I read the earlier bug report but that didn't seem to solve my problems. I changed the owner of /etc/puppet/gpgdata to puppet and made sure the permissions are 750 on the directory and 640 on all files inside. When I execute hiera -d -c hiera.yaml mysql:server:root_passwd either as root or puppet I get the correct value back:

/etc/puppet$ sudo hiera -d -c hiera.yaml mysql:server:root_passwd
DEBUG: Wed May 08 21:34:11 +0000 2013: Hiera YAML backend starting
DEBUG: Wed May 08 21:34:11 +0000 2013: Looking up mysql:server:root_passwd in YAML backend
DEBUG: Wed May 08 21:34:11 +0000 2013: Looking for data source passwords
DEBUG: Wed May 08 21:34:11 +0000 2013: Data retrieved from /etc/puppet/hieradata/passwords.yaml is not a Hash, setting defaults
DEBUG: Wed May 08 21:34:11 +0000 2013: Looking for data source common
DEBUG: Wed May 08 21:34:11 +0000 2013: Data retrieved from /etc/puppet/hieradata/common.yaml is not a Hash, setting defaults
DEBUG: Wed May 08 21:34:11 +0000 2013: [gpg_backend]: Loaded gpg_backend
DEBUG: Wed May 08 21:34:11 +0000 2013: [gpg_backend]: Lookup called, key mysql:server:root_passwd resolution type is priority
DEBUG: Wed May 08 21:34:11 +0000 2013: [gpg_backend]: GNUPGHOME is /etc/puppet/gpgdata
DEBUG: Wed May 08 21:34:11 +0000 2013: [gpg_backend]: loaded cipher: /etc/puppet/hieradata/gpgdata/passwords.gpg
DEBUG: Wed May 08 21:34:11 +0000 2013: [gpg_backend]: result is a String ctx #<GPGME::Ctx:0x7fbe72436df8> txt ---
mysql:server:root_passwd: jona123
DEBUG: Wed May 08 21:34:11 +0000 2013: [gpg_backend]: GPG decrypt returned valid data
DEBUG: Wed May 08 21:34:11 +0000 2013: [gpg_backend]: Data contains valid YAML
DEBUG: Wed May 08 21:34:11 +0000 2013: [gpg_backend]: Key mysql:server:root_passwd found in YAML document, Passing answer to hiera
DEBUG: Wed May 08 21:34:11 +0000 2013: [gpg_backend]: Assigning answer variable
jona123

Whenever I try to run this through the puppet agent it fails:

...
Info: Loading facts in /var/lib/puppet/lib/facter/pe_version.rb
Debug: catalog supports formats: b64_zlib_yaml dot pson raw yaml; using pson
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Puppet::Parser::AST::Resource failed with error NoMethodError: undefined method `empty?' for #<Puppet::Util::Log:0x7fefea8fe558> at /etc/puppet/manifests/site.pp:18 on node ip-10-250-6-39.us-west-2.compute.internal
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
Debug: Value of 'preferred_serialization_format' (pson) is invalid for report, using default (b64_zlib_yaml)
Debug: report supports formats: b64_zlib_yaml raw yaml; using b64_zlib_yaml

I'm wondering if I'm even installing this correctly. I used gem install hiera-gpg. I can see it and the hiera gem fine in the /var/lig/gems directory. But I'm suspecting that puppet is using it's own hiera version in /usr/lib/ruby/vendor_ruby ?! Which would explain the issues I'm seeing.

Some more information: hiera.yaml:


---
:backends:
  - yaml
  - gpg

:logger: console

:hierarchy:
  - passwords
  - "%{operatingsystem}"
  - common

:yaml:
  :datadir: /etc/puppet/hieradata

:gpg:
  :datadir: /etc/puppet/hieradata/gpgdata
  :key_dir: /etc/puppet/gpgdata

The call to hiera is in manifests/site.pp:

...
node /testmachine.local/ {
  class { 'apache' : }
  class { 'ruby' : }
  class { 'passenger' : }
  class { 'puppet::master::apache' : }
  class { 'mysql' : }
  class { 'mysql::ruby' : }
  class { 'mysql::server' :
    config_hash => { 'root_password' => hiera( 'mysql:server:root_passwd' ) }
  }
  mysql::server::config { 'basic_config' :
    settings => {
      'mysqld' => {
        'default_storage_engine' => 'InnoDB',
      }
    }
  }
}

All my setup can be found here: https://github.com/berndmweber/open-source-puppet-master/tree/master/modules/puppet

Any feedback is appreciated!

codylane commented 11 years ago

Check your permissions on /etc/puppet/gpgdata and ensure the owner and group match the user that is running the puppet server.

In my case I am running the puppet master as the puppet user so I needed to do the following.

chown -R puppet:root /etc/puppet/keyrings
chmod 0770 /etc/puppet/keyrings

This worked for me and I was having the very same issues as you described above. Hope this helps.