diff options
-rw-r--r-- | Rakefile | 121 | ||||
-rw-r--r-- | conf/redhat/client.cron | 24 | ||||
-rw-r--r-- | conf/redhat/client.init | 67 | ||||
-rw-r--r-- | conf/redhat/client.sysconfig | 11 | ||||
-rw-r--r-- | conf/redhat/fileserver.conf | 12 | ||||
-rw-r--r-- | conf/redhat/puppet.spec | 136 | ||||
-rw-r--r-- | conf/redhat/server.init | 89 | ||||
-rw-r--r-- | conf/redhat/server.sysconfig | 9 | ||||
-rw-r--r-- | lib/puppet.rb | 2 | ||||
-rw-r--r-- | lib/puppet/client/master.rb | 1 | ||||
-rw-r--r-- | lib/puppet/config.rb | 53 | ||||
-rw-r--r-- | lib/puppet/type.rb | 2 | ||||
-rwxr-xr-x | test/other/config.rb | 44 |
13 files changed, 540 insertions, 31 deletions
@@ -7,11 +7,19 @@ rescue Exception nil end -require 'rdoc/rdoc' +$rdoc = true +begin + require 'rdoc/rdoc' +rescue => detail + $rdoc = false + puts "No rdoc: %s" % detail +end require 'rake/clean' require 'rake/testtask' -require 'rake/rdoctask' +if $rdoc + require 'rake/rdoctask' +end CLEAN.include('**/*.o') CLOBBER.include('doc/*') @@ -89,28 +97,32 @@ end # rdoc.rdoc_files.include('lib/**/*.rb', 'doc/**/*.rdoc') #} -Rake::RDocTask.new(:html) { |rdoc| - rdoc.rdoc_dir = 'html' - rdoc.template = 'html' - rdoc.title = "Puppet" - rdoc.options << '--line-numbers' << '--inline-source' << '--main' << 'README' - rdoc.rdoc_files.include('README', 'LICENSE', 'TODO', 'CHANGELOG') - rdoc.rdoc_files.include('lib/**/*.rb') - CLEAN.include("html") -} - -task :ri do |ri| - files = ['README', 'LICENSE', 'TODO', 'CHANGELOG'] + Dir.glob('lib/**/*.rb') - puts "files are \n%s" % files.join("\n") - begin - ri = RDoc::RDoc.new - ri.document(["--ri-site"] + files) - rescue RDoc::RDocError => detail - puts "Failed to build docs: %s" % detail - return nil - rescue LoadError - puts "Missing rdoc; cannot build documentation" - return nil +if $rdoc + Rake::RDocTask.new(:html) { |rdoc| + rdoc.rdoc_dir = 'html' + rdoc.template = 'html' + rdoc.title = "Puppet" + rdoc.options << '--line-numbers' << '--inline-source' << '--main' << 'README' + rdoc.rdoc_files.include('README', 'LICENSE', 'TODO', 'CHANGELOG') + rdoc.rdoc_files.include('lib/**/*.rb') + CLEAN.include("html") + } +end + +if $rdoc + task :ri do |ri| + files = ['README', 'LICENSE', 'TODO', 'CHANGELOG'] + Dir.glob('lib/**/*.rb') + puts "files are \n%s" % files.join("\n") + begin + ri = RDoc::RDoc.new + ri.document(["--ri-site"] + files) + rescue RDoc::RDocError => detail + puts "Failed to build docs: %s" % detail + return nil + rescue LoadError + puts "Missing rdoc; cannot build documentation" + return nil + end end end @@ -124,6 +136,7 @@ PKG_FILES = FileList[ 'lib/**/*.rb', 'test/**/*.rb', 'bin/**/*', + 'conf/**/*', 'ext/**/*', 'examples/**/*' ] @@ -251,6 +264,7 @@ task :release => [ :tag, # tag everything before we make a bunch of extra dirs :html, :package, + :fedorarpm, :copy ] do @@ -303,16 +317,29 @@ task :update_version => [:prerelease] do open("lib/puppet.rb") do |rakein| open("lib/puppet.rb.new", "w") do |rakeout| rakein.each do |line| - if line =~ /^\s*PUPPETVERSION\s*=\s*/ - rakeout.puts "PUPPETVERSION = '#{PKG_VERSION}'" + if line =~ /^(\s*)PUPPETVERSION\s*=\s*/ + rakeout.puts "#{$1}PUPPETVERSION = '#{PKG_VERSION}'" else rakeout.puts line end end end end - mv "lib/puppet.rb.new", "lib/puppet.rb" + + open("conf/redhat/puppet.spec") do |rakein| + open("conf/redhat/puppet.spec.new", "w") do |rakeout| + rakein.each do |line| + if line =~ /^Version:=\s*/ + rakeout.puts "Version: '#{PKG_VERSION}'" + else + rakeout.puts line + end + end + end + end + mv "conf/redhat/puppet.spec.new", "conf/redhat/puppet.spec" + if ENV['RELTEST'] announce "Release Task Testing, skipping commiting of new version" else @@ -322,12 +349,14 @@ task :update_version => [:prerelease] do end desc "Copy the newly created package into the downloads directory" -task :copy => [:package, :html] do +task :copy => [:package, :html, :fedorarpm] do + puts Dir.getwd sh %{cp pkg/puppet-#{PKG_VERSION}.gem #{DOWNDIR}/gems} sh %{generate_yaml_index.rb -d #{DOWNDIR}} sh %{cp pkg/puppet-#{PKG_VERSION}.tgz #{DOWNDIR}/puppet} sh %{ln -sf puppet-#{PKG_VERSION}.tgz #{DOWNDIR}/puppet/puppet-latest.tgz} sh %{cp -r html #{DOWNDIR}/puppet/apidocs} + sh %{rsync -av /home/luke/rpm/. #{DOWNDIR}/rpm} end desc "Tag all the SVN files with the latest release number (REL=x.y.z)" @@ -365,4 +394,40 @@ task :hosttest do #end end +desc "Create an RPM" +task :rpm do + tarball = File.join(Dir.getwd, "pkg", "puppet-#{PKG_VERSION}.tgz") + + sourcedir = `rpm --define 'name puppet' --define 'version #{PKG_VERSION}' --eval '%_sourcedir'`.chomp + specdir = `rpm --define 'name puppet' --define 'version #{PKG_VERSION}' --eval '%_specdir'`.chomp + basedir = File.dirname(sourcedir) + + if ! FileTest::exist?(sourcedir) + FileUtils.mkdir_p(sourcedir) + end + FileUtils.mkdir_p(basedir) + + target = "#{sourcedir}/#{File::basename(tarball)}" + + sh %{cp %s %s} % [tarball, target] + sh %{cp conf/redhat/puppet.spec %s/puppet.spec} % basedir + + Dir.chdir(basedir) do + system("rpmbuild -ba puppet.spec") + end + + sh %{mv %s/puppet.spec %s} % [basedir, specdir] +end + +desc "Create an rpm on a system that can actually do so" +task :fedorarpm => [:package] do + sh %{ssh fedora1 'cd puppet; rake rpm'} +end + +desc "Create a Native Package" +task :nativepkg do + # Okay, first we get a file list + +end + # $Id$ diff --git a/conf/redhat/client.cron b/conf/redhat/client.cron new file mode 100644 index 000000000..cb309585d --- /dev/null +++ b/conf/redhat/client.cron @@ -0,0 +1,24 @@ +#!/bin/sh + +if [ -f /etc/sysconfig/puppet ]; then + . /etc/sysconfig/puppet +fi + +# The server must be specified explicitly +if [ -z "${PUPPET_SERVER}" ]; then + echo $"No puppet server specified." + return 1 +fi + +[ -z "$PUPPET_LOG" ] && PUPPET_LOG="/var/log/puppet.log" +[ -z "$PUPPET_PORT" ] && PUPPET_PORT=8139 +PUPPET_OPTS="\ + --server=$PUPPET_SERVER \ + --port=$PUPPET_PORT \ + --logdest=$PUPPET_LOG \ + $PUPPET_EXTRA_OPTS" + +# Run if puppet is enabled +if [ -f /var/lock/subsys/puppet ]; then + /usr/sbin/puppetd ${PUPPET_OPTS} +fi diff --git a/conf/redhat/client.init b/conf/redhat/client.init new file mode 100644 index 000000000..b71650702 --- /dev/null +++ b/conf/redhat/client.init @@ -0,0 +1,67 @@ +#!/bin/bash +# puppet This shell script enables system auto-conf through puppet. +# +# Author: Duane Griffin <d.griffin@psenterprise.com> +# +# chkconfig: - 98 02 +# +# description: Enables periodic system configuration checks through puppet. +# processname: puppetd + +PATH=/usr/bin:/sbin:/bin:/usr/sbin +export PATH + +lockfile=/var/lock/subsys/puppet + +# Source function library. +. /etc/rc.d/init.d/functions + +RETVAL=0 + +start() { + echo -n $"Enabling hourly puppet update: " + touch "$lockfile" && success || failure + RETVAL=$? + echo +} + +stop() { + echo -n $"Disabling hourly puppet update: " + rm -f "$lockfile" && success || failure + RETVAL=$? + echo +} + +restart() { + stop + start +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart|force-reload) + restart + ;; + reload) + ;; + condrestart) + [ -f "$lockfile" ] && restart + ;; + status) + if [ -f "$lockfile" ]; then + echo $"Hourly puppet update is enabled." + else + echo $"Hourly puppet update is disabled." + fi + ;; + *) + echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}" + exit 1 +esac + +exit $RETVAL diff --git a/conf/redhat/client.sysconfig b/conf/redhat/client.sysconfig new file mode 100644 index 000000000..23d114a42 --- /dev/null +++ b/conf/redhat/client.sysconfig @@ -0,0 +1,11 @@ +# You must specify the puppetmaster server here +PUPPET_SERVER= + +# If you wish to specify the port to connect to do so here +#PUPPET_PORT=8139 + +# Where to log to. Specify syslog to send log messages to the system log. +#PUPPET_LOG=syslog + +# You may specify other parameters to the puppet client here +#PUPPET_EXTRA_OPTS=--waitforcert=3600 diff --git a/conf/redhat/fileserver.conf b/conf/redhat/fileserver.conf new file mode 100644 index 000000000..4e93f7449 --- /dev/null +++ b/conf/redhat/fileserver.conf @@ -0,0 +1,12 @@ +# This file consists of arbitrarily named sections/modules +# defining where files are served from and to whom + +# Define a section 'files' +# Adapt the allow/deny settings to your needs. Order +# for allow/deny does not matter, allow always takes precedence +# over deny +[files] + path /var/puppet/files +# allow *.example.com +# deny *.evil.example.com +# allow 192.168.0.0/24 diff --git a/conf/redhat/puppet.spec b/conf/redhat/puppet.spec new file mode 100644 index 000000000..cdc1bbbc5 --- /dev/null +++ b/conf/redhat/puppet.spec @@ -0,0 +1,136 @@ +%define rubylibdir %(ruby -rrbconfig -e 'puts Config::CONFIG["sitelibdir"]') +%define _pbuild %{_builddir}/%{name}-%{version} +%define puppetroot /home/luke/svn/puppet/trunk +%define confdir %{puppetroot}/conf/redhat +%define pkgdir %{puppetroot}/pkg + +Summary: A network tool for managing many disparate systems +Name: puppet +Version: 0.11.2 +Release: 1 +License: GPL +Group: System Environment/Base + +URL: http://reductivelabs.com/projects/puppet/ +Source: http://reductivelabs.com/downloads/puppet/%{name}-%{version}.tgz +Source1: client.init +Source2: client.sysconfig +Source3: client.cron +Source4: server.sysconfig +Source5: server.init +Source6: fileserver.conf + +Vendor: Reductive Labs +Packager: Duane Griffin <d.griffin@psenterprise.com> + +Requires: ruby >= 1.8.1 +Requires: facter >= 1.1 +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root +BuildArchitectures: noarch + +%description +Puppet lets you centrally manage every important aspect of your system using a +cross-platform specification language that manages all the separate elements +normally aggregated in different files, like users, cron jobs, and hosts, +along with obviously discrete elements like packages, services, and files. + +%package server +Group: System Environment/Base +Summary: Server for the puppet system management tool. +Requires: puppet = %{version}-%{release} + +%description server +Provides the central puppet server daemon which provides manifests to clients. +The server can also function as a certificate authority and file server. + +%prep +%setup -q + +%{__cp} -p %{confdir}/* . + +%install +%{__rm} -rf %{buildroot} +%{__install} -d -m0755 %{buildroot}%{_sbindir} +%{__install} -d -m0755 %{buildroot}%{rubylibdir} +%{__install} -d -m0755 %{buildroot}%{_sysconfdir}/puppet/manifests +%{__install} -d -m0755 %{buildroot}%{_docdir}/%{name}-%{version} +%{__install} -d -m0755 %{buildroot}%{_localstatedir}/puppet +%{__install} -Dp -m0755 %{_pbuild}/bin/* %{buildroot}%{_sbindir} +%{__install} -Dp -m0644 %{_pbuild}/lib/puppet.rb %{buildroot}%{rubylibdir}/puppet.rb +%{__cp} -a %{_pbuild}/lib/puppet %{buildroot}%{rubylibdir} +%{__install} -Dp -m0644 client.sysconfig %{buildroot}%{_sysconfdir}/sysconfig/puppet +%{__install} -Dp -m0755 client.init %{buildroot}%{_initrddir}/puppet +%{__install} -Dp -m0644 client.cron %{buildroot}%{_sysconfdir}/cron.hourly/puppet.cron +%{__install} -Dp -m0644 server.sysconfig %{buildroot}%{_sysconfdir}/sysconfig/puppetmaster +%{__install} -Dp -m0755 server.init %{buildroot}%{_initrddir}/puppetmaster +%{__install} -Dp -m0644 fileserver.conf %{buildroot}%{_sysconfdir}/puppet/fileserver.conf + +%files +%defattr(-, root, root, 0755) +%{_sbindir}/puppet +%{_sbindir}/puppetd +%{rubylibdir}/* +%{_localstatedir}/puppet +%config %{_initrddir}/puppet +%config %{_sysconfdir}/cron.hourly/puppet.cron +%config(noreplace) %{_sysconfdir}/sysconfig/puppet +%doc CHANGELOG COPYING LICENSE README TODO examples +%exclude %{_sbindir}/puppetdoc + +%files server +%{_sbindir}/puppetmasterd +%config %{_initrddir}/puppetmaster +%config(noreplace) %{_sysconfdir}/puppet/* +%config(noreplace) %{_sysconfdir}/sysconfig/puppetmaster +%config(noreplace) %{_sysconfdir}/puppet/fileserver.conf +%{_sbindir}/cf2puppet +%{_sbindir}/puppetca + +%post +touch %{_localstatedir}/log/puppet.log +/sbin/chkconfig --add puppet +exit 0 + +%post server +touch %{_localstatedir}/log/puppetmaster.log +touch %{_localstatedir}/log/puppetmaster-http.log +/sbin/chkconfig --add puppetmaster + +%preun +if [ "$1" = 0 ] ; then + /sbin/service puppet stop > /dev/null 2>&1 + /sbin/chkconfig --del puppet +fi + +%preun server +if [ "$1" = 0 ] ; then + /sbin/service puppetmaster stop > /dev/null 2>&1 + /sbin/chkconfig --del puppetmaster +fi + +%postun server +if [ "$1" -ge 1 ]; then + /sbin/service puppetmaster condrestart > /dev/null 2>&1 +fi + +%clean +%{__rm} -rf %{buildroot} + +%changelog +* Tue Jan 17 2006 David Lutterkort <dlutter@redhat.com> - 0.11.0-1 +- Rebuild + +* Thu Jan 12 2006 David Lutterkort <dlutter@redhat.com> - 0.10.2-1 +- Updated for 0.10.2 Fixed minor kink in how Source is given + +* Wed Jan 11 2006 David Lutterkort <dlutter@redhat.com> - 0.10.1-3 +- Added basic fileserver.conf + +* Wed Jan 11 2006 David Lutterkort <dlutter@redhat.com> - 0.10.1-1 +- Updated. Moved installation of library files to sitelibdir. Pulled +initscripts into separate files. Folded tools rpm into server + +* Thu Nov 24 2005 Duane Griffin <d.griffin@psenterprise.com> +- Added init scripts for the client +* Wed Nov 23 2005 Duane Griffin <d.griffin@psenterprise.com> +- First packaging diff --git a/conf/redhat/server.init b/conf/redhat/server.init new file mode 100644 index 000000000..e05ceeeec --- /dev/null +++ b/conf/redhat/server.init @@ -0,0 +1,89 @@ +#!/bin/bash +# puppetmaster This shell script enables the puppetmaster server. +# +# Author: Duane Griffin <d.griffin@psenterprise.com> +# +# chkconfig: 345 65 45 +# +# description: Server for the puppet system management tool. +# processname: puppetmasterd + +PATH=/usr/bin:/sbin:/bin:/usr/sbin +export PATH + +lockfile=/var/lock/subsys/puppetmaster + +# Source function library. +. /etc/rc.d/init.d/functions + +if [ -f /etc/sysconfig/puppetmaster ]; then + . /etc/sysconfig/puppetmaster +fi + +[ -z "$PUPPETMASTER_MANIFEST" ] && PUPPETMASTER_MANIFEST=/etc/puppet/manifests/site.pp +[ -z "$PUPPETMASTER_LOG" ] && PUPPETMASTER_LOG="/var/log/puppetmaster.log" +PUPPETMASTER_OPTS=" + --manifest=$PUPPETMASTER_MANIFEST \ + --logdest=${PUPPETMASTER_LOG} \ + ${PUPPETMASTER_EXTRA_OPTS}" + +RETVAL=0 + +prog=puppetmasterd +PUPPETMASTER=/usr/sbin/$prog + +start() { + echo -n $"Starting $prog: " + + # Confirm the manifest exists + if [ -r $PUPPETMASTER_MANIFEST ]; then + $PUPPETMASTER $PUPPETMASTER_OPTS + RETVAL=$? + else + failure $"Manifest does not exist: $PUPPETMASTER_MANIFEST" + echo + return 1 + fi + [ $RETVAL -eq 0 ] && touch "$lockfile" + [ $RETVAL -eq 0 ] && echo_success + [ $RETVAL -ne 0 ] && echo_failure + echo + return $RETVAL +} + +stop() { + echo -n $"Stopping $prog: " + killproc $PUPPETMASTER + RETVAL=$? + echo + [ $RETVAL -eq 0 ] && rm -f "$lockfile" + return $RETVAL +} + +restart() { + stop + start +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart|reload|force-reload) + restart + ;; + condrestart) + [ -f "$lockfile" ] && restart + ;; + status) + status $PUPPETMASTER + ;; + *) + echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}" + exit 1 +esac + +exit $RETVAL diff --git a/conf/redhat/server.sysconfig b/conf/redhat/server.sysconfig new file mode 100644 index 000000000..fe673cc40 --- /dev/null +++ b/conf/redhat/server.sysconfig @@ -0,0 +1,9 @@ +# Location of the main manifest +#PUPPETMASTER_MANIFEST=/etc/puppet/manifests/site.pp + +# Where to log general messages to. +# Specify syslog to send log messages to the system log. +#PUPPETMASTER_LOG=syslog + +# You may specify other parameters to the puppetmaster here +#PUPPETMASTER_EXTRA_OPTS=--noca diff --git a/lib/puppet.rb b/lib/puppet.rb index d48d45b94..1526b3c4b 100644 --- a/lib/puppet.rb +++ b/lib/puppet.rb @@ -13,7 +13,7 @@ require 'puppet/util' # # it's also a place to find top-level commands like 'debug' module Puppet -PUPPETVERSION = '0.11.2' + PUPPETVERSION = '0.12.0' def Puppet.version return PUPPETVERSION diff --git a/lib/puppet/client/master.rb b/lib/puppet/client/master.rb index 73217b2f0..29e466224 100644 --- a/lib/puppet/client/master.rb +++ b/lib/puppet/client/master.rb @@ -54,6 +54,7 @@ class Puppet::Client::MasterClient < Puppet::Client Metric.store Metric.graph end + Puppet.notice "Finished configuration run" return transaction end diff --git a/lib/puppet/config.rb b/lib/puppet/config.rb index dc9892cfb..833a2c6e3 100644 --- a/lib/puppet/config.rb +++ b/lib/puppet/config.rb @@ -1,6 +1,6 @@ module Puppet # The class for handling configuration files. -class Config < Hash +class Config # Slight override, since we can't seem to have a subclass where all instances # have the same default block. def [](section) @@ -43,6 +43,57 @@ class Config < Hash end } end + + def setdefaults(hash) + hash.each { |param, value| + if @defaults.include?(param) + raise Puppet::Error, "Default %s is already defined" % param + end + + case value + when true, false: + @defaults[param] = Boolean.new(param, value) + when String: + @defaults[param] = Element.new(param, value) + when Hash: + type = nil + unless value.include?(:type) + raise Puppet::Error, "You must include the object type" + end + unless type = Puppet.type(value[:type]) + raise Puppet::Error, "Invalid type %s" % value[:type] + end + + value.delete(:type) + + # FIXME this won't work, because we don't want to interpolate the + # file name until they actually ask for it + begin + @defaults[param] = type.create(value) + rescue => detail + raise Puppet::Error, "Could not create default %s: %s" % + [param, detail] + end + end + } + end + + class Element + attr_accessor :name, :value + end + + class File < Element + end + + class Boolean < Element + def value=(value) + unless value == true or value == false + raise Puppet::DevError, "Invalid value %s for %s" % [value, @name] + end + + @value = value + end + end end end diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb index 424646742..151233862 100644 --- a/lib/puppet/type.rb +++ b/lib/puppet/type.rb @@ -1849,7 +1849,7 @@ class Type < Puppet::Element newmetaparam(:schedule) do desc "On what schedule the object should be managed. You must create a schedule_ object, and then reference the name of that object to use - that for your schedule: + that for your schedule:: schedule { daily: period => daily, diff --git a/test/other/config.rb b/test/other/config.rb new file mode 100755 index 000000000..ae3392edd --- /dev/null +++ b/test/other/config.rb @@ -0,0 +1,44 @@ +if __FILE__ == $0 + $:.unshift '..' + $:.unshift '../../lib' + $puppetbase = "../.." +end + +require 'puppet' +require 'puppet/config' +require 'puppettest' +require 'test/unit' + +class TestConfig < Test::Unit::TestCase + include TestPuppet + + def mkconfig + c = nil + assert_nothing_raised { + c = Puppet::Config.new + } + return c + end + + def test_addbools + c = mkconfig + + assert_nothing_raised { + c.setdefaults(:booltest => true) + } + + assert(c[:booltest]) + + assert_nothing_raised { + c[:booltest] = false + } + + assert(! c[:booltest]) + + assert_raise(Puppet::Error) { + c[:booltest] = "yayness" + } + end +end + +# $Id$ |