Is there a way to append values to an array? Consider this:
$sudoers = $identity ? {
''oracle'' => [''namath'',
''obrien'', ''testeverde'',
''favre''],
''webdev'' => [''ruth'',
''jeter''],
default => [''simms'', ''taylor''],
}
Now I''d like to maybe add the security team:
if $security {
$sudoers += [''bob'', ''doug''] # or
something like this...
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com
To unsubscribe from this group, send email to
puppet-users+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en
-~----------~----~----~----~------~----~------~--~---
Not currently. You could do some template magic (iClassify comes to mind). File a feature req =] Regards, AJ On 21/08/2008, at 1:41 AM, Jeff <joesiege@gmail.com> wrote:> > Is there a way to append values to an array? Consider this: > > $sudoers = $identity ? { > ''oracle'' => [''namath'', ''obrien'', ''testeverde'', ''favre''], > ''webdev'' => [''ruth'', ''jeter''], > default => [''simms'', ''taylor''], > } > > Now I''d like to maybe add the security team: > > if $security { > $sudoers += [''bob'', ''doug''] # or something like this... > } > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
I also was thinking about this problem recently, I think that the main problem is that you can reassign a variable again, e.g.: array = return_array(array,new_array) you can do it for native puppet types with the +> operator, but not for variables. I ended up doing a lot of this stuff inside templates or custom functions... Ohad On Wed, Aug 20, 2008 at 9:41 PM, Jeff <joesiege@gmail.com> wrote:> > Is there a way to append values to an array? Consider this: > > $sudoers = $identity ? { > ''oracle'' => [''namath'', ''obrien'', ''testeverde'', ''favre''], > ''webdev'' => [''ruth'', ''jeter''], > default => [''simms'', ''taylor''], > } > > Now I''d like to maybe add the security team: > > if $security { > $sudoers += [''bob'', ''doug''] # or something like this... > } > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
On Wed, Aug 20, 2008 at 10:24 PM, Ohad Levy <ohadlevy@gmail.com> wrote:> I also was thinking about this problem recently, I think that the main > problem is that you can reassign a variable again, e.g.: >can not of course... Ohad --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
Hi, On 20/08/08 15:41, Jeff wrote:> Is there a way to append values to an array? Consider this: > > $sudoers = $identity ? { > ''oracle'' => [''namath'', ''obrien'', ''testeverde'', ''favre''], > ''webdev'' => [''ruth'', ''jeter''], > default => [''simms'', ''taylor''], > } > > Now I''d like to maybe add the security team: > > if $security { > $sudoers += [''bob'', ''doug''] # or something like this... > } >0.24.6 will contain one of my puppet contribution that implements exactly this. Except that it respects the write-once paradigm of variables, so the += operator can only be used in a new scope and it doesn''t change the value of the original variable. Hope that will help the users :-) -- Brice Figureau Days of Wonder http://www.daysofwonder.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---