Doubt about eyaml_lookup_key and hiera_eyaml_gpg

瀏覽次數:89 次
跳到第一則未讀訊息

Bruno Rodriguez

未讀,
2018年3月13日 上午10:15:582018/3/13
收件者:Puppet Users
Good evening everyone, 

I'm having a problem while getting some information from a yaml file via hiera and I've been hours with it without knowing how to find the solution.

In the .pp I make the following lookup:

   files = hiera_hash('common::files', $files)

In the hiera file I have an entry in the form:

   common::files: 
      '/my/file':
          content: 'something simple'
      '/my/file2':
          content: 'something simple again'

Then I get the following error:

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Function Call, Lookup of key 'common::files' failed: Value for key 'common::files', in hash returned from data_hash function 'yaml_data', when using location '/etc/puppetlabs/code/environments/my_env/hieradata/common.yaml', has wrong type, expects Puppet::LookupValue, got Hash[Data, Hash[Enum['content', 'ensure', 'target'], Enum['/opt/puppetlabs/bin/fact.-....   

Just as if I couldn't get the value and I can't understand anything because it looks like a "internal" problem with gems and so on. I'm suspecting that because whenever I make a lookup in the server I get this error:

  # puppet lookup common::files
  Error: Could not run: wrong number of arguments (1 for 0)

The global hiera.yaml file looks like this. It's almost a 

  version: 5
  defaults:
      datadir: "/etc/puppetlabs/code/environments/%{environment}/hieradata"
      data_hash: yaml_data
  #    lookup_key: eyaml_lookup_key
  #    options: 
  #        gpg_gnupghome: '/etc/puppetlabs/puppet/gpg_keys'
  #        encrypt_method: 'gpg'
  
  hierarchy:
    - name: "common.yaml"
      data_hash: yaml_data
      path: "common.yaml"

I'm moving from hiera v3 to hiera v5 and I was using GPG instead of PKCS7, but that will be another poblem. First of all I want to be able to recover the non-encrypted values.

Bruno Rodriguez

未讀,
2018年3月13日 上午10:37:142018/3/13
收件者:Puppet Users
OK, I discovered what the problem was but ... Still amazed

In my YAML files I had some entries like this:

common::packages:
   ['vim', 'htop']:
      ensure: latest

It didn't work and gave an error that has been pretty difficult to understand. After changing the yaml to:

common::packages:
   'vim':
      ensure: latest
   'htop':
      ensure: latest

Everything works. I'll have to rewrite some parts of my hiera files, but at least I can apply the manifests in the nodes...
回覆所有人
回覆作者
轉寄
0 則新訊息