Duncan Hill
2008-Mar-18 15:58 UTC
[Puppet Users] Overriding a file without causing duplicate definitions
Hello folks. I''ve got a problem that I can''t work out the solution to. My base workstation node definition says essentially: node base-workstation { file { etc-sudoers: name => "/etc/sudoers", ... } } This works fine, all of our workstations get a standardised sudoers file. However, I have one user on a workstation who needs a specialised sudoers file. If I define that file inside of the node definition, I get a duplicate definition error, which is right, it is a duplicate. Is there a clean solution to this kind of problem? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Ian J Cottee
2008-Mar-18 16:35 UTC
[Puppet Users] Re: Overriding a file without causing duplicate definitions
Duncan Hill wrote:> Hello folks. > > I''ve got a problem that I can''t work out the solution to. > > My base workstation node definition says essentially: > node base-workstation { > file { etc-sudoers: > name => "/etc/sudoers", ... > } > } > > This works fine, all of our workstations get a standardised sudoers file. > > However, I have one user on a workstation who needs a specialised > sudoers file. If I define that file inside of the node definition, I > get a duplicate definition error, which is right, it is a duplicate. > > Is there a clean solution to this kind of problemThis kind of issue is exactly what I have to deal with all the time. My solution is to have two sets of config files within svn. One is the ''standard'' configs and the other is where customised files can be put. So in trunk/shared/all/etc/samba I have the standard smb.conf I''ll use for all samba machines. If I want to override it I place a file in a specific place for that machine. i.e. trunk/systems/sn1177/config/etc/samba trunk/shared and trunk/systems are shared using puppet shares. i.e. my puppet/fileserver.conf reads # config files shared by all or groups of hosts [shared] path /home/bb2/svn/trunk/shared allow * # Config files for this specific system [system] path /home/bb2/svn/trunk/systems/%h allow * And then in the recipe I have stuff like this file { "/etc/samba/smb.conf": mode => 644, owner => root, group => root, source => ["puppet://bb2/system/config/etc/samba/smb.conf", "puppet://bb2/shared/all/etc/samba/smb.conf"], } The end result is that for each file I use, I''ll look for a specific file for that machine and if there''s nothing there I''ll use the standard file. Ian --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
José González Gómez
2008-Mar-18 17:08 UTC
[Puppet Users] Re: Overriding a file without causing duplicate definitions
On 18 mar, 16:58, "Duncan Hill" <bajand...@googlemail.com> wrote:> Hello folks. > > I''ve got a problem that I can''t work out the solution to. > > My base workstation node definition says essentially: > node base-workstation { > file { etc-sudoers: > name => "/etc/sudoers", ... > } > > } > > This works fine, all of our workstations get a standardised sudoers file. > > However, I have one user on a workstation who needs a specialised > sudoers file. If I define that file inside of the node definition, I > get a duplicate definition error, which is right, it is a duplicate. > > Is there a clean solution to this kind of problem?You may override the sudoers source in the special node: node special { File["etc-sudoers"] { source => "/another/source" } } Best regards Jose --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Duncan Hill
2008-Mar-18 17:19 UTC
[Puppet Users] Re: Overriding a file without causing duplicate definitions
On 18/03/2008, José González Gómez <jose.gonzalez.gomez@gmail.com> wrote:> > On 18 mar, 16:58, "Duncan Hill" <bajand...@googlemail.com> wrote: > > Hello folks. > > > > I''ve got a problem that I can''t work out the solution to. > > > > My base workstation node definition says essentially: > > node base-workstation { > > file { etc-sudoers: > > name => "/etc/sudoers", ... > > } > > > > }> You may override the sudoers source in the special node: > > node special { > File["etc-sudoers"] { source => "/another/source" } > }Ah! Thank you Jose, that solves it cleanly. I was doing a whole new definition, when I just needed to override the property. Thanks as well Ian, that''s another interesting approach. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Matt McLeod
2008-Mar-19 00:25 UTC
[Puppet Users] Re: Overriding a file without causing duplicate definitions
My solution to this problem was to generalise. I have a definition called "xfile" which I use in place of "file" and it automatically looks for host/platform/location-specific versions of the source. I''m sure there are problems with it, but here it is anyway: define xfile($owner = root, $group = 0, $mode = 644, $source, $backup = main, $recurse = false, $ensure = file) { file { $name: mode => $mode, owner => $owner, group => $group, backup => $backup, recurse => $recurse, ensure => $ensure, source => [ "puppet://$server/dist/$source.$hostname", "puppet://$server/dist/$source.$operatingsystem-$itg_location", "puppet://$server/dist/$source.$itg_location", "puppet://$server/dist/$source.$operatingsystem", "puppet://$server/dist/$source" ] } } On 19/03/08 2:58 AM, "Duncan Hill" <bajandude@googlemail.com> wrote:> > Hello folks. > > I''ve got a problem that I can''t work out the solution to. > > My base workstation node definition says essentially: > node base-workstation { > file { etc-sudoers: > name => "/etc/sudoers", ... > } > } > > This works fine, all of our workstations get a standardised sudoers file. > > However, I have one user on a workstation who needs a specialised > sudoers file. If I define that file inside of the node definition, I > get a duplicate definition error, which is right, it is a duplicate. > > Is there a clean solution to this kind of problem? > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---