-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Sunday 18 March 2007 22:28, Andrew Leach wrote:> define sedfile ( $file = '', $target = '', $pattern =
'', $options = '-i
> -n' , onlyif = '' ) {
> exec { "sedfile-$name":
> command => "sed ${options} '${pattern}'
${file}",
> path => "/usr/bin:/usr/sbin:/bin",
> cwd => "$target",
> logoutput => "true",
> onlyif => $onlyif,
> require => $operatingsystem ? {
> debian => Package["sed"]
> }
> }
> }
>
> define checkkernelparamisset ( $file = ".config", $target >
"/usr/src/linux", $param = '' ) {
> exec { "checkkernelparamisset-$name":
> command => "if !test `^grep
'${param}.*=.*[y|Y|yes|YES|Yes]'
> ${file}`",
> path => "/usr/bin:/usr/sbin:/bin",
> cwd => "${target}",
> require => Package["coreutils"];
> }
> }
>
> Main calling code:
>
> $param = [ "CONFIG_MODVERSIONS", "CONFIG_NET_RADIO",
"CONFIG_SYSCTL",
> "CONFIG_CRYPTO", "CONFIG_CRYPTO_HMAC",
"CONFIG_CRYPTO_AES" ]
> sedfile { "mod_madwifi_${param}":
> file => "Rule.mk",
> pattern => "s/^\(${param}\) = .*/#\1 is not set/",
> onlyif => checkkernelparamisset { "mod_madwifi_${param}":
> param => "${param}";
> },
> target => "/usr/src";
> }
>
> There's two things here that I don't believe puppet can do yet.
>
> 1) issuing a command multiple times by iterating through an array [ $param
> code ]
> 2) being able to pass user supplied code segments into other user defined
> code segments [ onlyif code ]
>
> I believe these would be very useful, is there anyway I can achieve this
> now?
1) use a define:
define my_cmd() {
exec { "exec_${name}":
command => "something $name",
}
}
my_cmd{ $array: }
2) should be achievable by implementing a ruby/puppet function and building
the onlyif command from the arguments. See
http://reductivelabs.com/trac/puppet/wiki/WritingYourOwnFunctions
Regards, David
- --
- - hallo... wie gehts heute?
- - *hust* gut *rotz* *keuch*
- - gott sei dank kommunizieren wir über ein septisches medium ;)
-- Matthias Leeb, Uni f. angewandte Kunst, 2005-02-15
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFF/bn0/Pp1N6Uzh0URAigGAJ9j0DOigjKPxVtW0/5Ln1QGJTW8mACfb3Be
tl728hzG76GpsriBJlrLaqM=7fYh
-----END PGP SIGNATURE-----
_______________________________________________
Puppet-users mailing list
Puppet-users@madstop.com
https://mail.madstop.com/mailman/listinfo/puppet-users