I have a Puppet manifest with three exec
resources:
exec { 'test1':
command => "bla1",
require => File['test'],
}
exec { 'test2':
command => "bla2",
require => File['test'],
}
exec { 'test3':
command => "bla3",
require => File['test'],
}
Can someone offer a way to improve the code, such as with a loop?
I'm using Puppet 3.8 and would need something supported in that release.
This is one way to do it:
$cmd = [
"command1",
"command2",
"command3",
]
define run_command {
exec { "${name}":
path => ['/usr/bin','/usr/sbin','/bin','/sbin'],
}
}
run_command { $cmd:
require => File['test'];
}