Note that the license has changed from GPLv2 to ASL 2.0. With 2.7, the puppetstoredconfigclean script has been dropped from ext/ because 'puppet node clean' performs this task. Unfortunately, it does more than just cleaning up the storeconfig db (removing signed certificates and reports), so we can't just call 'puppet node clean'. Instead, restore the script and add a note that it is deprecated, pointing to 'puppet node clean' as the supported method of cleaning storedconfig and other node data.epel9
parent
2b0f973a67
commit
ffddaa3465
@ -1,60 +0,0 @@
|
||||
From e3fc5c4960de988b81e470d9e1f6a66c1bfd15e2 Mon Sep 17 00:00:00 2001
|
||||
From: Dominic Cleal <dcleal@redhat.com>
|
||||
Date: Mon, 19 Dec 2011 22:56:43 +0000
|
||||
Subject: [PATCH] (#11414) Test Augeas versions correctly with versioncmp
|
||||
|
||||
The release of Augeas 0.10.0 broke simplistic version comparisons with the >=
|
||||
operator, so now use versioncmp.
|
||||
|
||||
(Cherry pick of 735acad5 but without the accompanying test, which doesn't exist
|
||||
in 2.6.x).
|
||||
---
|
||||
lib/puppet/provider/augeas/augeas.rb | 8 +++++---
|
||||
1 files changed, 5 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/lib/puppet/provider/augeas/augeas.rb b/lib/puppet/provider/augeas/augeas.rb
|
||||
index 7dbd062..70406f6 100644
|
||||
--- a/lib/puppet/provider/augeas/augeas.rb
|
||||
+++ b/lib/puppet/provider/augeas/augeas.rb
|
||||
@@ -19,9 +19,11 @@
|
||||
|
||||
require 'augeas' if Puppet.features.augeas?
|
||||
require 'strscan'
|
||||
+require 'puppet/util/package'
|
||||
|
||||
Puppet::Type.type(:augeas).provide(:augeas) do
|
||||
include Puppet::Util
|
||||
+ include Puppet::Util::Package
|
||||
|
||||
confine :true => Puppet.features.augeas?
|
||||
|
||||
@@ -143,7 +145,7 @@ def open_augeas
|
||||
debug("Opening augeas with root #{root}, lens path #{load_path}, flags #{flags}")
|
||||
@aug = Augeas::open(root, load_path,flags)
|
||||
|
||||
- debug("Augeas version #{get_augeas_version} is installed") if get_augeas_version >= "0.3.6"
|
||||
+ debug("Augeas version #{get_augeas_version} is installed") if versioncmp(get_augeas_version, "0.3.6") >= 0
|
||||
|
||||
if resource[:incl]
|
||||
aug.set("/augeas/load/Xfm/lens", resource[:lens])
|
||||
@@ -279,7 +281,7 @@ def need_to_run?
|
||||
# If we have a verison of augeas which is at least 0.3.6 then we
|
||||
# can make the changes now, see if changes were made, and
|
||||
# actually do the save.
|
||||
- if return_value and get_augeas_version >= "0.3.6"
|
||||
+ if return_value and versioncmp(get_augeas_version, "0.3.6") >= 0
|
||||
debug("Will attempt to save and only run if files changed")
|
||||
set_augeas_save_mode(SAVE_NOOP)
|
||||
do_execute_changes
|
||||
@@ -303,7 +305,7 @@ def execute_changes
|
||||
# Re-connect to augeas, and re-execute the changes
|
||||
begin
|
||||
open_augeas
|
||||
- set_augeas_save_mode(SAVE_OVERWRITE) if get_augeas_version >= "0.3.6"
|
||||
+ set_augeas_save_mode(SAVE_OVERWRITE) if versioncmp(get_augeas_version, "0.3.6") >= 0
|
||||
|
||||
do_execute_changes
|
||||
|
||||
--
|
||||
1.7.5.4
|
||||
|
@ -0,0 +1,17 @@
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
Version: GnuPG v1.4.11 (Darwin)
|
||||
|
||||
iQIcBAABAgAGBQJPhJb0AAoJEBBUt6JL1uwwZDYP/jTEbdhzM5l1t2aUgdNdkk6d
|
||||
otYWofbq4ClsUJfMP4giHUDtlzM5GJCqtMcDeIp8HfqsQNdDIL9BFCLyVCo7VukS
|
||||
EE9VaNv8E5oOyAUAFR8wsETyPN5V7WH34o3XQ2Og1+7O6RSDXEGdWH8dkjioJ78C
|
||||
HNVJvCOEdYKCGgZt6/aZUOvCXAHEolb5lcKeyQCLpK+dP5Bp/Hp/JbVqbhOmiMi2
|
||||
yJm/eV/zlFQ9sz2JovFgAzaJwSDLEetx01ROsDrJks44LaH4ibEu+MoLOPTVIGkk
|
||||
EJJRfojOKrEQIBco1zjvsx7D6gIe/WGlshT9s7bvNGCAmQvhxRoga2PvZwyhQxkE
|
||||
kZbSiBprYW9Z0J2FTdSuLCH9dcAcqVzvtaEJpfgzRM5lkhnSKVaBdwRYOmtSxPP4
|
||||
WyecLc1TZSkJklqc70kTq7pMFrrBkZrgufVlckXrA4ZKV8ZnP1KxPBQ/0lFseOHO
|
||||
qnJV1tNgZUTRrFjPM58Va7TSD5tH5RlFci/k6v+0FowdDgko8J4vXr2XU0QTzPSK
|
||||
CaR75g+jpyBk2XIkTdkQ/VR46imsMw6NEIkPuSbAo1O00BAStvJ4/7xvR+dZQ1nj
|
||||
tYHO3naagP/rPRxbYZJek6lcKn9frQsx1Epev4VH1mi8NiHmc6aN4BvkxP0L0oUZ
|
||||
mIfuFz6Kwagt5FSue1VL
|
||||
=DjHL
|
||||
-----END PGP SIGNATURE-----
|
@ -0,0 +1,109 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
# Script to clean up stored configs for (a) given host(s)
|
||||
#
|
||||
# Credits:
|
||||
# Script was taken from http://reductivelabs.com/trac/puppet/attachment/wiki/UsingStoredConfiguration/kill_node_in_storedconfigs_db.rb (link no longer valid),
|
||||
# which haven been initially posted by James Turnbull
|
||||
# duritong adapted and improved the script a bit.
|
||||
|
||||
require 'getoptlong'
|
||||
require 'puppet'
|
||||
require 'puppet/rails'
|
||||
|
||||
config = Puppet[:config]
|
||||
|
||||
def printusage(error_code)
|
||||
puts "Usage: #{$0} [ list of hostnames as stored in hosts table ]"
|
||||
puts "\n Options:"
|
||||
puts "--config <puppet config file>"
|
||||
exit(error_code)
|
||||
end
|
||||
|
||||
# Print a deprecation notice, pointing to puppet node clean the supported
|
||||
# method of cleaning nodes in puppet >= 2.7. Unfortunately, puppet node clean
|
||||
# removes far more than just storedconfig data.
|
||||
puts "\nTHIS SCRIPT IS DEPRECATED."
|
||||
puts "'puppet node clean' replaces it, but also removes certificates and reports.\n\n"
|
||||
|
||||
opts = GetoptLong.new(
|
||||
[ "--config", "-c", GetoptLong::REQUIRED_ARGUMENT ],
|
||||
[ "--help", "-h", GetoptLong::NO_ARGUMENT ],
|
||||
[ "--usage", "-u", GetoptLong::NO_ARGUMENT ],
|
||||
[ "--version", "-v", GetoptLong::NO_ARGUMENT ]
|
||||
)
|
||||
|
||||
begin
|
||||
opts.each do |opt, arg|
|
||||
case opt
|
||||
when "--config"
|
||||
config = arg
|
||||
|
||||
when "--help"
|
||||
printusage(0)
|
||||
|
||||
when "--usage"
|
||||
printusage(0)
|
||||
|
||||
when "--version"
|
||||
puts "#{Puppet.version}"
|
||||
exit
|
||||
end
|
||||
end
|
||||
rescue GetoptLong::InvalidOption => detail
|
||||
$stderr.puts "Try '#{$0} --help'"
|
||||
exit(1)
|
||||
end
|
||||
|
||||
printusage(1) unless ARGV.size > 0
|
||||
|
||||
if config != Puppet[:config]
|
||||
Puppet[:config]=config
|
||||
Puppet.settings.parse
|
||||
end
|
||||
|
||||
master = Puppet.settings.instance_variable_get(:@values)[:master]
|
||||
main = Puppet.settings.instance_variable_get(:@values)[:main]
|
||||
db_config = main.merge(master)
|
||||
|
||||
# get default values
|
||||
[:master, :main, :rails].each do |section|
|
||||
Puppet.settings.params(section).each do |key|
|
||||
db_config[key] ||= Puppet[key]
|
||||
end
|
||||
end
|
||||
|
||||
adapter = db_config[:dbadapter]
|
||||
args = {:adapter => adapter, :log_level => db_config[:rails_loglevel]}
|
||||
|
||||
case adapter
|
||||
when "sqlite3"
|
||||
args[:dbfile] = db_config[:dblocation]
|
||||
when "mysql", "mysql2", "postgresql"
|
||||
args[:host] = db_config[:dbserver] unless db_config[:dbserver].to_s.empty?
|
||||
args[:username] = db_config[:dbuser] unless db_config[:dbuser].to_s.empty?
|
||||
args[:password] = db_config[:dbpassword] unless db_config[:dbpassword].to_s.empty?
|
||||
args[:database] = db_config[:dbname] unless db_config[:dbname].to_s.empty?
|
||||
args[:port] = db_config[:dbport] unless db_config[:dbport].to_s.empty?
|
||||
socket = db_config[:dbsocket]
|
||||
args[:socket] = socket unless socket.to_s.empty?
|
||||
else
|
||||
raise ArgumentError, "Invalid db adapter #{adapter}"
|
||||
end
|
||||
|
||||
args[:database] = "puppet" unless not args[:database].to_s.empty?
|
||||
|
||||
ActiveRecord::Base.establish_connection(args)
|
||||
|
||||
ARGV.each do |hostname|
|
||||
if @host = Puppet::Rails::Host.find_by_name(hostname.strip)
|
||||
print "Removing #{hostname} from storedconfig..."
|
||||
$stdout.flush
|
||||
@host.destroy
|
||||
puts "done."
|
||||
else
|
||||
puts "Error: Can't find host #{hostname}."
|
||||
end
|
||||
end
|
||||
|
||||
exit 0
|
Loading…
Reference in new issue