Last active
January 2, 2018 11:26
-
-
Save todgru/1caf3333021c9b40c36e to your computer and use it in GitHub Desktop.
Puppet unresponsive nodes list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I'm sure there is a more ruby way of doing this | |
# house keeping | |
mv puppet.dead puppet.dead.old | |
# get a list of all the unresponsive nodes | |
/opt/puppet/bin/rake -f /opt/puppet/share/puppet-dashboard/Rakefile node:unlist >> puppet.dead | |
#deactivate unresponsive nodes | |
cat puppet.dead | xargs -I {} puppet node deactivate {} | |
# clean unresponsive nodes | |
cat puppet.dead | xargs -I {} puppet node clean {} | |
# remove unresponse nodes from db and puppet console | |
cat puppet.dead | xargs -I {} /opt/puppet/bin/rake -f /opt/puppet/share/puppet-dashboard/Rakefile node:del['{}'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Puppet command line(CLI) tool to list unresponsive nodes. | |
# Add this to the `/opt/puppet/share/puppet-dashboard/lib/tasks` directory. | |
# `rake node:unrelist` to show all unresponsive nodes by name. | |
# Copied and modified from original Puppet `node:list` rake task. | |
# | |
$: << File.dirname(__FILE__) | |
require 'rake_helpers' | |
namespace :node do | |
desc 'List unresponsive nodes' | |
repeatable_task :unrelist, [:match] => :environment do |task| | |
names = Node.unresponsive.map(&:name) | |
regex = task.get_parameter(:match) | |
names.grep(/#{regex}/).map{|n| puts n} | |
end | |
end |
A newer version written in Ruby for PE 2016 can be found here: https://gist.github.com/todgru/df110c5139ce02c397988fcc41a889ee
The Ruby code is simple enough that a bash script could implement the same thing. Just use curl ❤️
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's so easy now, tahnk you :)