Hi John,

I haven't use create_resources() before, so following the puppetlab docs. After 
having the data structure in my default.yaml, I have this  in the nodes.pp:

$hr_mon_base_pkgs = hiera_hash('rpm_mon_base_pack', undef)
>

and then in my utils.pp, I have this:

class monitoring::mon-utils {
>
>     define mon_pkgs($pkgs_pack) {
>         $repo = inline_template("<%= @pkgs_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   => $pkgs_pack[$repo][$name],
>             require  => Yumrepo[ $repo ],
>         }
>     }
>     create_resources(  monitoring::mon-utils::mon_pkgs, $hr_mon_base_pkgs )
> }
>


but ends up with the error:

err: Could not retrieve catalog from remote server: Error 400 on SERVER: 
> Invalid parameter rpm-mon-ntp on node mon105.back.local
> warning: Not using cache on failed catalog
> err: Could not retrieve catalog; skipping run
>

which is one of the packages in the hiera hash. Am I doing it right at all??

Best,
San


On Monday, May 5, 2014 6:13:13 PM UTC+1, jcbollinger wrote:
>
>
>
> 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
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/ccebd1f8-d760-4f64-8e2a-9968f20bdda0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to