Bostjan Skufca
2009-Sep-16 00:39 UTC
[Puppet Users] Do resources support some form of inheritance/prototyping?
Hi! Does anybody know, if resources can be inherited? Example: I would like to define three files with owner=root and group=bin and mode=754. To do that you can write: file { "file1": owner=root, group=bin, mode=754, } file { "file2": owner=root, group=bin, mode=754, } file { "file3": owner=root, group=bin, mode=754, } As you can see there is a bit of redundancy there. The more elegant way would be something like this (fictive code!): file_prototype { owner=root, group=bin, mode=754, } file { "file1": include file_prototype, } file { "file2": include file_prototype, } file { "file3": include file_prototype, } Does something similar to code above exists in puppet? Or any workaround that does similar trick? Thank you, b. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Nigel Kersten
2009-Sep-16 00:58 UTC
[Puppet Users] Re: Do resources support some form of inheritance/prototyping?
On Tue, Sep 15, 2009 at 5:39 PM, Bostjan Skufca <bostjan.skufca@gmail.com>wrote:> > Hi! > > Does anybody know, if resources can be inherited? > > Example: > > I would like to define three files with owner=root and group=bin and > mode=754. > To do that you can write: > file { "file1": > owner=root, > group=bin, > mode=754, > } > file { "file2": > owner=root, > group=bin, > mode=754, > } > file { "file3": > owner=root, > group=bin, > mode=754, > } > > > As you can see there is a bit of redundancy there. >You should do this with setting resource defaults in the current scope instead like: File { ensure => file, owner => root, group => bin, mode => 0754, } file { ["file1", "file2", "file3"]: } http://reductivelabs.com/trac/puppet/wiki/LanguageTutorial#resource-defaults> The more elegant way would be something like this (fictive code!): > > file_prototype { > owner=root, > group=bin, > mode=754, > } > file { "file1": include file_prototype, } > file { "file2": include file_prototype, } > file { "file3": include file_prototype, } > > Does something similar to code above exists in puppet? Or any > workaround that does similar trick? > > Thank you, > b. > > > > >-- Nigel Kersten nigelk@google.com System Administrator Google Inc. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
James Turnbull
2009-Sep-16 01:41 UTC
[Puppet Users] Re: Do resources support some form of inheritance/prototyping?
2009/9/16 Nigel Kersten <nigelk@google.com>:> > > On Tue, Sep 15, 2009 at 5:39 PM, Bostjan Skufca <bostjan.skufca@gmail.com> > wrote: >> >> Hi! >> >> Does anybody know, if resources can be inherited? >> >> Example: >> >> I would like to define three files with owner=root and group=bin and >> mode=754. >> To do that you can write: >> file { "file1": >> owner=root, >> group=bin, >> mode=754, >> } >> file { "file2": >> owner=root, >> group=bin, >> mode=754, >> } >> file { "file3": >> owner=root, >> group=bin, >> mode=754, >> } >> >> >> As you can see there is a bit of redundancy there. > > You should do this with setting resource defaults in the current scope > instead like: > > File { ensure => file, owner => root, group => bin, mode => 0754, } > > file { ["file1", "file2", "file3"]: } >Or: file { ["file1", "file2", "file3"]: owner=root, group=bin, mode=754, } Or using a define or articulated as: file { "file1": owner => "root", group => "bin", mode => 754; "file2": owner => "root", group => "bin", mode => 754; "file3": owner => "root", group => "bin", mode => 754; } Regards James Turnbull -- Author of: * Pro Linux Systems Administration (http://tinyurl.com/linuxadmin) * Pulling Strings with Puppet (http://tinyurl.com/pupbook) * Pro Nagios 2.0 (http://tinyurl.com/pronagios) * Hardening Linux (http://tinyurl.com/hardeninglinux) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Bostjan Skufca
2009-Sep-16 01:46 UTC
[Puppet Users] Re: Do resources support some form of inheritance/prototyping?
I believed that defaults could only be set for global scope. Funny:) Thank you both for your hints! b. On Sep 16, 2:58 am, Nigel Kersten <nig...@google.com> wrote:> On Tue, Sep 15, 2009 at 5:39 PM, Bostjan Skufca <bostjan.sku...@gmail.com>wrote: > > > > > > > Hi! > > > Does anybody know, if resources can be inherited? > > > Example: > > > I would like to define three files with owner=root and group=bin and > > mode=754. > > To do that you can write: > > file { "file1": > > owner=root, > > group=bin, > > mode=754, > > } > > file { "file2": > > owner=root, > > group=bin, > > mode=754, > > } > > file { "file3": > > owner=root, > > group=bin, > > mode=754, > > } > > > As you can see there is a bit of redundancy there. > > You should do this with setting resource defaults in the current scope > instead like: > > File { ensure => file, owner => root, group => bin, mode => 0754, } > > file { ["file1", "file2", "file3"]: } > > http://reductivelabs.com/trac/puppet/wiki/LanguageTutorial#resource-d... > > > > > The more elegant way would be something like this (fictive code!): > > > file_prototype { > > owner=root, > > group=bin, > > mode=754, > > } > > file { "file1": include file_prototype, } > > file { "file2": include file_prototype, } > > file { "file3": include file_prototype, } > > > Does something similar to code above exists in puppet? Or any > > workaround that does similar trick? > > > Thank you, > > b. > > -- > Nigel Kersten > nig...@google.com > System Administrator > Google Inc.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
James Turnbull
2009-Sep-16 01:50 UTC
[Puppet Users] Re: Do resources support some form of inheritance/prototyping?
2009/9/16 James Turnbull <james@lovedthanlost.net>:> file { ["file1", "file2", "file3"]: > owner=root, > group=bin, > mode=754, > }That should read: file { ["file1", "file2", "file3"]: owner => root, group => bin, mode => 754, } Regards James Turnbull -- Author of: * Pro Linux Systems Administration (http://tinyurl.com/linuxadmin) * Pulling Strings with Puppet (http://tinyurl.com/pupbook) * Pro Nagios 2.0 (http://tinyurl.com/pronagios) * Hardening Linux (http://tinyurl.com/hardeninglinux) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Nigel Kersten
2009-Sep-16 16:00 UTC
[Puppet Users] Re: Do resources support some form of inheritance/prototyping?
On Tue, Sep 15, 2009 at 6:46 PM, Bostjan Skufca <bostjan.skufca@gmail.com>wrote:> > I believed that defaults could only be set for global scope. Funny:) > > Thank you both for your hints! >I actually thought this too, but it''s for the current and inherited scopes it seems. Moving to declaring File defaults in each class has made my manifests *so* much more readable....> > b. > > > On Sep 16, 2:58 am, Nigel Kersten <nig...@google.com> wrote: > > On Tue, Sep 15, 2009 at 5:39 PM, Bostjan Skufca < > bostjan.sku...@gmail.com>wrote: > > > > > > > > > > > > > Hi! > > > > > Does anybody know, if resources can be inherited? > > > > > Example: > > > > > I would like to define three files with owner=root and group=bin and > > > mode=754. > > > To do that you can write: > > > file { "file1": > > > owner=root, > > > group=bin, > > > mode=754, > > > } > > > file { "file2": > > > owner=root, > > > group=bin, > > > mode=754, > > > } > > > file { "file3": > > > owner=root, > > > group=bin, > > > mode=754, > > > } > > > > > As you can see there is a bit of redundancy there. > > > > You should do this with setting resource defaults in the current scope > > instead like: > > > > File { ensure => file, owner => root, group => bin, mode => 0754, } > > > > file { ["file1", "file2", "file3"]: } > > > > http://reductivelabs.com/trac/puppet/wiki/LanguageTutorial#resource-d... > > > > > > > > > The more elegant way would be something like this (fictive code!): > > > > > file_prototype { > > > owner=root, > > > group=bin, > > > mode=754, > > > } > > > file { "file1": include file_prototype, } > > > file { "file2": include file_prototype, } > > > file { "file3": include file_prototype, } > > > > > Does something similar to code above exists in puppet? Or any > > > workaround that does similar trick? > > > > > Thank you, > > > b. > > > > -- > > Nigel Kersten > > nig...@google.com > > System Administrator > > Google Inc. > > >-- Nigel Kersten nigelk@google.com System Administrator Google Inc. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---