Class 如何根据另一个类的状态编写puppet类依赖关系
我有两个类叫做Class 如何根据另一个类的状态编写puppet类依赖关系,class,puppet,Class,Puppet,我有两个类叫做main.pp和precheck.pp。我的想法是main.pp将继续执行,如果precheck.pp成功。那么,我应该如何获得precheck.pp class my::main { require my::module::precheck # I want to execute installpackage if precheck is succeed. require my::module::installpackage } class my::modul
main.pp
和precheck.pp
。我的想法是main.pp将继续执行,如果precheck.pp
成功。那么,我应该如何获得precheck.pp
class my::main {
require my::module::precheck
# I want to execute installpackage if precheck is succeed.
require my::module::installpackage
}
class my::module::precheck {
if $facts['osfamily'] == 'redhat' {
if versioncmp($facts['operatingsystemmajrelease'], '7') >= 0 {
notify {"osrelease":
message => "${::operatingsystemmajrelease} is good to install myapp."
}
}
else {
fail("myapp is not supported on this OS release")
}
}
else {
fail("myapp is not supported on ${::osfamily}.")
}
}
在precheck.pp
class my::main {
require my::module::precheck
# I want to execute installpackage if precheck is succeed.
require my::module::installpackage
}
class my::module::precheck {
if $facts['osfamily'] == 'redhat' {
if versioncmp($facts['operatingsystemmajrelease'], '7') >= 0 {
notify {"osrelease":
message => "${::operatingsystemmajrelease} is good to install myapp."
}
}
else {
fail("myapp is not supported on this OS release")
}
}
else {
fail("myapp is not supported on ${::osfamily}.")
}
}
上述代码段未按预期工作
感谢James您可以使用以下工具创建类级依赖项: 这将在
precheck
类容器上为installpackage
类容器创建依赖项。请注意,与类容器结合使用的类级依赖通常不被认为是最佳实践