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

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 ... edit retag close merge delete ## 1 Answer Sort by » oldest newest most voted 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']
}
}

more