Skip to content

Instantly share code, notes, and snippets.

@todgru
Last active January 2, 2018 11:26
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save todgru/1caf3333021c9b40c36e to your computer and use it in GitHub Desktop.
Save todgru/1caf3333021c9b40c36e to your computer and use it in GitHub Desktop.
Puppet unresponsive nodes list
# 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['{}']
# 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
@balunia
Copy link

balunia commented Nov 23, 2015

It's so easy now, tahnk you :)

@todgru
Copy link
Author

todgru commented Feb 7, 2017

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