summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2005-08-23 16:09:14 +0000
committerLuke Kanies <luke@madstop.com>2005-08-23 16:09:14 +0000
commit6029ef7812765775306ff8394005c326e359d886 (patch)
tree32cbe5ea68e0e9fbdc0935d0b41e58fdfcba9e3d /bin
parente87eb58ce8dc40ba8c66233bf17cea61094e7647 (diff)
downloadpuppet-6029ef7812765775306ff8394005c326e359d886.tar.gz
puppet-6029ef7812765775306ff8394005c326e359d886.tar.xz
puppet-6029ef7812765775306ff8394005c326e359d886.zip
Moving all files into a consolidated trunk. All tests pass except the known-failing certificate test, but there appear to be some errors that are incorrectly not resulting in failurs. I will track those down ASAP.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@576 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'bin')
-rwxr-xr-xbin/certmgr.rb44
-rwxr-xr-xbin/filebucketd40
-rwxr-xr-xbin/puppet129
-rwxr-xr-xbin/puppetca127
-rwxr-xr-xbin/puppetd102
-rwxr-xr-xbin/puppetdoc129
-rwxr-xr-xbin/puppetmasterd89
7 files changed, 660 insertions, 0 deletions
diff --git a/bin/certmgr.rb b/bin/certmgr.rb
new file mode 100755
index 000000000..37f4a406c
--- /dev/null
+++ b/bin/certmgr.rb
@@ -0,0 +1,44 @@
+#!/usr/bin/ruby -w
+
+#--------------------
+# the puppet client
+#
+# $Id$
+
+
+require 'puppet'
+require 'puppet/openssl'
+require 'getoptlong'
+
+result = GetoptLong.new(
+ [ "--debug", "-d", GetoptLong::NO_ARGUMENT ],
+ [ "--help", "-h", GetoptLong::NO_ARGUMENT ]
+)
+
+check = false
+
+result.each { |opt,arg|
+ case opt
+ when "--debug":
+ when "--check":
+ when "--help":
+ puts "There is no help yet"
+ exit
+ else
+ puts "Invalid option '#{opt}'"
+ exit(10)
+ end
+}
+
+Puppet[:logdest] = :console
+Puppet[:loglevel] = :info
+
+rootcert = Puppet[:rootcert]
+rootkey = Puppet[:rootkey]
+rootkey = Puppet[:rootkey]
+
+unless rootcert
+ raise "config unset"
+end
+
+#mkcertsdir(File.basename(rootcert))
diff --git a/bin/filebucketd b/bin/filebucketd
new file mode 100755
index 000000000..2e7177d6a
--- /dev/null
+++ b/bin/filebucketd
@@ -0,0 +1,40 @@
+#!/usr/bin/ruby -w
+
+#--------------------
+# accept and serve files
+#
+# $Id$
+
+require 'getoptlong'
+require 'puppet/filebucket'
+
+ #[ "--size", "-s", GetoptLong::REQUIRED_ARGUMENT ],
+result = GetoptLong.new(
+ [ "--help", "-h", GetoptLong::NO_ARGUMENT ]
+)
+
+result.each { |opt,arg|
+ case opt
+ when "--help"
+ puts "There is no help yet"
+ exit
+ else
+ raise "Invalid option '#{opt}'"
+ end
+}
+
+begin
+ server = FileBucket::BucketWebserver.new(
+ :Bucket => File.expand_path("~/.puppet/bucket"),
+ :Debug => true,
+ :Port => 8080
+ )
+ trap(:INT) { server.shutdown }
+ server.start
+ #server = FileBucket::BucketServer.new(
+ # :Bucket => File.expand_path("~/.puppet/bucket")
+ #)
+rescue => detail
+ $stderr.puts detail
+ exit(1)
+end
diff --git a/bin/puppet b/bin/puppet
new file mode 100755
index 000000000..094cefd0a
--- /dev/null
+++ b/bin/puppet
@@ -0,0 +1,129 @@
+#!/usr/bin/ruby -w
+
+#
+# = Synopsis
+#
+# Run a stand-alone +puppet+ script.
+#
+# = Usage
+#
+# puppet [-V|--version] [-d|--debug] [-v|--verbose] [-l|--logfile <file>] [-h|--help] <file>
+#
+# = Description
+#
+# This is the standalone +puppet+ execution script; use it to execute
+# individual scripts that you write. If you need to execute site-wide
+# scripts, use +puppetd+ and +puppetmasterd+.
+#
+# = Options
+#
+# debug::
+# Enable full debugging.
+#
+# help::
+# Print this help message
+#
+# logfile::
+# Where to send messages. Defaults to sending messages to the console.
+#
+# = Example
+#
+# puppet -l /tmp/script.log script.pp
+#
+# = Author
+#
+# Luke Kanies
+#
+# = Copyright
+#
+# Copyright (c) 2005 Reductive Labs, LLC
+# Licensed under the Gnu Public License
+
+require 'puppet'
+require 'puppet/server'
+require 'puppet/client'
+require 'getoptlong'
+
+$haveusage = true
+
+begin
+ require 'rdoc/usage'
+rescue
+ $haveusage = false
+end
+
+ result = GetoptLong.new(
+ [ "--version", "-V", GetoptLong::NO_ARGUMENT ],
+ [ "--logfile", "-l", GetoptLong::REQUIRED_ARGUMENT ],
+ [ "--debug", "-d", GetoptLong::NO_ARGUMENT ],
+ [ "--verbose", "-v", GetoptLong::NO_ARGUMENT ],
+ [ "--help", "-h", GetoptLong::NO_ARGUMENT ]
+ )
+
+debug = false
+verbose = false
+logfile = false
+
+begin
+ result.each { |opt,arg|
+ case opt
+ when "--version"
+ puts "%s" % Puppet.version
+ exit
+ when "--help"
+ if $haveusage
+ RDoc::usage && exit
+ else
+ puts "No help available unless you have RDoc::usage installed"
+ exit
+ end
+ when "--verbose"
+ verbose = true
+ when "--debug"
+ debug = true
+ when "--logfile"
+ logfile = arg
+ else
+ $stderr.puts "Invalid option '#{opt}'"
+ Rdoc::usage(1,'usage')
+ end
+ }
+rescue GetoptLong::InvalidOption => detail
+ RDoc::usage(1,'usage')
+end
+
+if debug
+ Puppet[:loglevel] = :debug
+elsif verbose
+ Puppet[:loglevel] = :info
+end
+
+if logfile
+ Puppet[:logdest] = logfile
+end
+
+begin
+ server = Puppet::Master.new(
+ :File => ARGV.shift,
+ :Local => true
+ )
+rescue => detail
+ $stderr.puts detail
+ exit(1)
+end
+
+begin
+ client = Puppet::Client.new(
+ :Server => server
+ )
+rescue => detail
+ $stderr.puts detail
+ exit(1)
+end
+
+begin
+ client.getconfig
+rescue => detail
+ $stderr.puts detail
+ exit(1)
+end
diff --git a/bin/puppetca b/bin/puppetca
new file mode 100755
index 000000000..358f721b1
--- /dev/null
+++ b/bin/puppetca
@@ -0,0 +1,127 @@
+#!/usr/bin/ruby -w
+
+#--------------------
+# the puppet client
+#
+# $Id$
+
+
+require 'puppet'
+require 'puppet/sslcertificates'
+require 'getoptlong'
+
+result = GetoptLong.new(
+ [ "--ssldir", GetoptLong::REQUIRED_ARGUMENT ],
+ [ "--list", "-l", GetoptLong::NO_ARGUMENT ],
+ [ "--sign", "-s", GetoptLong::NO_ARGUMENT ],
+ [ "--debug", "-d", GetoptLong::NO_ARGUMENT ],
+ [ "--verbose", "-v", GetoptLong::NO_ARGUMENT ],
+ [ "--all", "-a", GetoptLong::NO_ARGUMENT ],
+ [ "--cadir", GetoptLong::REQUIRED_ARGUMENT ],
+ [ "--generate", "-g", GetoptLong::NO_ARGUMENT ],
+ [ "--help", "-h", GetoptLong::NO_ARGUMENT ]
+)
+
+mode = nil
+all = false
+generate = nil
+
+result.each { |opt,arg|
+ case opt
+ when "--help"
+ puts "There is no help yet"
+ exit
+ when "--list"
+ mode = :list
+ when "--sign"
+ mode = :sign
+ when "--all"
+ all = true
+ when "--verbose"
+ Puppet[:loglevel] = :info
+ when "--debug"
+ Puppet[:loglevel] = :debug
+ when "--generate"
+ generate = arg
+ mode = :generate
+ when "--cadir"
+ Puppet[:cadir] = arg
+ when "--ssldir"
+ Puppet[:ssldir] = arg
+ else
+ puts "Invalid option '#{opt}'"
+ exit(10)
+ end
+}
+
+ca = Puppet::SSLCertificates::CA.new()
+
+unless mode
+ $stderr.puts "You must specify --list or --sign"
+ exit(12)
+end
+
+hosts = ca.list
+unless hosts.length > 0 or mode == :generate
+ Puppet.info "No waiting requests"
+ exit(0)
+end
+
+case mode
+when :list
+ puts hosts.join("\n")
+when :sign
+ unless ARGV.length > 0 or all
+ $stderr.puts(
+ "You must specify to sign all certificates or you must specify hostnames"
+ )
+ exit(24)
+ end
+
+ unless all
+ hosts = hosts.find_all { |host|
+ ARGV.include?(host)
+ }
+ end
+
+ hosts.each { |host|
+ begin
+ csr = ca.getclientcsr(host)
+ rescue => detail
+ $stderr.puts "Could not retrieve request for %s: %s" % [host, detail]
+ end
+
+ begin
+ ca.sign(csr)
+ rescue => detail
+ $stderr.puts "Could not sign request for %s: %s" % [host, detail]
+ end
+
+ begin
+ ca.removeclientcsr(host)
+ rescue => detail
+ $stderr.puts "Could not remove request for %s: %s" % [host, detail]
+ end
+ }
+when :generate
+ # we need to generate a certificate for a host
+ unless ARGV.length > 0
+ $stderr.puts "You must specify hosts to generate certs for"
+ exit(84)
+ end
+ ARGV.each { |host|
+ puts "Generating certificate for %s" % host
+ cert = Puppet::SSLCertificates::Certificate.new(
+ :name => host
+ )
+ cert.mkcsr
+ signedcert, cacert = ca.sign(cert.csr)
+
+ cert.cert = signedcert
+ cert.cacert = cacert
+ cert.write
+ }
+else
+ $stderr.puts "Invalid mode %s" % mode
+ exit(42)
+end
diff --git a/bin/puppetd b/bin/puppetd
new file mode 100755
index 000000000..7b5184948
--- /dev/null
+++ b/bin/puppetd
@@ -0,0 +1,102 @@
+#!/usr/bin/ruby
+
+#--------------------
+# the puppet client
+#
+# $Id$
+
+
+$:.unshift '../lib'
+
+require 'puppet'
+require 'puppet/server'
+require 'puppet/client'
+require 'getoptlong'
+
+result = GetoptLong.new(
+ [ "--logfile", "-l", GetoptLong::REQUIRED_ARGUMENT ],
+ [ "--ssldir", GetoptLong::REQUIRED_ARGUMENT ],
+ [ "--fqdn", "-f", GetoptLong::REQUIRED_ARGUMENT ],
+ [ "--server", "-s", GetoptLong::REQUIRED_ARGUMENT ],
+ [ "--secure", GetoptLong::REQUIRED_ARGUMENT ],
+ [ "--port", "-p", GetoptLong::REQUIRED_ARGUMENT ],
+ [ "--noinit", "-n", GetoptLong::NO_ARGUMENT ],
+ [ "--debug", "-d", GetoptLong::NO_ARGUMENT ],
+ [ "--verbose", "-v", GetoptLong::NO_ARGUMENT ],
+ [ "--help", "-h", GetoptLong::NO_ARGUMENT ]
+)
+
+noinit = false
+server = "localhost"
+proto = "http"
+fqdn = nil
+
+result.each { |opt,arg|
+ case opt
+ when "--help"
+ puts "There is no help yet"
+ exit
+ when "--verbose"
+ Puppet[:loglevel] = :info
+ when "--debug"
+ Puppet[:loglevel] = :debug
+ when "--ssldir"
+ Puppet[:ssldir] = arg
+ when "--secure"
+ proto = "https"
+ when "--noinit"
+ noinit = true
+ when "--fqdn"
+ fqdn = arg
+ when "--server"
+ server = arg
+ when "--port"
+ Puppet[:masterport] = arg
+ when "--logfile"
+ Puppet[:logfile] = arg
+ else
+ puts "Invalid option '#{opt}'"
+ exit(10)
+ end
+}
+
+bg = false
+
+unless Puppet[:loglevel] == :debug or Puppet[:loglevel] == :info
+ bg = true
+end
+
+args = {:Server => server}
+if fqdn
+ args[:FQDN] = fqdn
+end
+client = Puppet::Client.new(args)
+
+unless client.readcert
+ begin
+ while ! client.requestcert do
+ Puppet.notice "Could not request certificate"
+ sleep 5
+ end
+ rescue => detail
+ Puppet.err "Could not request certificate: %s" % detail.to_s
+ exit(23)
+ end
+end
+
+if bg
+ Puppet[:logdest] = Puppet[:logfile]
+ client.daemonize
+end
+#client.start
+client.getconfig
+
+#threads = []
+#threads << Thread.new {
+# trap(:INT) {
+# client.shutdown
+# }
+# client.start
+#}
+#
+#client.getconfig
diff --git a/bin/puppetdoc b/bin/puppetdoc
new file mode 100755
index 000000000..e64ca0624
--- /dev/null
+++ b/bin/puppetdoc
@@ -0,0 +1,129 @@
+#!/usr/local/bin/ruby
+#!/usr/bin/ruby -w
+
+#--------------------
+# produce documentation on all of the puppet types
+#
+# $Id$
+
+
+$:.unshift '../lib'
+
+require 'puppet'
+require 'getoptlong'
+
+def tab(num)
+ return $tab * num
+end
+
+result = GetoptLong.new(
+ [ "--logfile", "-l", GetoptLong::REQUIRED_ARGUMENT ],
+ [ "--debug", "-d", GetoptLong::NO_ARGUMENT ],
+ [ "--help", "-h", GetoptLong::NO_ARGUMENT ]
+)
+
+debug = false
+logfile = false
+
+$tab = " "
+
+result.each { |opt,arg|
+ case opt
+ when "--help"
+ puts "There is no help yet"
+ exit
+ when "--debug"
+ debug = true
+ when "--logfile"
+ logfile = arg
+ else
+ raise "Invalid option '#{opt}'"
+ end
+}
+
+puts %{
+==============
+Type Reference
+==============
+
+}
+
+types = {}
+Puppet::Type.eachtype { |type|
+ types[type.name] = type
+}
+puts %{
+---------------
+Meta-Parameters
+---------------
+
+}
+Puppet::Type.eachmetaparam { |param|
+ puts "- **" + param.to_s + "**"
+ puts tab(1) + Puppet::Type.metaparamdoc(param).gsub(/\n\s*/,' ')
+}
+
+puts %{
+-----
+Types
+-----
+
+- *namevar* is the parameter used to uniquely identify a type instance.
+ This is the parameter that gets assigned when a string is provided before
+ the colon in a type declaration.
+- *states* are the aspects of a type that can be changed.
+- *params* control how a type implements the state changes.
+
+
+}
+
+types.sort { |a,b|
+ a.to_s <=> b.to_s
+}.each { |name,type|
+ next if name == :puppet
+ next if name == :component
+
+ puts "
+
+----------------
+
+"
+
+ puts "
+%s
+%s" % [name, "=" * (name.to_s.length + 4)]
+ #String.new('n%s\n') % name.to_s
+ #puts "**" + type.doc.gsub(/\n\s*/, ' ') + "**\n\n"
+ puts type.doc.gsub(/\n\s*/, ' ') + "\n\n"
+ type.buildstatehash
+ #puts tab(1) + "* namevar: %s" % type.namevar
+ puts "%s States\n'''''''''''''''''''''''''''''''" % name.to_s.capitalize
+ type.validstates.sort { |a,b|
+ a.to_s <=> b.to_s
+ }.each { |sname,state|
+ puts "- **%s**" % sname
+ puts tab(1) + state.doc.gsub(/\n\s*/,' ')
+ }
+
+ puts "\n%s Parameters\n''''''''''''''''''''''''''''''" % name.to_s.capitalize
+ type.parameters.sort { |a,b|
+ a.to_s <=> b.to_s
+ }.each { |name,param|
+ print "- **%s**" % name
+ if type.namevar == name and name != :name
+ puts " (*namevar*)"
+ else
+ puts ""
+ end
+ puts tab(1) + type.paramdoc(name).gsub(/\n\s*/,' ')
+ }
+ puts "\n"
+}
+
+puts "
+
+----------------
+
+"
+
+puts "\n*This page autogenerated on %s*" % Time.now
diff --git a/bin/puppetmasterd b/bin/puppetmasterd
new file mode 100755
index 000000000..af5da3ee5
--- /dev/null
+++ b/bin/puppetmasterd
@@ -0,0 +1,89 @@
+#!/usr/bin/ruby -w
+
+#--------------------
+# the central puppet server
+#
+# $Id$
+
+require 'getoptlong'
+require 'puppet'
+require 'puppet/server'
+
+result = GetoptLong.new(
+ [ "--logfile", "-l", GetoptLong::REQUIRED_ARGUMENT ],
+ [ "--manifest", "-m", GetoptLong::REQUIRED_ARGUMENT ],
+ [ "--ssldir", "-s", GetoptLong::REQUIRED_ARGUMENT ],
+ [ "--noinit", "-n", GetoptLong::NO_ARGUMENT ],
+ [ "--debug", "-d", GetoptLong::NO_ARGUMENT ],
+ [ "--verbose", "-v", GetoptLong::NO_ARGUMENT ],
+ [ "--noca", GetoptLong::NO_ARGUMENT ],
+ [ "--help", "-h", GetoptLong::NO_ARGUMENT ]
+)
+
+noinit = false
+ca = true
+
+result.each { |opt,arg|
+ case opt
+ when "--help"
+ puts "There is no help yet"
+ exit
+ when "--verbose"
+ Puppet[:loglevel] = :info
+ when "--debug"
+ Puppet[:debug] = true
+ when "--noca"
+ ca = false
+ when "--ssldir"
+ Puppet[:ssldir] = arg
+ when "--manifest"
+ Puppet[:manifest] = arg
+ when "--noinit"
+ noinit = true
+ when "--logfile"
+ Puppet[:masterlog] = arg
+ else
+ raise "Invalid option '#{opt}'"
+ end
+}
+
+bg = false
+
+Puppet[:autosign] = true
+
+unless Puppet[:loglevel] == :debug or Puppet[:loglevel] == :info
+ bg = true
+end
+
+if bg
+ Puppet[:logdest] = Puppet[:masterlog]
+end
+
+begin
+ # use the default, um, everything
+ #server = Puppet::Server.new(:CA => ca)
+ server = Puppet::Server.new(
+ :Handlers => {
+ :CA => {}, # so that certs autogenerate
+ :Master => {},
+ :Status => {}
+ }
+ )
+rescue => detail
+ $stderr.puts detail
+ exit(1)
+end
+
+if bg
+ server.daemonize
+end
+
+trap(:INT) {
+ server.shutdown
+}
+begin
+ server.start
+rescue => detail
+ Puppet.err "Could not start puppetmaster: %s" % detail
+ exit(1)
+end