GitLab upgraded to 13.7.4-ee.0 - changelog: https://gitlab.com/gitlab-org/gitlab/blob/master/CHANGELOG-EE.md

plugin.rb 1.87 KB
Newer Older
Michael Klishin's avatar
Michael Klishin committed
1 2
# frozen_string_literal: true
#
3
# Cookbook:: rabbitmq
Michael Klishin's avatar
Michael Klishin committed
4 5
# Provider:: plugin
#
6 7
# Copyright:: 2012-2018, Chef Software, Inc.
# Copyright:: 2018-2019, Pivotal Software, Inc.
Michael Klishin's avatar
Michael Klishin committed
8 9 10 11 12
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
Spring Operator's avatar
Spring Operator committed
13
#     https://www.apache.org/licenses/LICENSE-2.0
Michael Klishin's avatar
Michael Klishin committed
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

include RabbitMQ::CoreHelpers

def plugin_enabled?(name)
  ENV['PATH'] = "#{ENV['PATH']}:/usr/lib/rabbitmq/bin"
  cmdstr = "rabbitmq-plugins list -q -e '#{name}\\b'"
  cmd = Mixlib::ShellOut.new(cmdstr, env: shell_environment)
  cmd.run_command
  Chef::Log.debug "rabbitmq_plugin_enabled?: #{cmdstr}"
  Chef::Log.debug "rabbitmq_plugin_enabled?: #{cmd.stdout}"
  cmd.error!
  cmd.stdout =~ /\b#{name}\b/
end

action :enable do
  unless plugin_enabled?(new_resource.plugin)
    execute "rabbitmq-plugins enable #{new_resource.plugin}" do
38
      umask '0022'
Michael Klishin's avatar
Michael Klishin committed
39 40 41 42 43 44 45 46 47 48 49 50
      Chef::Log.info "Enabling RabbitMQ plugin '#{new_resource.plugin}'."
      environment shell_environment.merge(
        'PATH' => "#{ENV['PATH']}:/usr/lib/rabbitmq/bin"
      )
      new_resource.updated_by_last_action(true)
    end
  end
end

action :disable do
  if plugin_enabled?(new_resource.plugin)
    execute "rabbitmq-plugins disable #{new_resource.plugin}" do
51
      umask '0022'
Michael Klishin's avatar
Michael Klishin committed
52 53 54 55 56 57 58 59
      Chef::Log.info "Disabling RabbitMQ plugin '#{new_resource.plugin}'."
      environment shell_environment.merge(
        'PATH' => "#{ENV['PATH']}:/usr/lib/rabbitmq/bin"
      )
      new_resource.updated_by_last_action(true)
    end
  end
end