You can use the create_resources() function to declare resources based on hashes similar in form to those you present. You cannot, however, express resource references in hiera data, and you need resource references to express your resource relationships. That can be worked around. In this case, you also structure your data in a form that is not particularly conducive to the lookups you want to perform, but that, too can be worked around.
As is often the case in Puppet DSL, a suitable defined type can serve here as an adaptor, and suitable templates can do the needed processing. I might do something like this:
define site::hiera_package($package_pack) {
$repo = inline_template("<%= @package_pack.values.each { |repo| if repo.has_key?(@name) { repo; break } } %>")
if $repo == '' {
fail("No package '@name' defined in the provided pack")
}
package { $name:
ensure => $package_pack[$repo][$name]
require => Yumrepo[$repo]
}
}
That will work with the data structure you presented, but will not provide relationships on other Packages. However, since you are assuming the Yum package provider, you should not need to define package relationships to Puppet. These should already be adequately described in your packages' internal metadata, which Yum uses to install any needed dependencies automatically.
If you nevertheless want data-driven explicit dependencies between packages, then you can probably obtain that. One approach would involve making the values of the inner hashes be a third level of hash wherein you describe possibly-multiple properties of the package named by the key. One of those properties would be the state to ensure, and another could be an array of the names of packages it should depend on. You could then use an additional define to process the array and declare appropriate resource relationships via a chain operator. Alternatively, the iteration facilities of the Future parser might provide a more direct route to expressing the needed chain operations.
John