Ask Your Question
0

Best practice for centralizing resource defaults

asked 2014-08-27 10:06:03 -0500

Bijan Vakili @EVault gravatar image

I'd like to know what's the best practice for centralize a resource's defaults in one place for use across multiple nodes and classes regardless of hierarchy.

e.g. I have the following:


class server::common::windows (
  $param1 = '. . .',
  $param2 = '. . .'
) {

  # . . . other stuff . . .

  # set file defaults to executable and owned by Adminsitrator
  File {
    ensure => 'file',
    source_permissions => ignore,
    owner => "Administrator",
    group => "Administrators",
    mode => 'u=rwx,og=rx',
  }
}

class role1 {
  class { 'server::common::windows': } 
   # . . . some resources that re-use the File defaults
}

class role2 {
  include server::common::windows
   # . . . some resources that re-use the File defaults
}

class role3 : inherits server::common::windows {

   # . . . some resources that re-use the File defaults
}

I believe this generally won't work as expected since resource defaults are dynamically scoped in Puppet. Based on the documentation for dynamic scope it seems inheritance should work (as in 'role3'), however I haven't gotten this to work.

I'd actually prefer to use inheritance or imports if possible. What's the recommended best practice for avoiding copying+pasting resouce defaults (like File) in each role class I define?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2014-08-28 19:00:53 -0500

Utilize site.pp

Learning puppet - Basic Agent/Master Puppet (site.pp)

Example follows:

...
...
Exec { path => '/usr/bin:/usr/sbin:/usr/local/bin:/bin:/sbin' }
Package { allow_virtual => false }

node 'foo.example.com' {
  ...
  ...

The puppet master always loads site.pp.

Hope this helps.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2014-08-27 08:50:04 -0500

Seen: 131 times

Last updated: Aug 28 '14