diff --git a/README.md b/README.md index c6882272..303ad353 100644 --- a/README.md +++ b/README.md @@ -290,6 +290,11 @@ rabbitmq_cluster '[{"name":"rabbit@rabbit1","type":"disc"},{"name":"rabbit@rabbi end ``` +#### Removing nodes from cluster + +This cookbook provides the primitives to remove a node from a cluster via helper functions but do not include these in any recipes. This is something that is potentially very dangerous and different deployments will have different needs and IF you decide you need this it should be implemented in your wrapper with EXTREME caution. There are 2 helper methods for 2 different sceneries: +- removing self from cluster. This should likely only be considered for machines on a normal decommission. +- removing another node from cluster. This should only be done once you are sure the machine is gone and won't come back. ## Limitations diff --git a/libraries/helpers.rb b/libraries/helpers.rb new file mode 100644 index 00000000..fa52b6a7 --- /dev/null +++ b/libraries/helpers.rb @@ -0,0 +1,22 @@ +module RabbitMQCookbook + module Helpers + require 'mixlib/shellout' + + def remove_self_from_cluster + # stop rmq + stop_rmq = Mixlib::ShellOut.new('rabbitmqctl stop_app') + stop_rmq.run_command + stop_rmq.error! + # remove self from cluster + remove_from_cluster = Mixlib::ShellOut.new('rabbitmqctl reset') + remove_from_cluster.run_command + remove_from_cluster.error! + end + + def remove_remote_node_from_cluster(rmq_node) + remove_from_cluster = Mixlib::ShellOut.new("rabbitmqctl forget_cluster_node #{rmq_node}") + remove_from_cluster.run_command + remove_from_cluster.error! + end + end +end