Proceed forward through

  http://docs.puppetlabs.com/learning/index.html


--Stuart
RHCE/RHCSA/Oracle DBA/Sun/Mensa


On Aug 26, 2013, at 12:00 PM, Ken Weiss <ken.we...@ucop.edu> wrote:

> Thanks to Chris's suggestion I have this mostly working. I need to add a few 
> final touches and then I'll post a closing note with full examples of the 
> solution. I really appreciate the help. I'm just getting started with Puppet, 
> barely understood defined resources, and didn't even know that 
> create_resources existed.
> 
> --Ken
> 
> ------------------------------------------------------------
> Ken Weiss                                 ken.we...@ucop.edu
> UC Office of the President              510-587-6311 (office)
> California Digital Library              916-905-6933 (mobile)
> UC Curation Center
> 415 20th Street, 4th Floor
> Oakland, CA 94612
> 
> 
> From: Ellison Marks <gty...@gmail.com>
> Reply-To: "puppet-users@googlegroups.com" <puppet-users@googlegroups.com>
> Date: Monday, August 26, 2013 11:56 AM
> To: "puppet-users@googlegroups.com" <puppet-users@googlegroups.com>
> Subject: Re: [Puppet Users] Using hiera lookups with defined types
> 
> Agreed, create resources is the way to create defined types using hiera data. 
> As a note though, if you need to create a bunch of defined types without 
> parameters, if, for example, you're only relying on the name parameter, you 
> can pass an array of titles to a declaration. 
> http://docs.puppetlabs.com/puppet/3/reference/lang_resources.html#array-of-titles
> 
> yaml:
> ---
> logrotate_users:
>   - alice
>   - bob
>   - carol
> 
> pp:
> $logrotate_users = hiera_array('logrotate_users')
> cron_jobs::logrotate::users { $logrotate_users: }
> 
> On Friday, August 23, 2013 10:17:05 PM UTC-7, mcd wrote:
>> 
>> Well normally you would use hiera_hash() and create_resources() to do it, 
>> like this:
>> 
>> # yaml data source
>> ---
>> cron_jobs::logrotate::users
>>   kenweiss:
>>     hour => 5
>>   tomjones:
>>     hour => 3
>> 
>> 
>> # pp file
>> ---
>> class cron_jobs::logrotate ( $hour, $minute, $weekday ) {
>>   ...
>>   $user_cron_options = hiera_hash('cron_jobs::logrotate::users', false)
>>   if $user_cron_options{
>>     create_resources('cron_jobs::logrotate::user_cron', $user_cron_options)
>>   }
>> }
>> 
>> One thing I don't know is how to do that for defined types that do not have 
>> any parameters.  Unfortunately create_resources requires a hash for the 
>> second argument, so you have to use hiera_hash to pull in the data, so it 
>> has to be a hash in hiera. And I haven't figured out how to define an empty 
>> hash yet. Or transform an array into a hash that would work for 
>> create_resources. 
>> 
>> /shrug
>> 
>> Chris
>> 
>> 
>> On Fri, Aug 23, 2013 at 5:01 PM, Ken Weiss <ken....@ucop.edu> wrote:
>>> Hi all,
>>> 
>>> I am trying to use hiera and .yaml files to load parameters into my 
>>> declared classes. For basic classes it works great. For example:
>>> 
>>> class cron_jobs::logrotate ( $hour, $minute, $weekday ) {...
>>> 
>>> node fqdn: test.my.com
>>> 
>>> I declare the class for my node very simply:
>>> 
>>> class {'cron_jobs::logrotate': }
>>> 
>>> If I create a file in the default hiera data directory called 
>>> test.my.com.yaml and include this:
>>> 
>>> cron_jobs::logrotate::hour: 5
>>> 
>>> then sure enough, when I do a puppet apply the cron job is created to run 
>>> at 5:00 AM.
>>> 
>>> 
>>> My problem is extending this to work with defined types. Let's say my 
>>> defined type looks like this when I declare it:
>>> 
>>> cron_jobs::logrotate::user_cron {'kenweiss' :}
>>> 
>>> What do I put in my .yaml file in order to get Puppet to load the 
>>> parameters automatically?
>>> 
>>> I tried a couple of things...
>>> 
>>> cron_jobs::logrotate::user_cron::kenweiss::hour 5
>>> cron_jobs::logrotate::user_cron[kenweiss]::hour 5
>>> 
>>> Neither worked, and I can't think of any other reasonable syntax. Can 
>>> anyone point me in the right direction?
>>> 
>>> --Ken Weiss
>>> -- 
>>> 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 puppet-users...@googlegroups.com.
>>> To post to this group, send email to puppet...@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/puppet-users.
>>> For more options, visit https://groups.google.com/groups/opt_out.
> 
> -- 
> You received this message because you are subscribed to a topic in the Google 
> Groups "Puppet Users" group.
> To unsubscribe from this topic, visit 
> https://groups.google.com/d/topic/puppet-users/Lual4Uxo3Ds/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to 
> puppet-users+unsubscr...@googlegroups.com.
> To post to this group, send email to puppet-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/puppet-users.
> For more options, visit https://groups.google.com/groups/opt_out.
> -- 
> 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 puppet-users+unsubscr...@googlegroups.com.
> To post to this group, send email to puppet-users@googlegroups.com.
> Visit this group at http://groups.google.com/group/puppet-users.
> For more options, visit https://groups.google.com/groups/opt_out.

-- 
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 puppet-users+unsubscr...@googlegroups.com.
To post to this group, send email to puppet-users@googlegroups.com.
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to