Ask Your Question
0

How do I remove common & repeated attributes from select directives?

asked 2014-02-12 13:15:46 -0500

bigH gravatar image

I am using boxen (which uses puppet) in order to set up dev environments on new laptops. Directives are organized by repository. I'd like to find a way to quickly build directives that contain many common attributes. e.g.:

file { "${tomcat_lib_dir}/somelib.jar":
  ensure => present,
  source => "puppet:///modules/projects/somelib.jar",
  require => Package['boxen/brews/tomcat6']
}

file { "${tomcat_lib_dir}/otherlib.jar":
  ensure => present,
  source => "puppet:///modules/projects/otherlib.jar",
  require => Package['boxen/brews/tomcat6']
}

file { "${tomcat_lib_dir}/anotherlib.jar":
  ensure => present,
  source => "puppet:///modules/projects/anotherlib.jar",
  require => Package['boxen/brews/tomcat6']
}

There are many repeated directives. (files mostly). Many ... (more)

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2014-02-12 13:33:34 -0500

updated 2014-02-12 13:45:13 -0500

This is how I'd try to do it:

define my_directive($tomcat_lib_dir, $name) {
  file { "${tomcat_lib_dir}/${name}.jar":
    ensure => present,
    source => "puppet:///modules/projects/${name}.jar",
    require => Package['boxen/brews/tomcat6']
  }
}
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

2 followers

Stats

Asked: 2014-02-12 13:15:46 -0500

Seen: 58 times

Last updated: Feb 12 '14