Upgraded puppet server and hiera is not working

249 views
Skip to first unread message

Peter Krawetzky

unread,
Jul 21, 2017, 8:16:11 AM7/21/17
to Puppet Users
I upgraded the puppet server from 2.1.1-1 to 2.7.2-1 and at the same time the puppet agent was upgraded from 1.2.2-1 to 1.10.4-1.

I read several different posts on this forum and others but I can't seem to get hiera 5 to work properly.  I tried a couple of different hiera.yaml config files yet nothing seems to work correctly.  I've tried to use the old hiera.yaml version and getting the expected depricated warning.  The Puppet doci on V5 and converting is not the greatest.

Our hiera config uses both json files and couchdb.  Everytime I run puppet lookup I get:
[root@xlabsvcpup4 code]# puppet lookup pup_url
Warning: /etc/puppetlabs/code/hiera.yaml: Use of 'hiera.yaml' version 3 is deprecated. It should be converted to version 5
   (in /etc/puppetlabs/code/hiera.yaml)
Warning: Undefined variable '::my_role';
   (file & line not available)
Error: Could not run: HTTP request path is empty

Current hiera.yaml file:
[root@xlabsvcpup4 code]# cat hiera.yaml
---
:backends:
  - http
  - json
  - yaml
:hierarchy:
  - "%{::clientcert}"
  - "%{::environment}/%{::clientcert}"
  - "%{::environment}/%{::my_role}"
  - "%{::environment}/common"
  - "%{::my_role}"
  - common
:json:
  :datadir: /u01/hieradata/
:yaml:
  :datadir: /u01/hieradata/
:http:
  :host: couchdb.com
  :port: 5984
  :output: json
  :failure: graceful
  :use_auth: true
  :auth_user: 'userid'
  :auth_pass: 'password'
  :paths:
    - /hieradb/%{::clientcert}
    - /%{::environment}/%{::my_role}
    - /%{::environment}/common
    - /hieradb/%{::my_role}
    - /hieradb/common

I tried to use this version 5 config file:
---
version: 5

defaults:
  datadir: "/u01/hieradata"
  data_hash: json_data

hierarchy:
  - name: "json files"
    paths:
        - "%{::clientcert}.json"
        - "%{::environment}/%{::clientcert}.json"
        - "%{::environment}/%{::my_role}.json"
        - "%{::environment}/common.json"
        - "%{::my_role}.json"
        - common.json
  - name: "Couchdb"
    options:
        connections:
            hiera3_backend: hiera-http
            host: couchdb.com
            output: json
            failure: graceful
            use_auth: true
            auth_user: 'userid'
            auth_pass: 'password'
            paths:
               - /hieradb/%{::clientcert}
               - /%{::environment}/%{::my_role}
               - /%{::environment}/common
               - /hieradb/%{::my_role}
               - /hieradb/common
When I use the V5 config i get:
Warning: Undefined variable '::my_role';
   (file & line not available)
Error: Could not run: 'json_data' one of 'path', 'paths' 'glob', 'globs' or 'mapped_paths' must be declared in hiera.yaml when using t


Antony Fomenko

unread,
Jul 24, 2017, 3:17:20 AM7/24/17
to Puppet Users
Try to remove default and use datadir and data_hash options for json backend only.
Reply all
Reply to author
Forward
0 new messages