# Variable scoping in hiera config

Hi,

We're using Puppet 3.7.2 with hiera 1.3.4. We have implemented the role/profile pattern as is recommended. In the profiles we do hiera lookups.

The value for certain configuration parameters depend on the role in which they are used. (eg. the size of the file system containing oracle binaries is 5GB for Oracle clients (role: oracleclient), while it is 20GB on Oracle DB servers (role:oracledb)).

Below our hiera config:

---
:backends: yaml
:yaml:
:logger: puppet
:hierarchy:
- nodes/%{::fqdn}
- roles/%{role}/%{::environment}
- roles/%{role}
- network_zones/%{::network_zone}
- environments/%{::environment}
- common

The above only works when %{role} is defined in the node definition (see snippet below), but that's redundant and not guaranteed to work properly. If someone forgets to set $role in a new node definition, the proper values will not be used and the server will be misconfigured. So I'm looking for a way to have this variable to set another way. node 'dbserver' {$role = ‘oracle_db’
include ::role::oracle::server::db
}

class role::oracle::server::db {
...
}

more