--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet...@googlegroups.com.
To unsubscribe from this group, send email to puppet-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
John
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet...@googlegroups.com.
To unsubscribe from this group, send email to puppet-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet...@googlegroups.com.
To unsubscribe from this group, send email to puppet-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
I wonder if the nil value is not being accepted as 'being passed' - can you populate the nil value and try again?
On Fri, May 18, 2012 at 2:41 PM, Dan White <yg...@comcast.net> wrote:
> On 18/05/12 13:46, Dan White wrote:
> > Ah, Gary ! �Just the brain I wish to pick ! �:)
> >
> > Thanks for the response. It makes sense.
> > However, if I perceive this properly, it would provide an All-Or-Nothing implementation of users.
> >
> > I am looking for for a way to have a master list of users in hiera and then realize/instantiate a group-keyed-subset of the master list on each node.
> >
> > �Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us.�
> > Bill Waterson (Calvin& �Hobbes)
> >
>
> Why not use a define to wrap the virtualised declaration of your users,
> or tried and doesn't work? Theoretically like this:
>
> --------------------
> define virtualise_user ($name, $uid, ...) {
> � �@user { $name:
> � � �uid => $uid,
> � �}
> }
>
> $all_users = hiera_hash('users')
>
> create_resources('virtualise_user', $all_users)
> --------------------
>
Closer, but no cigar yet !
user.pp:
-------------------------
define add_user ( $username, $uid, $ingroups, $info ) {
<clip>
}
define add_virtual_user ( $v_username, $v_uid, $v_ingroups, $v_info ) {
� �@add_user { "${name}":
� � � �username => "${v_username}",
� � � �uid � � �=> "${v_uid}",
� � � �ingroups => "${v_ingroups}",
� � � �info � � => "${v_info}",
� �}
}
-------------------------
/etc/puppet/hierdata/common.yaml:
-------------------------
users:
� �beast:
� � � �v_username : beast
� � � �v_uid � � �: 6666
� � � �v_ingroups :
� � � �v_info � � : Let's see if this works
� �boo:
� � � �v_username : boo
� � � �v_uid � � �: 6667
� � � �v_ingroups :
� � � �v_info � � : Let's see if this works also
-------------------------
And if I say:
hiera users -c /etc/puppet/hiera.yaml
I get:
{"beast"=>{"v_info"=>"Let's see if this works", "v_username"=>"beast", "v_ingroups"=>nil, "v_uid"=>6666}, "boo"=>{"v_info"=>"Let's see if this works also", "v_username"=>"boo", "v_ingroups"=>nil, "v_uid"=>6667}}
Which is out of order, but everything is there. �That's how hashes are supposed to work !
But when I try to run the catalog with
�$the_users = hiera('users') �or $the_users = hiera_hash('users')
followed by :
�create_resources ( 'add_virtual_user', $the_users )
I get:
�Must pass a parameter or all necessary values at /etc/puppet/manifests/nodes/puppetmaster-node.pp:15 on node puppetmaster.foo.org
�Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us.�
Bill Waterson (Calvin & Hobbes)
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet...@googlegroups.com.
To unsubscribe from this group, send email to puppet-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
--
Gary LarizzaProfessional Services EngineerPuppet Labs
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet...@googlegroups.com.
To unsubscribe from this group, send email to puppet-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
luke....@lmax.com | http://www.lmax.com LMAX, Yellow Building, 1A Nicholas Road, London W11 4AN
I agree with Gary, Dan, it's probably the lack of data in the 'v_ingroups' key in your YAML that create_resources() is complaining about. If it truly can't pass an empty key/val pair you could do something hacky like use the string "undef" then explicitly check for it in the define.
define add_virtual_user ( $v_username, $v_uid, $v_ingroups, $v_info ) {
if ($v_ingroups == "undef") {
On Mon, May 21, 2012 at 1:24 AM, Luke Bigum <Luke....@lmax.com> wrote:
I agree with Gary, Dan, it's probably the lack of data in the 'v_ingroups' key in your YAML that create_resources() is complaining about. If it truly can't pass an empty key/val pair you could do something hacky like use the string "undef" then explicitly check for it in the define.if ($v_ingroups == "undef") {
define add_virtual_user ( $v_username, $v_uid, $v_ingroups, $v_info ) {
Do you really mean to be comparing to the string "undef" rather than the keyword undef (no quotes)?
There's a big difference...
If you want to test if a variable is undefined the best way is to do this:
if ($foo == undef) { notice "\$foo is undef" }else { notice "\$foo is defined as ${foo}" }
-Jeff
I found an answer to this particular issue. Thanks for the reminder so I can share the answer:
I found the hiera/yaml way to indicate an empty array !
So, to use my earlier example:
users:
beast:
username : beast
uid : 6666
ingroups :
- ''
info : Let's see if this works
Then, with a hiera call, I get :
{"beast"=>{"ingroups"=>[""], "uid"=>6666, "username"=>"beast", "info"=>"Let's see if this works"}
> > To post to this group, send email to puppet-users@
On Tuesday, May 22, 2012, Dan White wrote:I found an answer to this particular issue. Thanks for the reminder so I can share the answer:
I found the hiera/yaml way to indicate an empty array !
So, to use my earlier example:
users:
beast:
username : beast
uid : 6666
ingroups :
- ''
info : Let's see if this works
Then, with a hiera call, I get :
{"beast"=>{"ingroups"=>[""], "uid"=>6666, "username"=>"beast", "info"=>"Let's see if this works"}
This is actually a non-empty array hat had one element, the empt string.
This clearly seems like a bug in puppet and how it is handling Hash values. I'll take a look more as soon as I get into the office.