如何影响在另一个 Puppet 模块中声明的资源类型
How Affect Resource Type Declared In Another Puppet Module
我包含 class nova::compute::libvirt
并且此 class 定义了一个包资源,如下所示:
package { 'libvirt-nwfilter':
ensure => present,
name => $::nova::params::libvirt_nwfilter_package_name,
before => Service['libvirt'],
tag => ['openstack', 'nova-support-package'],
}
问题是 RPM 在未启用的 YUM 存储库中 enabled=0
。
我可以通过更改 nova::conpute::libvirt
来解决这个问题,使包资源看起来像这样:
package { 'libvirt-nwfilter':
ensure => present,
name => $::nova::params::libvirt_nwfilter_package_name,
before => Service['libvirt'],
tag => ['openstack', 'nova-support-package'],
install_options => ['--enablerepo', 'redhat_updates'],
}
但我不想修改我从 puppet forge 获得的模块,因为下次其他人设置 puppet master 时他们可能会忘记进行修改。 class 有什么我可以做的,其中包括 nova::compute::libvirt
?
您可以通过使用 yumrepo
资源启用 redhat_updates
yum 存储库,然后在 class.[=14 之前为其应用指定元参数来解决此问题。 =]
yumrepo { "redhat_updates":
baseurl => "baseurl",
descr => "Redhat Updates",
enabled => 1,
gpgcheck => 0,
before => Class['nova::compute::libvirt'],
}
Resource collectors afford the possibility of overriding attributes of resources declared elsewhere。语法为:
Package<| title == 'libvirt-nwfilter' |> {
install_options => ['--enablerepo', 'redhat_updates']
}
该替代方案避免了修改存储库定义,并且不需要引入任何新的排序关系。但是请注意,收集器总是会实现任何匹配的虚拟资源。还要注意这种方法非常强大,因此很容易被滥用,给自己带来麻烦。能力越大,责任越大。
我包含 class nova::compute::libvirt
并且此 class 定义了一个包资源,如下所示:
package { 'libvirt-nwfilter':
ensure => present,
name => $::nova::params::libvirt_nwfilter_package_name,
before => Service['libvirt'],
tag => ['openstack', 'nova-support-package'],
}
问题是 RPM 在未启用的 YUM 存储库中 enabled=0
。
我可以通过更改 nova::conpute::libvirt
来解决这个问题,使包资源看起来像这样:
package { 'libvirt-nwfilter':
ensure => present,
name => $::nova::params::libvirt_nwfilter_package_name,
before => Service['libvirt'],
tag => ['openstack', 'nova-support-package'],
install_options => ['--enablerepo', 'redhat_updates'],
}
但我不想修改我从 puppet forge 获得的模块,因为下次其他人设置 puppet master 时他们可能会忘记进行修改。 class 有什么我可以做的,其中包括 nova::compute::libvirt
?
您可以通过使用 yumrepo
资源启用 redhat_updates
yum 存储库,然后在 class.[=14 之前为其应用指定元参数来解决此问题。 =]
yumrepo { "redhat_updates":
baseurl => "baseurl",
descr => "Redhat Updates",
enabled => 1,
gpgcheck => 0,
before => Class['nova::compute::libvirt'],
}
Resource collectors afford the possibility of overriding attributes of resources declared elsewhere。语法为:
Package<| title == 'libvirt-nwfilter' |> {
install_options => ['--enablerepo', 'redhat_updates']
}
该替代方案避免了修改存储库定义,并且不需要引入任何新的排序关系。但是请注意,收集器总是会实现任何匹配的虚拟资源。还要注意这种方法非常强大,因此很容易被滥用,给自己带来麻烦。能力越大,责任越大。