2
我正在嘗試使用exec資源類型來執行批處理文件。但是我想把變量$ dsn_64bit的值從init.pp傳遞給install.pp。請讓我知道如何做到這一點:在傀儡類中傳遞變量
這裏是我的init.pp
class exec_batchfile ($dsn_64bit = "false")
{
if $::osfamily == 'windows' {
include exec_batchfile::install
}
}
這裏是我的install.pp
class exec_batchfile::install
{
if $dsn_64bit == true
{
$hklm_path = 'HKLM\Software\Oracle'
$Script_name = 'E:\\Path\\pupp_test64.bat'
}
else
{
$hklm_path = 'HKLM\Software\WOW6432Node\Oracle'
$Script_name = 'E:\\Path\\pupp_test.bat'
}
exec { 'exec_batchfile':
command => "${Script_name}",
path => $::path,
logoutput => true,
unless => "cmd.exe /c reg query ${hklm_path} /v inst_loc",
}
}
感謝
$ local_var =「from parent :: child」做了訣竅。鏈接爲+1。非常感謝 – user3605317
更改了我的答案,使其更符合您的評論。 – kkamilpl