summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Turnbull <james@lovedthanlost.net>2009-12-13 08:41:11 +1100
committerJames Turnbull <james@lovedthanlost.net>2009-12-18 14:35:08 +1100
commitf5960ce2bde4af9af1af8bdf106e83d21afacb5c (patch)
tree2c5e92b97e90e8f81f6f8ab7a266c7e09c1351ba
parent2d88926b76e14c8aa105ad7b1480cee9132fc699 (diff)
downloadpuppet-f5960ce2bde4af9af1af8bdf106e83d21afacb5c.tar.gz
puppet-f5960ce2bde4af9af1af8bdf106e83d21afacb5c.tar.xz
puppet-f5960ce2bde4af9af1af8bdf106e83d21afacb5c.zip
Closed #2937 - Migrated a number of requires to features
-rw-r--r--lib/puppet/application/puppetrun.rb15
-rw-r--r--lib/puppet/feature/base.rb3
-rw-r--r--lib/puppet/feature/selinux.rb3
-rwxr-xr-xlib/puppet/sslcertificates.rb6
-rw-r--r--lib/puppet/util/selinux.rb6
5 files changed, 11 insertions, 22 deletions
diff --git a/lib/puppet/application/puppetrun.rb b/lib/puppet/application/puppetrun.rb
index 2dbd803fa..41ebf9f1a 100644
--- a/lib/puppet/application/puppetrun.rb
+++ b/lib/puppet/application/puppetrun.rb
@@ -1,18 +1,9 @@
-begin
- require 'rubygems'
-rescue LoadError
- # Nothing; we were just doing this just in case
-end
-
-begin
- require 'ldap'
-rescue LoadError
- $stderr.puts "Failed to load ruby LDAP library. LDAP functionality will not be available"
-end
-
require 'puppet'
require 'puppet/application'
+Puppet.warning "RubyGems not installed" unless Puppet.features.rubygems?
+Puppet.warning "Failed to load ruby LDAP library. LDAP functionality will not be available" unless Puppet.features.ldap?
+
Puppet::Application.new(:puppetrun) do
should_not_parse_config
diff --git a/lib/puppet/feature/base.rb b/lib/puppet/feature/base.rb
index c3fb9a2f3..aac04f234 100644
--- a/lib/puppet/feature/base.rb
+++ b/lib/puppet/feature/base.rb
@@ -28,3 +28,6 @@ Puppet.features.add(:augeas, :libs => ["augeas"])
# We have RRD available
Puppet.features.add(:rrd, :libs => ["RRDtool"])
+
+# We have OpenSSL
+Puppet.features.add(:openssl, :libs => ["openssl"])
diff --git a/lib/puppet/feature/selinux.rb b/lib/puppet/feature/selinux.rb
new file mode 100644
index 000000000..84be239fc
--- /dev/null
+++ b/lib/puppet/feature/selinux.rb
@@ -0,0 +1,3 @@
+require 'puppet/util/feature'
+
+Puppet.features.add(:selinux, :libs => ["selinux"])
diff --git a/lib/puppet/sslcertificates.rb b/lib/puppet/sslcertificates.rb
index fb5c1b749..62cfad1f0 100755
--- a/lib/puppet/sslcertificates.rb
+++ b/lib/puppet/sslcertificates.rb
@@ -2,11 +2,7 @@
require 'puppet'
-begin
- require 'openssl'
-rescue LoadError
- raise Puppet::Error, "You must have the Ruby openssl library installed"
-end
+raise Puppet::Error, "You must have the Ruby openssl library installed" unless Puppet.features.openssl?
module Puppet::SSLCertificates
#def self.mkcert(type, name, dnsnames, ttl, issuercert, issuername, serial, publickey)
diff --git a/lib/puppet/util/selinux.rb b/lib/puppet/util/selinux.rb
index f1336f946..331c8eb82 100644
--- a/lib/puppet/util/selinux.rb
+++ b/lib/puppet/util/selinux.rb
@@ -7,11 +7,7 @@
# was abysmal. At this time (2008-11-02) the only distribution providing
# these Ruby SELinux bindings which I am aware of is Fedora (in libselinux-ruby).
-begin
- require 'selinux'
-rescue LoadError
- # Nothing
-end
+Puppet.warning "SELinux not installed" unless Puppet.features.selinux?
require 'pathname'