简体   繁体   中英

How Affect Resource Type Declared In Another Puppet Module

I include the class nova::compute::libvirt and this class defines a Package resource like so:

package { 'libvirt-nwfilter':
  ensure => present,
  name   => $::nova::params::libvirt_nwfilter_package_name,
  before => Service['libvirt'],
  tag    => ['openstack', 'nova-support-package'],
}

The problem is that the RPM is in a YUM repo that is not enabled enabled=0 . I could solve this issue by changing nova::conpute::libvirt so that Package resource looked like this:

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'],
}

But I'd like to not have to modified a module I got from puppet forge because the next time someone else setups up a puppet master they might forget to make the modification. Is there something I can do from the class that includes nova::compute::libvirt ?

You can solve this problem by enabling the redhat_updates yum repo with a yumrepo resource, and then specifying a metaparameter for it to be applied before the class.

yumrepo { "redhat_updates":
  baseurl  => "baseurl",
  descr    => "Redhat Updates",
  enabled  => 1,
  gpgcheck => 0,
  before   => Class['nova::compute::libvirt'],
}

https://docs.puppet.com/puppet/latest/types/yumrepo.html

Resource collectors afford the possibility of overriding attributes of resources declared elsewhere . The syntax would be:

Package<| title == 'libvirt-nwfilter' |> {
    install_options => ['--enablerepo', 'redhat_updates']
}

That alternative avoids modifying the repository definition, and it does not require introducing any new ordering relationships. Beware, however, that collectors always realize any matching virtual resources. Beware also that this approach is very powerful, and thus very easy to abuse to get yourself in trouble. With great power comes great responsibility.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM