Skip to content

Instantly share code, notes, and snippets.

@MosesMendoza
Created October 31, 2012 00:34
Show Gist options
  • Save MosesMendoza/3984076 to your computer and use it in GitHub Desktop.
Save MosesMendoza/3984076 to your computer and use it in GitHub Desktop.
From f320eb76e7bd8488b8fb480e051417f052c453ea Mon Sep 17 00:00:00 2001
From: Moses Mendoza <[email protected]>
Date: Tue, 30 Oct 2012 14:33:27 -0700
Subject: [PATCH] Update puppet spec to 3.0.1
This patch updates the puppet spec for version 3.0.1, and removes the
signature file as a source since its not used in the spec anywhere.
Puppet 3.0.1 includes service management files for systemd, which ships
with F17, so this updates the spec to include systemd conditionals where
applicable. Several deprecated manpages and executables, including
everything Puppet shipped in %{_sbindir}, are removed in Puppet 3.0.x as
well; This commit updates the spec as such. The patch for commit a71208b
is removed as its in the 3.0.1 source. Per existing comments, the
deprecated puppetstoredconfigclean.rb script is removed. Puppet 3.0.1
requires ruby >= 1.8.7 and facter >= 1.6.6, so updated BuildRequires and
Requires are added for these. A new requires of hiera >= 1.0.0 is added
as well. Puppet 3.0.1 also absorbed the source of the package
hiera-puppet, so this is replaced and provided here. Finally, the
built-in mongrel support is removed in 3, so the reference to it is
removed in the spec.
Signed-off-by: Moses Mendoza <[email protected]>
diff --git a/0001-Ruby-1.9.3-has-a-different-error-when-require-fails.patch b/0001-Ruby-1.9.3-has-a-different-error-when-require-fails.patch
deleted file mode 100644
index f7fed29..0000000
--- a/0001-Ruby-1.9.3-has-a-different-error-when-require-fails.patch
+++ /dev/null
@@ -1,31 +0,0 @@
-From a71208ba651d96d2ac9792c5358f10231a140e10 Mon Sep 17 00:00:00 2001
-From: Daniel Pittman <[email protected]>
-Date: Fri, 9 Mar 2012 14:43:02 -0800
-Subject: [PATCH/puppet] Ruby 1.9.3 has a different error when `require`
- fails.
-
-The text of the error message when load fails has changed, resulting in the
-test failing. This adapts that to catch the different versions, allowing this
-to pass in all cases.
-
-Signed-off-by: Daniel Pittman <[email protected]>
----
- lib/puppet/provider/confine.rb | 2 +-
- 1 files changed, 1 insertions(+), 1 deletions(-)
-
-diff --git a/lib/puppet/provider/confine.rb b/lib/puppet/provider/confine.rb
-index 6825def..b28d07d 100644
---- a/lib/puppet/provider/confine.rb
-+++ b/lib/puppet/provider/confine.rb
-@@ -25,7 +25,7 @@ class Puppet::Provider::Confine
- begin
- require "puppet/provider/confine/#{name}"
- rescue LoadError => detail
-- unless detail.to_s =~ /No such file/i
-+ unless detail.to_s =~ /No such file|cannot load such file/i
- warn "Could not load confine test '#{name}': #{detail}"
- end
- # Could not find file
---
-1.7.6
-
diff --git a/puppet-2.7.18.tar.gz.asc b/puppet-2.7.18.tar.gz.asc
deleted file mode 100644
index ffa35a6..0000000
--- a/puppet-2.7.18.tar.gz.asc
+++ /dev/null
@@ -1,18 +0,0 @@
------BEGIN PGP SIGNATURE-----
-Version: GnuPG/MacGPG2 v2.0.18 (Darwin)
-Comment: GPGTools - http://gpgtools.org
-
-iQIcBAABAgAGBQJP/JQ9AAoJEBBUt6JL1uwwko0P/igNdI01Lkss73TaRRSGiJcF
-dLSSqyNjrgyiAoZkBTlyL7qPf76l5t7qhzO6cjj6q64e5yaGfZAbr65d4LhIGs7Z
-fcpzC4MpRhcaZKTqp9864Fhwd0UC/rzMAMaR1bRkSLVgcR0F6WXDcoclnwcRZXb5
-e6b51JI85G0lyQB95Gq0SIUZQ/n8OsMDC/IhLpJLCbZIw7jRB1hciFPL6SuMGFlK
-Zw+3ZpMwWGOpLU0bxLL6Nw54vVwJDf1pq/Upi+EChPdkzJQw2rZR0qwDlavNd6Ax
-mEBwFyBOQ/mEiIRZslQk/TYQ+xuq3eCSk11E3ZJ+VDx2h7T4mqdEdZRoYmwliGOW
-EXR/+QmB7Jqmgi0Ue0Y1LYUsydHKvXYTeR8R/wmm4O3qD8CTQ0SxbsemO78o/dp0
-pM++wMjoAKO5vyZ0/3k+kblIzXy+BYdzeqThZArMhV5q3iIm5daYSegyIA4RCSgG
-mnyTGtaSQRQP685gwGdlF9P1kfrhnvw7UK2HW3WDsmkZh9lGlKSM3stwlB4FgXGu
-9OAFFhRVh23Ka5B6CAXBqIdXvjz3LOmKKalxcRwR36UEaJZ4OIlTDMAmbXofOvHq
-YbR0dWBovVMUn7N9vMC5AosOXApbQWNQINW2th21KV4lNvzc76bi3j5iTMsBKARE
-qNhzL1TXuJYNPUv88UxJ
-=mjJz
------END PGP SIGNATURE-----
diff --git a/puppet.spec b/puppet.spec
index 28563ce..217f87d 100644
--- a/puppet.spec
+++ b/puppet.spec
@@ -8,30 +8,32 @@
%global puppet_libdir %(ruby -rrbconfig -e 'puts RbConfig::CONFIG["sitelibdir"]')
%endif
-%global confdir conf/redhat
+# F-17 also ships with systemd; package/use systemd files in this case
+%if 0%{?fedora} >= 17
+%global _with_systemd 1
+%else
+%global _with_systemd 0
+%endif
+
+%global confdir ext/redhat
%global ruby_version %(ruby -rrbconfig -e 'puts RbConfig::CONFIG["ruby_version"]')
Name: puppet
-Version: 2.7.18
+Version: 3.0.1
Release: 1%{?dist}
Summary: A network tool for managing many disparate systems
License: ASL 2.0
URL: http://puppetlabs.com
Source0: http://downloads.puppetlabs.com/%{name}/%{name}-%{version}.tar.gz
-Source1: http://downloads.puppetlabs.com/%{name}/%{name}-%{version}.tar.gz.asc
-Source2: puppetstoredconfigclean.rb
-Source3: puppet-nm-dispatcher
-# https://projects.puppetlabs.com/issues/11325
-# https://github.com/puppetlabs/puppet/commit/a71208ba
-Patch0: 0001-Ruby-1.9.3-has-a-different-error-when-require-fails.patch
-Patch1: 0001-Preserve-timestamps-when-installing-files.patch
+Source1: puppet-nm-dispatcher
+Patch0: 0001-Preserve-timestamps-when-installing-files.patch
Group: System Environment/Base
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
-BuildRequires: facter >= 1.5
-BuildRequires: ruby >= 1.8.5
+BuildRequires: facter >= 1.6.6
+BuildRequires: ruby >= 1.8.7
%if 0%{?fedora} || 0%{?rhel} >= 5
BuildArch: noarch
@@ -51,17 +53,28 @@ Requires: ruby(shadow)
%endif
%endif
-Requires: facter >= 1.5
+Requires: facter >= 1.6.6
+Requires: hiera >= 1.0.0
+Obsoletes: hiera-puppet < 1.0.0
+Provides: hiera-puppet >= 1.0.0
+
+# Puppet 3.x drops ruby 1.8.5 support and adds ruby 1.9 support
%if "%{ruby_version}" == "1.8"
-Requires: ruby >= 1.8.5
+Requires: ruby >= 1.8.7
%endif
%{!?_without_augeas:Requires: ruby(augeas)}
Requires(pre): shadow-utils
+%if 0%{?_with_systemd}
+Requires(post): systemd
+Requires(preun): systemd
+Requires(postun): systemd
+%else
Requires(post): chkconfig
Requires(preun): chkconfig
Requires(preun): initscripts
Requires(postun): initscripts
+%endif
%description
Puppet lets you centrally manage every important aspect of your system using a
@@ -73,10 +86,16 @@ along with obviously discrete elements like packages, services, and files.
Group: System Environment/Base
Summary: Server for the puppet system management tool
Requires: puppet = %{version}-%{release}
+%if 0%{?_with_systemd}
+Requires(post): systemd
+Requires(preun): systemd
+Requires(postun): systemd
+%else
Requires(post): chkconfig
Requires(preun): chkconfig
Requires(preun): initscripts
Requires(postun): initscripts
+%endif
%description server
Provides the central puppet server daemon which provides manifests to clients.
@@ -85,8 +104,7 @@ The server can also function as a certificate authority and file server.
%prep
%setup -q
%patch0 -p1
-%patch1 -p1
-patch -s -p1 < conf/redhat/rundir-perms.patch
+patch -s -p1 < %{confdir}/rundir-perms.patch
# Fix some rpmlint complaints
for f in mac_dscl.pp mac_dscl_revert.pp \
@@ -94,7 +112,7 @@ for f in mac_dscl.pp mac_dscl_revert.pp \
sed -i -e'1d' examples/$f
chmod a-x examples/$f
done
-for f in external/nagios.rb network/http_server/mongrel.rb relationship.rb; do
+for f in external/nagios.rb relationship.rb; do
sed -i -e '1d' lib/puppet/$f
done
chmod +x ext/puppet-load.rb ext/regexp_nodes/regexp_nodes.rb
@@ -117,36 +135,26 @@ install -d -m0755 %{buildroot}%{_datadir}/%{name}/modules
install -d -m0755 %{buildroot}%{_localstatedir}/lib/puppet
install -d -m0755 %{buildroot}%{_localstatedir}/run/puppet
install -d -m0750 %{buildroot}%{_localstatedir}/log/puppet
+
+%if 0%{?_with_systemd}
+%{__install} -d -m0755 %{buildroot}%{_unitdir}
+install -Dp -m0644 ext/systemd/puppetagent.service %{buildroot}%{_unitdir}/puppetagent.service
+install -Dp -m0644 ext/systemd/puppetmaster.service %{buildroot}%{_unitdir}/puppetmaster.service
+%else
install -Dp -m0644 %{confdir}/client.sysconfig %{buildroot}%{_sysconfdir}/sysconfig/puppet
install -Dp -m0755 %{confdir}/client.init %{buildroot}%{_initrddir}/puppet
install -Dp -m0644 %{confdir}/server.sysconfig %{buildroot}%{_sysconfdir}/sysconfig/puppetmaster
install -Dp -m0755 %{confdir}/server.init %{buildroot}%{_initrddir}/puppetmaster
+install -Dp -m0755 %{confdir}/queue.init %{buildroot}%{_initrddir}/puppetqueue
+%endif
+
install -Dp -m0644 %{confdir}/fileserver.conf %{buildroot}%{_sysconfdir}/puppet/fileserver.conf
install -Dp -m0644 %{confdir}/puppet.conf %{buildroot}%{_sysconfdir}/puppet/puppet.conf
install -Dp -m0644 %{confdir}/logrotate %{buildroot}%{_sysconfdir}/logrotate.d/puppet
-# We need something for these ghosted files, otherwise rpmbuild
-# will complain loudly. They won't be included in the binary packages
-touch %{buildroot}%{_sysconfdir}/puppet/puppetmasterd.conf
-touch %{buildroot}%{_sysconfdir}/puppet/puppetca.conf
-touch %{buildroot}%{_sysconfdir}/puppet/puppetd.conf
-
-# Replace redundant man pages with links to the canonical man page
-pushd %{buildroot}%{_mandir}/man8 >/dev/null
-ln -svf puppet-cert.8.gz puppetca.8.gz
-ln -svf puppet-queue.8.gz puppetqd.8.gz
-ln -svf puppet-kick.8.gz puppetrun.8.gz
-ln -svf puppet-describe.8.gz pi.8.gz
-ln -svf puppet-master.8.gz puppetmasterd.8.gz
-ln -svf puppet-filebucket.8.gz filebucket.8.gz
-ln -svf puppet-agent.8.gz puppetd.8.gz
-ln -svf puppet-doc.8.gz puppetdoc.8.gz
-ln -svf puppet-resource.8.gz ralsh.8.gz
-popd >/dev/null
-
# Install a NetworkManager dispatcher script to pickup changes to
# /etc/resolv.conf and such (https://bugzilla.redhat.com/532085).
-install -Dpv %{SOURCE3} \
+install -Dpv %{SOURCE1} \
%{buildroot}%{_sysconfdir}/NetworkManager/dispatcher.d/98-%{name}
# Install the ext/ directory to %%{_datadir}/%%{name}
@@ -154,12 +162,10 @@ install -d %{buildroot}%{_datadir}/%{name}
cp -a ext/ %{buildroot}%{_datadir}/%{name}
# emacs and vim bits are installed elsewhere
rm -rf %{buildroot}%{_datadir}/%{name}/ext/{emacs,vim}
-
-# The puppetstoredconfigclean script was removed now that puppet node clean
-# does this job and more. For folks that were using this, let's provide the
-# script and give them a hint to use puppet node clean. Remove this for the
-# next major release after 2.7.
-install -pv %{SOURCE2} %{buildroot}%{_datadir}/%{name}/ext/
+# remove misc packaging artifacts in source not applicable to rpm
+rm -rf %{buildroot}%{_datadir}/%{name}/ext/{gentoo,freebsd,solaris,suse,windows,osx,ips,debian}
+rm -f %{buildroot}%{_datadir}/%{name}/ext/{build_defaults.yaml,project_data.yaml}
+rm -f %{buildroot}%{_datadir}/%{name}/ext/redhat/*.init
# Install emacs mode files
emacsdir=%{buildroot}%{_datadir}/emacs/site-lisp
@@ -179,27 +185,28 @@ echo "D /var/run/%{name} 0755 %{name} %{name} -" > \
%{buildroot}%{_sysconfdir}/tmpfiles.d/%{name}.conf
%endif
+# Create puppet modules directory for puppet module tool
+mkdir -p %{buildroot}%{_sysconfdir}/%{name}/modules
+
%files
%defattr(-, root, root, 0755)
-%doc CHANGELOG LICENSE README.md examples
-%{_bindir}/pi
+%doc LICENSE README.md examples
%{_bindir}/puppet
-%{_bindir}/ralsh
-%{_bindir}/filebucket
-%{_bindir}/puppetdoc
-%{_sbindir}/puppetca
-%{_sbindir}/puppetd
+%{_bindir}/extlookup2hiera
%{puppet_libdir}/*
+%if 0%{?_with_systemd}
+%{_unitdir}/puppetagent.service
+%else
%{_initrddir}/puppet
+%config(noreplace) %{_sysconfdir}/sysconfig/puppet
+%endif
%dir %{_sysconfdir}/puppet
+%dir %{_sysconfdir}/%{name}/modules
%if 0%{?fedora} >= 15
%config(noreplace) %{_sysconfdir}/tmpfiles.d/%{name}.conf
%endif
-%config(noreplace) %{_sysconfdir}/sysconfig/puppet
%config(noreplace) %{_sysconfdir}/puppet/puppet.conf
%config(noreplace) %{_sysconfdir}/puppet/auth.conf
-%ghost %config(noreplace,missingok) %{_sysconfdir}/puppet/puppetca.conf
-%ghost %config(noreplace,missingok) %{_sysconfdir}/puppet/puppetd.conf
%config(noreplace) %{_sysconfdir}/logrotate.d/puppet
%dir %{_sysconfdir}/NetworkManager
%dir %{_sysconfdir}/NetworkManager/dispatcher.d
@@ -213,33 +220,54 @@ echo "D /var/run/%{name} 0755 %{name} %{name} -" > \
%attr(-, puppet, puppet) %{_localstatedir}/run/puppet
%attr(0750, puppet, puppet) %{_localstatedir}/log/puppet
%attr(-, puppet, puppet) %{_localstatedir}/lib/puppet
-# Exclude man pages from the server package
-%exclude %{_mandir}/man8/puppet-kick.8.gz
-%exclude %{_mandir}/man8/puppet-master.8.gz
-%exclude %{_mandir}/man8/puppet-queue.8.gz
-%exclude %{_mandir}/man8/puppetmasterd.8.gz
-%exclude %{_mandir}/man8/puppetqd.8.gz
-%exclude %{_mandir}/man8/puppetrun.8.gz
%{_mandir}/man5/puppet.conf.5.gz
-%{_mandir}/man8/*.8.gz
+%{_mandir}/man8/puppet.8.gz
+%{_mandir}/man8/puppet-agent.8.gz
+%{_mandir}/man8/puppet-apply.8.gz
+%{_mandir}/man8/puppet-catalog.8.gz
+%{_mandir}/man8/puppet-describe.8.gz
+%{_mandir}/man8/puppet-ca.8.gz
+%{_mandir}/man8/puppet-cert.8.gz
+%{_mandir}/man8/puppet-certificate.8.gz
+%{_mandir}/man8/puppet-certificate_request.8.gz
+%{_mandir}/man8/puppet-certificate_revocation_list.8.gz
+%{_mandir}/man8/puppet-config.8.gz
+%{_mandir}/man8/puppet-device.8.gz
+%{_mandir}/man8/puppet-doc.8.gz
+%{_mandir}/man8/puppet-facts.8.gz
+%{_mandir}/man8/puppet-file.8.gz
+%{_mandir}/man8/puppet-filebucket.8.gz
+%{_mandir}/man8/puppet-help.8.gz
+%{_mandir}/man8/puppet-inspect.8.gz
+%{_mandir}/man8/puppet-instrumentation_data.8.gz
+%{_mandir}/man8/puppet-instrumentation_listener.8.gz
+%{_mandir}/man8/puppet-instrumentation_probe.8.gz
+%{_mandir}/man8/puppet-key.8.gz
+%{_mandir}/man8/puppet-man.8.gz
+%{_mandir}/man8/puppet-module.8.gz
+%{_mandir}/man8/puppet-node.8.gz
+%{_mandir}/man8/puppet-parser.8.gz
+%{_mandir}/man8/puppet-plugin.8.gz
+%{_mandir}/man8/puppet-report.8.gz
+%{_mandir}/man8/puppet-resource.8.gz
+%{_mandir}/man8/puppet-resource_type.8.gz
+%{_mandir}/man8/puppet-secret_agent.8.gz
+%{_mandir}/man8/puppet-status.8.gz
%files server
%defattr(-, root, root, 0755)
-%{_sbindir}/puppetmasterd
-%{_sbindir}/puppetrun
-%{_sbindir}/puppetqd
+%if 0%{?_with_systemd}
+%{_unitdir}/puppetmaster.service
+%else
%{_initrddir}/puppetmaster
+%{_initrddir}/puppetqueue
+%config(noreplace) %{_sysconfdir}/sysconfig/puppetmaster
+%endif
%config(noreplace) %{_sysconfdir}/puppet/fileserver.conf
%dir %{_sysconfdir}/puppet/manifests
-%config(noreplace) %{_sysconfdir}/sysconfig/puppetmaster
-%ghost %config(noreplace,missingok) %{_sysconfdir}/puppet/puppetmasterd.conf
-# Ensure that man pages listed here are excluded from the main package
%{_mandir}/man8/puppet-kick.8.gz
%{_mandir}/man8/puppet-master.8.gz
%{_mandir}/man8/puppet-queue.8.gz
-%{_mandir}/man8/puppetmasterd.8.gz
-%{_mandir}/man8/puppetqd.8.gz
-%{_mandir}/man8/puppetrun.8.gz
# Fixed uid/gid were assigned in bz 472073 (Fedora), 471918 (RHEL-5),
# and 471919 (RHEL-4)
@@ -255,37 +283,81 @@ fi
exit 0
%post
+%if 0%{?_with_systemd}
+/bin/systemctl daemon-reload >/dev/null 2>&1 || :
+%else
/sbin/chkconfig --add puppet || :
+%endif
%post server
+%if 0%{?_with_systemd}
+/bin/systemctl daemon-reload >/dev/null 2>&1 || :
+%else
/sbin/chkconfig --add puppetmaster || :
+%endif
%preun
+%if 0%{?_with_systemd}
+if [ "$1" -eq 0 ] ; then
+ /bin/systemctl --no-reload disable puppetagent.service > /dev/null 2>&1 || :
+ /bin/systemctl stop puppetagent.service > /dev/null 2>&1 || :
+ /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+fi
+%else
if [ "$1" = 0 ] ; then
/sbin/service puppet stop >/dev/null 2>&1
/sbin/chkconfig --del puppet || :
fi
+%endif
%preun server
+%if 0%{?_with_systemd}
+if [ $1 -eq 0 ] ; then
+ /bin/systemctl --no-reload disable puppetmaster.service > /dev/null 2>&1 || :
+ /bin/systemctl stop puppetmaster.service > /dev/null 2>&1 || :
+ /bin/systemctl daemon-reload >/dev/null 2>&1 || :
+fi
+%else
if [ "$1" = 0 ] ; then
/sbin/service puppetmaster stop >/dev/null 2>&1
/sbin/chkconfig --del puppetmaster || :
fi
+%endif
%postun
+%if 0%{?_with_systemd}
+if [ $1 -ge 1 ] ; then
+ /bin/systemctl try-restart puppetagent.service >/dev/null 2>&1 || :
+fi
+%else
if [ "$1" -ge 1 ]; then
/sbin/service puppet condrestart >/dev/null 2>&1 || :
fi
+%endif
%postun server
+%if 0%{?_with_systemd}
+if [ $1 -ge 1 ] ; then
+ /bin/systemctl try-restart puppetmaster.service >/dev/null 2>&1 || :
+fi
+%else
if [ "$1" -ge 1 ]; then
/sbin/service puppetmaster condrestart >/dev/null 2>&1 || :
fi
+%endif
%clean
rm -rf %{buildroot}
%changelog
+* Tue Oct 30 2012 Moses Mendoza <[email protected]> - 3.0.1-1
+- Update to 3.0.1
+- Update new dependencies (ruby >= 1.8.7, facter >= 1.6.6, hiera >= 1.0.0)
+- Update for manpage and file changes in upstream
+- Add conditionals for systemd service management
+- Remove signature file from sources, not used in spec
+- Remove 0001-Ruby-1.9.3-has-a-different-error-when-require-fails.patch
+
* Wed Jul 11 2012 Todd Zullinger <[email protected]> - 2.7.18-1
- Update to 2.7.17, fixes CVE-2012-3864, CVE-2012-3865, CVE-2012-3866,
CVE-2012-3867
diff --git a/puppetstoredconfigclean.rb b/puppetstoredconfigclean.rb
deleted file mode 100644
index 3d0abdd..0000000
--- a/puppetstoredconfigclean.rb
+++ /dev/null
@@ -1,109 +0,0 @@
-#!/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
--
1.7.7.6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment