gpt4 book ai didi

puppet - 在 puppet 类之间传递变量

转载 作者:行者123 更新时间:2023-12-04 23:53:13 25 4
gpt4 key购买 nike

我正在尝试使用 exec 资源类型来执行批处理文件。但我想将变量 $dsn_64bit 的值从 init.pp 传递到 install.pp。请让我知道如何实现:

这是我的 init.pp

class exec_batchfile ($dsn_64bit = "false")
{
if $::osfamily == 'windows' {
include exec_batchfile::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",
}
}

谢谢

最佳答案

由于 puppet 2.7 动态查找已弃用,因此您的代码将无法正常工作。目前推荐的解决方案是使用完全限定的名称。请关注link找到一个全面的解释。

Whenever you need to refer to a variable in another class, give the variable an explicit namespace: instead of simply referring to $packagelist, use $git::core::packagelist.

关于puppet - 在 puppet 类之间传递变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29904749/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com