Hello there,

I need to access the following hiera data in a script:
$ hiera -c /etc/puppet/hiera.yaml tomcats environment=development 
line=intra3
["tc7_test1", "tc7_test8"]
or
$ hiera -c /etc/puppet/hiera.yaml apache_port environment=development 
line=intra3 name=tc7_test1
81

The example on https://github.com/puppetlabs/hiera uses facts of a specific 
hosts.
I don't want to specify and load each YAML file for each host, because the 
hosts are already defined for a specific line and stage environment:
$ hiera -c /etc/puppet/hiera.yaml hosts environment=development line=intra3
["serverA.domain.tld", "serverB.domain.tld"]

But I can't get the hiera.lookup to work without providing a scope with the 
facts of a specific host.

I know that I could just call hiera and parse the output, but I thought I 
better ask before doing that.
Maybe I'm even using environment and stage specific hiera data the wrong 
way.

Here is my current hiera config:

$ cat /etc/puppet/hiera.yaml
:hierarchy:
    - %{environment}/%{line}/%{name}
    - %{environment}/%{line}
    - %{environment}
:backends:
    - yaml
:yaml:
    :datadir: '/etc/puppet/environments/%{environment}/hieradata'
:puppet:
    :datasource: data
$ hiera -c /etc/puppet/hiera.yaml apache_port environment=development 
line=intra3
80
$ hiera -c /etc/puppet/hiera.yaml apache_port environment=development 
line=intra3 name=tc7_test1
81
$ hiera -c /etc/puppet/hiera.yaml apache_port environment=development 
line=intra3 name=tc7_test8
80
$ cat /etc/puppet/environments/development/hieradata/development.yaml
---
# default values for this stage
apache_port: '80'

$ cat /etc/puppet/environments/development/hieradata/development/intra3.yaml
---
# line specific values
hosts:  - 'serverA.domain.tld'
        - 'serverB.domain.tld'
tomcats:  - 'tc7_test1'
          - 'tc7_test8'

$ cat 
/etc/puppet/environments/development/hieradata/development/intra3/tc7_test1.yaml
---
# tc7_test1 specific values
apache_port: 81


Thanks in advance!

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/puppet-users/-/wgIUzVFoXUsJ.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.

Reply via email to