From f8bd2d8a5d7725c1974b7c81816a086b6c10bf4c Mon Sep 17 00:00:00 2001 From: Corey Hickey Date: Tue, 2 Jan 2024 10:53:52 -0800 Subject: [PATCH] add a workaround for rabbitmq_vhost when running with --noop or --tags This fixes the error: Error: Could not prefetch rabbitmq_vhost provider 'rabbitmqctl': Command rabbitmqctl is missing The problem, and the workaround, are the same as that described in commit 8a3a27a0584666e71bf64b2eb49adf79133939c1, "add a workaround for running with --noop or --tags". This is necessary because the original workaround is for rabbitmqctl_list(), whereas rabbitmq_version() calls rabbitmqctl() directly. Other callers of rabbitmq_version() should not need this workaround, since they are not run in a state where rabbitmq itself is not yet installed. --- lib/puppet/provider/rabbitmq_vhost/rabbitmqctl.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/puppet/provider/rabbitmq_vhost/rabbitmqctl.rb b/lib/puppet/provider/rabbitmq_vhost/rabbitmqctl.rb index 0fd49ba04..d063bc478 100644 --- a/lib/puppet/provider/rabbitmq_vhost/rabbitmqctl.rb +++ b/lib/puppet/provider/rabbitmq_vhost/rabbitmqctl.rb @@ -19,6 +19,11 @@ def self.prefetch(resources) # we only deal with vhost metadata >= version 3.11.0 def self.supports_metadata? Puppet::Util::Package.versioncmp(rabbitmq_version, '3.11') >= 0 + rescue Puppet::MissingCommand + # See comment on the definition of rabbitmqctl_list in rabbitmqctl_cli.rb; + # the same rationale applies here. + Puppet.debug('supports_metadata?: rabbitmqctl command not found; assuming rabbitmq is not installed') + false end def supports_metadata?