diff options
author | Luke Kanies <luke@madstop.com> | 2008-10-31 16:01:28 -0500 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2008-10-31 16:01:28 -0500 |
commit | e76cac7df102389b7ee487be4031caf0e7e2ab04 (patch) | |
tree | 0b9bd8d260613a5b41d9c72fa984065e5cb2d5f4 | |
parent | 801b8a643d353176675023adaa25f26d0ec67403 (diff) | |
parent | f0635179b60f5cf30d1f7070f4c3c998ad5131c0 (diff) | |
download | puppet-e76cac7df102389b7ee487be4031caf0e7e2ab04.tar.gz puppet-e76cac7df102389b7ee487be4031caf0e7e2ab04.tar.xz puppet-e76cac7df102389b7ee487be4031caf0e7e2ab04.zip |
Merge branch '0.24.x'
Conflicts:
CHANGELOG
49 files changed, 1074 insertions, 867 deletions
@@ -7,6 +7,26 @@ whether we should even use a CRL. This way we aren't trying to set file paths to 'false' to disable the CRL. +0.24.x + Fixed #1710 - Spurious output in test run + + Fixed #1667 - Documentation should specify natural language regexs, not Regexp objects + + Fixed #1692 - k5login fails to set mode when file is created + + Fixed #1660 - Added specific recurse values for tidy + + Fixed #1698 - All logs should now show up in the reports + + Fixed #1661 - Type reference: tidy should specify manditory parameters + + Fixed #1104 - Classes and nodes should set $name variables + + Updated Red Hat spec file for 0.24.6 + + Removed conf/debian directory - Debian packaging information + now maintained downstream + 0.24.6 Adding support to the user type for: profiles, auths, project, key/value pairs (extension to Solaris RBAC support added in @@ -33,10 +33,6 @@ project = Rake::RedLabProject.new("puppet") do |p| p.filelist.exclude("bin/pi") p.add_dependency('facter', '1.1.0') - - #p.epmhosts = %w{culain} - #p.sunpkghost = "sol10b" - #p.rpmhost = "fedora1" end if project.has?(:gem) @@ -49,7 +45,6 @@ if project.has?(:gem) task.executables = ["puppet", "puppetd", "puppetmasterd", "puppetdoc", "puppetca", "puppetrun", "ralsh"] task.default_executable = "puppet" - task.autorequire = 'puppet' #### Documentation and testing. @@ -64,14 +59,6 @@ if project.has?(:gem) end end -if project.has?(:epm) - project.mkepmtask do |task| - task.bins = FileList.new("bin/puppet", "bin/puppetca") - task.sbins = FileList.new("bin/puppetmasterd", "bin/puppetd") - task.rubylibs = FileList.new('lib/**/*') - end -end - rule(/_is_runnable$/) do |t| available = false executable = t.name.sub(/_is_runnable$/, '') diff --git a/conf/debian/README.source b/conf/debian/README.source deleted file mode 100644 index fd9155241..000000000 --- a/conf/debian/README.source +++ /dev/null @@ -1,2 +0,0 @@ -The debian directory is now maintained on Alioth in git. -See http://pkg-puppet.alioth.debian.org/ for more information. diff --git a/conf/debian/TODO.Debian b/conf/debian/TODO.Debian deleted file mode 100644 index ac70b97be..000000000 --- a/conf/debian/TODO.Debian +++ /dev/null @@ -1 +0,0 @@ -* clean up initscripts per http://mail.madstop.com/pipermail/puppet-dev/2006-June/001069.html diff --git a/conf/debian/changelog b/conf/debian/changelog deleted file mode 100644 index 69984d622..000000000 --- a/conf/debian/changelog +++ /dev/null @@ -1,257 +0,0 @@ -puppet (0.24.1-2) unstable; urgency=low - - * Set rundir correctly (Closes: #460203, #459579) - * Apply patch for puppet#1003 to enable collection of tagged resources - - -- Thom May <thom@debian.org> Wed, 16 Jan 2008 11:08:55 +0100 - -puppet (0.24.1-1) unstable; urgency=low - - * New upstream release (Closes: #445626) - * Set maintainer to pkg-puppet-devel - - -- Thom May <thom@debian.org> Sun, 30 Dec 2007 19:13:47 +0100 - -puppet (0.24.0-1) unstable; urgency=low - - * New upstream release - - -- Thom May <thom@debian.org> Wed, 19 Dec 2007 16:00:34 +0100 - -puppet (0.23.2-15) unstable; urgency=low - - * No change upload setting maintainer to me whilst waiting for an alioth - project. - - -- Thom May <thom@debian.org> Thu, 29 Nov 2007 10:44:50 +0100 - -puppet (0.23.2-14) unstable; urgency=low - - * Orphaning. - * Create /var/lib/puppet in the puppet package. Closes: #452506. - * Start the puppet init script after puppetmaster, to silence whiny bug - reports. Closes: #452064. - * Add a reload command to the Puppet init script. Closes: #452060. - - -- Matthew Palmer <mpalmer@debian.org> Thu, 29 Nov 2007 10:48:21 +1100 - -puppet (0.23.2-13) unstable; urgency=low - - * Drop quotes from an already-quoted value in a query. Closes: #448179. - * Remove excessive quoting from puppet/network/handler/master.rb. - Closes: #448221. - * Force removal of directories during pluginsync. Closes: #448180. - - -- Matthew Palmer <mpalmer@debian.org> Tue, 30 Oct 2007 14:55:19 +1100 - -puppet (0.23.2-12) unstable; urgency=low - - * Create /var/run/puppet and set the perms in the various initscripts, as - well as hardcoding the rundir better in configuration.rb and removing - the explicit rundir setting from puppet.conf. Closes: #447314. - * Apply additional patch given (backwards) to fix export/collect on some - database backends. Closes: #445591 (again!) - - -- Matthew Palmer <mpalmer@debian.org> Sat, 20 Oct 2007 11:28:50 +1000 - -puppet (0.23.2-11) unstable; urgency=low - - * Apply patch from puppet#786 to fix a problem with exported resources not - being properly detected as needing a rerun. Closes: #445591. - * Fix ignore handling for the plugins mount. Closes: #446390. - - -- Matthew Palmer <mpalmer@debian.org> Mon, 15 Oct 2007 09:11:25 +1000 - -puppet (0.23.2-10) unstable; urgency=low - - * Recycle connections when we change (or get) certs. - * Catch and retry more transient errors in the XMLRPC wrapper. - - -- Matthew Palmer <mpalmer@debian.org> Thu, 27 Sep 2007 15:06:11 +1000 - -puppet (0.23.2-9) unstable; urgency=low - - * Recycle the HTTP connection if we get an EPIPE during a request. - Closes: #444177. Thanks to Jos Backus for helping with testing. - - -- Matthew Palmer <mpalmer@debian.org> Thu, 27 Sep 2007 09:55:34 +1000 - -puppet (0.23.2-8) unstable; urgency=low - - * Remove extraneous debugging output accidentally left behind in the last - release. - * Fix spelling mistakes in debian/control and debian/puppet.preinst. - Closes: #444158. - - -- Matthew Palmer <mpalmer@debian.org> Thu, 27 Sep 2007 07:45:07 +1000 - -puppet (0.23.2-7) unstable; urgency=low - - * Ignore ENOENT errors in the module plugin syncing code, since they're - innocuous and expected. - * Allow facts that are downloaded through pluginsync to be used like any - other fact. - * Allow users to still have an old-style plugins mount if they want, by - specifying a path for the mount. Also track down a fault in old-style - fileserving which did strange slash-stripping. Closes: #443932. - - -- Matthew Palmer <mpalmer@debian.org> Tue, 25 Sep 2007 16:41:32 +1000 - -puppet (0.23.2-6) unstable; urgency=low - - * Patch rails/param_name.rb to stop query failures, as per puppet#784. - * Actually honour namevar. - * Only set dbuser if explicitly asked for. - * Fix annoying database deletion error for ParamValue objects. - * Add an accessor for ca_file, since older openssl-ruby only had a writer. - * Fix the fileserver to honour ignore. Thanks to Nathan Ward for the - bug report on IRC. - - -- Matthew Palmer <mpalmer@debian.org> Thu, 20 Sep 2007 16:10:41 +1000 - -puppet (0.23.2-5) unstable; urgency=low - - * Add some NEWS for the ssldir transition. Should have done that earlier. - * Remove the explicit mode change for vardir, and fix up the mode on - statedir, as well. Closes: #425496. - * Only set some database parameters if they're explicitly set; this makes - life easier for PgSQL ident auth. - * Allow empty config options. - - -- Matthew Palmer <mpalmer@debian.org> Thu, 13 Sep 2007 11:09:59 +1000 - -puppet (0.23.2-4) unstable; urgency=low - - * Fix puppet#776 in a slightly better way by only flushing the cache when - a value is changed, rather than whenever a value is read. - * Apply patch from puppet#755 to cache connections to the Puppetmaster, - which improves performance by more than a little. - * Modify the fileserver so that it provides a 'plugins' mount which - exports the union of the plugins directory of all modules. - - -- Matthew Palmer <mpalmer@debian.org> Fri, 31 Aug 2007 15:32:04 +1000 - -puppet (0.23.2-3) unstable; urgency=low - - * Clear the config value cache every time. This is a titchy little - performance hit, but it works around puppet#776 rather nicely. - - -- Matthew Palmer <mpalmer@debian.org> Fri, 24 Aug 2007 16:08:04 +1000 - -puppet (0.23.2-2) unstable; urgency=low - - * Move the SSL state directory to a more policy-friendly location, - /var/lib/puppet/ssl. - - -- Matthew Palmer <mpalmer@debian.org> Tue, 21 Aug 2007 12:54:40 +1000 - -puppet (0.23.2-1) unstable; urgency=low - - * New upstream release. - - -- Matthew Palmer <mpalmer@debian.org> Tue, 7 Aug 2007 12:47:49 +1000 - -puppet (0.23.1-1) unstable; urgency=low - - * New upstream release. - * Switch primary maintainer to me. Thanks jaq. - * Make the recommendation for rails >= 1.2.3-2, to avoid - incompatibilities. This breaks compatibility with stable, but the rails - package from unstable should install cleanly in stable. Closes: #433999 - - -- Matthew Palmer <mpalmer@debian.org> Sat, 21 Jul 2007 16:34:36 +1000 - -puppet (0.23.0-1) unstable; urgency=low - - * New upstream release. - - Includes a new configuration file handling system; see NEWS.Debian. - - -- Matthew Palmer <mpalmer@debian.org> Mon, 25 Jun 2007 09:55:12 +1000 - -puppet (0.22.4-2) unstable; urgency=low - - * Depend on libshadow-ruby1.8, for new password modification functionality - added to upstream 0.22.4. - * Several improvements from Micah Anderson: - - Better vim syntax installation process. - - Install Emacs syntax highlighting. - - Install logcheck rules. Closes: #421851. - - -- Matthew Palmer <mpalmer@debian.org> Thu, 3 May 2007 15:04:15 +1000 - -puppet (0.22.4-1) unstable; urgency=low - - * New upstream release. - - -- Matthew Palmer <mpalmer@debian.org> Wed, 2 May 2007 12:20:15 +1000 - -puppet (0.22.3-1) unstable; urgency=low - - * New upstream release. Closes: #415773. - * Switch to using our own logrotate config, and enhance it as per - David Schmitt's suggestions. Closes: #414282. - * Add puppetrun to the puppetmaster package, and actually put puppetdoc - into the puppet package. Closes: #419273. - * Copy vim syntax highlighting file into the puppet package, and add a - stanza to have Vim automatically highlight .pp files. Closes: #412868. - Thanks to David Schmitt for researching how to do all of that. - * Add a templatedir setting to the default puppetmasterd.conf to make it - obvious that it can be changed. Closes: #407506. - - -- Matthew Palmer <mpalmer@debian.org> Wed, 18 Apr 2007 14:03:33 +1000 - -puppet (0.22.1-1) unstable; urgency=low - - * New upstream release. - - -- Matthew Palmer <mpalmer@debian.org> Fri, 2 Feb 2007 09:06:46 +1100 - -puppet (0.22.0-1) unstable; urgency=low - - * New upstream release. - * Use --startas instead of --init in init scripts, which (according to - Paul Hampson) makes checking for already-running instances work. - Closes: #405912. - - -- Matthew Palmer <mpalmer@debian.org> Mon, 8 Jan 2007 08:41:35 +1100 - -puppet (0.20.1-1) unstable; urgency=low - - * New upstream release. (Closes: #387674) - * Rationalise the puppetmasterd init script. - * Add inclusion of /etc/default files for init scripts. (Closes: #388178) - * Add puppet.conf to match puppetd.conf. (Closes: #385646) - - -- Matthew Palmer <mpalmer@debian.org> Thu, 30 Nov 2006 10:54:19 +1100 - -puppet (0.18.4-1) unstable; urgency=low - - * New upstream release. - - Properly detect all services, including those in rcS.d. - (Closes: #378351) - * Add Homepage: to the long description. (Closes: #377896) - - -- Matthew Palmer <mpalmer@debian.org> Mon, 24 Jul 2006 19:46:06 +1000 - -puppet (0.18.3-1) unstable; urgency=low - - * New upstream version. - - Set DEBIAN_FRONTEND=noninteractive when installing Debian packages. - (Closes: #378338) - - -- Matthew Palmer <mpalmer@debian.org> Sun, 16 Jul 2006 10:58:50 +1000 - -puppet (0.18.1-1) unstable; urgency=low - - * Make Puppet not wait for a cert at all (to prevent startup hangs). - * Cleanup the init scripts to not have NO_START detritus. - * Apply puppet.debian-frontend, to set DEBIAN_FRONTEND=noninteractive on - package installation. - - -- Matthew Palmer <mpalmer@debian.org> Tue, 27 Jun 2006 15:05:32 +1000 - -puppet (0.18.0-1) unstable; urgency=low - - * Initial release. (Closes: #348625) - - -- Matthew Palmer <mpalmer@debian.org> Wed, 24 May 2006 13:10:01 +1000 diff --git a/conf/debian/compat b/conf/debian/compat deleted file mode 100644 index b8626c4cf..000000000 --- a/conf/debian/compat +++ /dev/null @@ -1 +0,0 @@ -4 diff --git a/conf/debian/control b/conf/debian/control deleted file mode 100644 index 8b0e92e7e..000000000 --- a/conf/debian/control +++ /dev/null @@ -1,45 +0,0 @@ -Source: puppet -Section: admin -Priority: optional -Maintainer: Puppet Package Maintainers <pkg-puppet-devel@lists.alioth.debian.org> -Uploaders: Thom May <thom@debian.org> -Build-Depends-Indep: debhelper (>= 4.0.0), ruby (>= 1.8.1) -Standards-Version: 3.6.2 - -Package: puppet -Architecture: all -Depends: ruby (>= 1.8.1), libxmlrpc-ruby, libopenssl-ruby, libshadow-ruby1.8, adduser, facter, lsb-base -Recommends: rdoc -Description: centralised configuration management for networks - 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. - . - Puppet's simple declarative specification language provides powerful - classing abilities for drawing out the similarities between hosts while - allowing them to be as specific as necessary, and it handles dependency - and prerequisite relationships between objects clearly and explicitly. - . - Homepage: http://reductivelabs.com/projects/puppet - -Package: puppetmaster -Architecture: all -Depends: ruby (>= 1.8.1), puppet (= ${Source-Version}), facter, lsb-base -Recommends: rails (>= 1.2.3-2), rdoc -Description: centralised configuration management control daemon - 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. - . - Puppet's simple declarative specification language provides powerful - classing abilities for drawing out the similarities between hosts while - allowing them to be as specific as necessary, and it handles dependency - and prerequisite relationships between objects clearly and explicitly. - . - This package contains the manifest server, 'puppetmaster'. - . - Homepage: http://reductivelabs.com/projects/puppet diff --git a/conf/debian/copyright b/conf/debian/copyright deleted file mode 100644 index 06bdcab30..000000000 --- a/conf/debian/copyright +++ /dev/null @@ -1,17 +0,0 @@ -This package was debianized by Jamie Wilkinson <jaq@debian.org> on -Thu, 27 Apr 2006 10:18:04 +1000. - -It was downloaded from http://reductivelabs.com/downloads/puppet - -Copyright Holder: Luke Kanies <luke@madstop.com> - -License: - -From -http://reductivelabs.com/documents/faq#what-license-is-puppet-released-under: - -Puppet is open source and is released under the GNU Public License. - -On Debian systems, the complete text of the GNU General -Public License can be found in `/usr/share/common-licenses/GPL'. - diff --git a/conf/debian/docs b/conf/debian/docs deleted file mode 100644 index e845566c0..000000000 --- a/conf/debian/docs +++ /dev/null @@ -1 +0,0 @@ -README diff --git a/conf/debian/fileserver.conf b/conf/debian/fileserver.conf deleted file mode 100644 index 04a51c080..000000000 --- a/conf/debian/fileserver.conf +++ /dev/null @@ -1,12 +0,0 @@ -# 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 /etc/puppet/files -# allow *.example.com -# deny *.evil.example.com -# allow 192.168.0.0/24 diff --git a/conf/debian/puppet.NEWS b/conf/debian/puppet.NEWS deleted file mode 100644 index a712aafd4..000000000 --- a/conf/debian/puppet.NEWS +++ /dev/null @@ -1,63 +0,0 @@ -puppet (0.23.2-12) unstable; urgency=low - - * Handling of the rundir setting has been changed; we now store PID files - in /var/run/puppet, and the initscripts have been modified to ensure - that this directory exists on startup. It is no longer necessary to set - rundir explicitly in /etc/puppet/puppet.conf, and you should ensure that - you have no explicit rundir setting in your puppet.conf unless you want - to use a custom rundir setting for your own local purposes. - - -- Matthew Palmer <mpalmer@debian.org> Sat, 20 Oct 2007 11:58:58 +1000 - -puppet (0.23.2-3) unstable; urgency=low - - * This version of Puppet makes a fairly major change to the location of - the CA and certificates, from /etc/puppet/ssl to the more FHS-compliant - location /var/lib/puppet/ssl. This is to be both policy-compliant and - to match the location of the ssldir in other distributions. - - If you have transitioned to using the consolidated puppet.conf config - file, there should be no problems. If you are using a stock - puppet.conf, the change should be made for you automatically, while if - you've customised puppet.conf the ssldir will be left where it is and - you should transition to the new location manually. - - The only source of problems is if you're still using per-program config - files (puppetd.conf, puppetmasterd.conf, etc). I haven't been able to - work out a damage-free way of transitioning to the new location, so - things will likely break for you -- ssldir will have been moved to - /var/lib/puppet/ssl, but your puppet programs will use the - old config file (with the default ssldir of /etc/puppet/ssl. In this - case, you'll likely get all sorts of certificate-related problems. - - The solution is to either switch to using puppet.conf (which is - necessary anyway because support for the deprecated per-program config - files will be going away sometime) with the new ssldir setting, or add - the ssldir setting to all your per-program config files (this includes - creating them for programs that don't already have a config file, like - puppetca.conf). Then delete /etc/puppet/ssl (since it's not needed) and - use the existing SSL data that was moved to /var/lib/puppet/ssl. - - -- Matthew Palmer <mpalmer@debian.org> Fri, 24 Aug 2007 16:08:04 +1000 - -puppet (0.23.0-1) unstable; urgency=low - - * As of upstream 0.23.0, the configuration file layout has been largely - revamped. Now, instead of having one file per program, there is now - a single file, /etc/puppet/puppet.conf, which contains sections for - each program, as well as a "main" section that sets global config - options relevant for all programs. - - See http://reductivelabs.com/trac/puppet/wiki/ConfigurationReference for - more info. - - For backwards compatibility, all programs still read the per-program - configuration files, and will ignore the generic puppet.conf file if the - per-program file still exists. To prevent accidents, you will need to - do the configuration change manually, by rewriting puppet.conf to match - your local configuration parameters and then deleting the old files. If - you haven't changed any config parameters, then it should be as simple - as deleting puppetd.conf and puppetmasterd.conf and restarting the - daemons, as the configuration itself hasn't changed between versions. - - -- Matthew Palmer <mpalmer@debian.org> Mon, 25 Jun 2007 10:43:53 +1000 diff --git a/conf/debian/puppet.conf b/conf/debian/puppet.conf deleted file mode 100644 index c541c748a..000000000 --- a/conf/debian/puppet.conf +++ /dev/null @@ -1,8 +0,0 @@ -[main] -logdir=/var/log/puppet -vardir=/var/lib/puppet -ssldir=/var/lib/puppet/ssl -rundir=/var/run/puppet - -[puppetmasterd] -templatedir=/var/lib/puppet/templates diff --git a/conf/debian/puppet.dirs b/conf/debian/puppet.dirs deleted file mode 100644 index 9ce18f88e..000000000 --- a/conf/debian/puppet.dirs +++ /dev/null @@ -1,7 +0,0 @@ -usr/sbin -usr/lib/ruby/1.8 -var/log/puppet -etc/puppet/files -usr/share/vim/addons/ftdetect -usr/share/vim/vim71/syntax -var/lib/puppet diff --git a/conf/debian/puppet.files b/conf/debian/puppet.files deleted file mode 100644 index d92ac32e9..000000000 --- a/conf/debian/puppet.files +++ /dev/null @@ -1,6 +0,0 @@ -usr/bin/puppet -usr/bin/puppetdoc -usr/sbin/puppetd -usr/lib/ruby/1.8/ -var/log/puppet -etc/puppet/puppet.conf diff --git a/conf/debian/puppet.init b/conf/debian/puppet.init deleted file mode 100644 index 063f9273f..000000000 --- a/conf/debian/puppet.init +++ /dev/null @@ -1,64 +0,0 @@ -#! /bin/sh - -PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin -DAEMON=/usr/sbin/puppetd -DAEMON_OPTS="-w 0" -NAME=puppetd -DESC="puppet configuration management tool" - -test -x $DAEMON || exit 0 - -[ -r /etc/default/puppet ] && . /etc/default/puppet - -. /lib/lsb/init-functions - -reload_puppet() { - start-stop-daemon --stop --quiet --signal HUP --pidfile /var/run/puppet/$NAME.pid -} - -start_puppet() { - start-stop-daemon --start --quiet --pidfile /var/run/puppet/$NAME.pid \ - --startas $DAEMON -- $DAEMON_OPTS -} - -stop_puppet() { - start-stop-daemon --stop --quiet --pidfile /var/run/puppet/$NAME.pid -} - -if [ ! -d /var/run/puppet ]; then - rm -rf /var/run/puppet - mkdir -p /var/run/puppet -fi - -chown puppet:puppet /var/run/puppet - -case "$1" in - start) - log_begin_msg "Starting $DESC" - start_puppet - log_end_msg 0 - ;; - stop) - log_begin_msg "Stopping $DESC" - stop_puppet - log_end_msg 0 - ;; - reload) - log_begin_msg "Reloading $DESC" - reload_puppet - log_end_msg 0 - ;; - restart|force-reload) - log_begin_msg "Restarting $DESC" - stop_puppet - sleep 1 - start_puppet - log_end_msg 0 - ;; - *) - echo "Usage: $0 {start|stop|restart|force-reload|reload}" >&2 - exit 1 - ;; -esac - -exit 0 diff --git a/conf/debian/puppet.logrotate b/conf/debian/puppet.logrotate deleted file mode 100644 index 3864e396d..000000000 --- a/conf/debian/puppet.logrotate +++ /dev/null @@ -1,11 +0,0 @@ -/var/log/puppet/*log { - missingok - create 0644 puppet puppet - compress - rotate 4 - - postrotate - [ -e /etc/init.d/puppetmaster ] && /etc/init.d/puppetmaster restart >/dev/null 2>&1 || true - [ -e /etc/init.d/puppet ] && /etc/init.d/puppet reload > /dev/null 2>&1 || true - endscript -} diff --git a/conf/debian/puppet.postinst b/conf/debian/puppet.postinst deleted file mode 100644 index ac765ba85..000000000 --- a/conf/debian/puppet.postinst +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -e - -if [ "$1" = "configure" ]; then - if [ -d /etc/puppet/ssl ] && [ ! -e /var/lib/puppet/ssl ] && grep -q 'ssldir=/var/lib/puppet/ssl' /etc/puppet/puppet.conf; then - mv /etc/puppet/ssl /var/lib/puppet/ssl - fi -fi - -#DEBHELPER# diff --git a/conf/debian/puppet.postrm b/conf/debian/puppet.postrm deleted file mode 100644 index da994c3c3..000000000 --- a/conf/debian/puppet.postrm +++ /dev/null @@ -1,21 +0,0 @@ -#! /bin/sh - -case "$1" in - purge) - rm -rf /var/lib/puppet - /usr/sbin/deluser --system puppet - ;; - remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) - - - ;; - - *) - echo "postrm called with unknown argument \`$1'" >&2 - exit 1 - -esac - -#DEBHELPER# - -exit 0 diff --git a/conf/debian/puppet.preinst b/conf/debian/puppet.preinst deleted file mode 100644 index ce8e76083..000000000 --- a/conf/debian/puppet.preinst +++ /dev/null @@ -1,25 +0,0 @@ -#! /bin/sh - -case "$1" in - install|upgrade) - /usr/sbin/adduser --system \ - --group \ - --home /var/lib/puppet \ - --gecos "Puppet configuration management daemon" \ - puppet > /dev/null - ;; - - abort-upgrade) - ;; - - *) - echo "preinst called with unknown argument \`$1'" >&2 - exit 1 - ;; -esac - -#DEBHELPER# - -exit 0 - - diff --git a/conf/debian/puppetmaster.files b/conf/debian/puppetmaster.files deleted file mode 100644 index 15bc694b1..000000000 --- a/conf/debian/puppetmaster.files +++ /dev/null @@ -1,4 +0,0 @@ -usr/sbin/puppetmasterd -usr/sbin/puppetca -usr/sbin/puppetrun -etc/puppet/ diff --git a/conf/debian/puppetmaster.init b/conf/debian/puppetmaster.init deleted file mode 100644 index ea5c1bafb..000000000 --- a/conf/debian/puppetmaster.init +++ /dev/null @@ -1,58 +0,0 @@ -#! /bin/sh - -PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin -DAEMON=/usr/sbin/puppetmasterd -DAEMON_OPTS="" -NAME=puppetmasterd -DESC="puppet configuration management tool master server" - -test -x $DAEMON || exit 0 - -[ -r /etc/default/puppetmaster ] && . /etc/default/puppetmaster - -. /lib/lsb/init-functions - -if [ ! -d /var/run/puppet ]; then - rm -rf /var/run/puppet - mkdir -p /var/run/puppet -fi - -chown puppet:puppet /var/run/puppet - -start_puppetmaster() { - start-stop-daemon --start --quiet --pidfile /var/run/puppet/$NAME.pid \ - --startas $DAEMON -- $DAEMON_OPTS -} - -stop_puppetmaster() { - start-stop-daemon --stop --quiet --pidfile /var/run/puppet/$NAME.pid -} - -case "$1" in - start) - log_begin_msg "Starting $DESC" - start_puppetmaster - log_end_msg $? - ;; - stop) - log_begin_msg "Stopping $DESC" - stop_puppetmaster - log_end_msg $? - ;; - reload) - # Do nothing, as Puppetmaster rechecks its config automatically - ;; - restart|force-reload) - log_begin_msg "Restarting $DESC" - stop_puppetmaster - sleep 1 - start_puppetmaster - log_end_msg 0 - ;; - *) - echo "Usage: $0 {start|stop|restart|force-reload}" >&2 - exit 1 - ;; -esac - -exit 0 diff --git a/conf/debian/rules b/conf/debian/rules deleted file mode 100755 index ecabcbad0..000000000 --- a/conf/debian/rules +++ /dev/null @@ -1,115 +0,0 @@ -#!/usr/bin/make -f -# -*- makefile -*- - -# Uncomment this to turn on verbose mode. -#export DH_VERBOSE=1 - -INSTALL=install -Dp - -prefix := $(CURDIR)/debian/tmp -bindir := $(prefix)/usr/bin -sbindir := $(prefix)/usr/sbin -libdir := $(prefix)/usr/lib -localstatedir := $(prefix)/var -rubylibdir := $(libdir)/ruby/1.8 -sysconfdir := $(prefix)/etc -pkgconfdir := $(sysconfdir)/puppet - -ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) - CFLAGS += -O0 -else - CFLAGS += -O2 -endif - -configure: configure-stamp -configure-stamp: - dh_testdir - touch configure-stamp - - -build: build-stamp -build-stamp: configure-stamp - dh_testdir - touch build-stamp - -clean: - dh_testdir - dh_testroot - rm -f build-stamp configure-stamp - dh_clean - -install: build - dh_testdir - dh_testroot - dh_clean -k - dh_installdirs - - # ripped from the redhat spec - # this sucks, who wants to maintain this? - # note to self, fix the install.rb to handle DESTDIR and change - # library path - install -d -m0755 $(sbindir) - install -d -m0755 $(bindir) - install -d -m0755 $(rubylibdir) - install -d -m0755 $(pkgconfdir)/manifests - install -d -m0755 $(localstatedir)/lib/puppet - install -d -m0755 $(localstatedir)/run - install -d -m0755 $(localstatedir)/log/puppet - - $(INSTALL) -m0755 bin/puppet bin/puppetdoc $(bindir) - $(INSTALL) -m0755 bin/puppetd bin/puppetmasterd bin/puppetca bin/puppetrun $(sbindir) - $(INSTALL) -m0644 lib/puppet.rb $(rubylibdir)/puppet.rb - cp -a lib/puppet $(rubylibdir) - find $(rubylibdir) -type f -perm +ugo+x -exec chmod a-x {} \; - - $(INSTALL) -m0644 debian/fileserver.conf $(pkgconfdir)/fileserver.conf - $(INSTALL) -m0644 debian/puppet.conf $(pkgconfdir)/puppet.conf - - # Vim auto-syntax-highlighting stuff - $(INSTALL) -m0644 ext/vim/syntax/puppet.vim \ - $(CURDIR)/debian/puppet/usr/share/vim/vim71/syntax/ - $(INSTALL) -m0644 ext/vim/ftdetect/puppet.vim \ - $(CURDIR)/debian/puppet/usr/share/vim/addons/ftdetect/ - - # Emacs keeping up with the Joneses - $(INSTALL) -m0644 ext/emacs/puppet-mode-init.el \ - $(CURDIR)/debian/puppet/etc/emacs/site-start.d/50puppet-mode-init.el - $(INSTALL) -m0644 ext/emacs/puppet-mode.el \ - $(CURDIR)/debian/puppet/usr/share/emacs/site-lisp/puppet-mode.el - - dh_installexamples examples/* - - # Logcheck rules. Gee I wish you could specify a file to source - # in dh_installlogcheck. - cp ext/logcheck/puppet debian/puppet.logcheck.ignore.server - cp ext/logcheck/puppet debian/puppet.logcheck.ignore.workstation - dh_installlogcheck - rm debian/puppet.logcheck.* - - # Clean out any SVN cruft that may still be lingering in our - # packages - find debian/tmp debian/puppet debian/puppetmaster -name .svn |xargs rm -rf - -# Build architecture-dependent files here. -binary-arch: build install - -# Build architecture-independent files here. -binary-indep: build install - dh_testdir - dh_testroot - dh_movefiles -i - dh_installchangelogs -i CHANGELOG - dh_installdocs -i - dh_installinit -ppuppetmaster - dh_installinit -ppuppet -- defaults 21 - dh_installlogrotate -i - dh_compress -i - dh_fixperms -i - dh_installdeb -i - dh_shlibdeps -i - dh_gencontrol -i - dh_md5sums -i - dh_builddeb -i - -binary: binary-indep binary-arch -.PHONY: build clean binary-indep binary-arch binary install configure diff --git a/conf/debian/watch b/conf/debian/watch deleted file mode 100644 index 29d439f6d..000000000 --- a/conf/debian/watch +++ /dev/null @@ -1,2 +0,0 @@ -version=3 -http://reductivelabs.com/downloads/puppet/puppet-([0-9]+\..*)\.tgz diff --git a/conf/redhat/puppet.spec b/conf/redhat/puppet.spec index d71b8626e..367836abe 100644 --- a/conf/redhat/puppet.spec +++ b/conf/redhat/puppet.spec @@ -1,41 +1,45 @@ %{!?ruby_sitelibdir: %define ruby_sitelibdir %(ruby -rrbconfig -e 'puts Config::CONFIG["sitelibdir"]')} -%define pbuild %{_builddir}/%{name}-%{version} %define confdir conf/redhat -%define has_ruby_abi 0%{?fedora:%fedora} >= 5 || 0%{?rhel:%rhel} >= 5 || 0%{?centos:%centos} >= 5 -%define has_ruby_noarch %has_ruby_abi - -Summary: A network tool for managing many disparate systems -Name: puppet -Version: 0.24.6 -Release: 1%{?dist} -License: GPLv2+ -Group: System Environment/Base - -URL: http://puppet.reductivelabs.com/ -Source: http://reductivelabs.com/downloads/puppet/%{name}-%{version}.tgz - -Requires: ruby >= 1.8.1 -%if %has_ruby_abi -Requires: ruby(abi) = 1.8 +Name: puppet +Version: 0.24.6 +Release: 1%{?dist} +Summary: A network tool for managing many disparate systems +License: GPLv2+ +URL: http://puppet.reductivelabs.com/ +Source0: http://reductivelabs.com/downloads/puppet/%{name}-%{version}.tgz +BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) + +BuildRequires: ruby >= 1.8.1 + +%if 0%{?fedora} || 0%{?rhel} >= 5 +BuildArch: noarch +Requires: ruby(abi) = 1.8 +Requires: ruby-shadow %endif -Requires: facter >= 1.1.4 -BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) -%if %has_ruby_noarch -BuildArchitectures: noarch -%endif -BuildRequires: ruby >= 1.8.1 + +Requires: facter >= 1.1.4 +Requires: ruby >= 1.8.1 +Requires(pre): shadow-utils +Requires(post): chkconfig +Requires(preun): chkconfig +Requires(preun): initscripts +Requires(postun): initscripts %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, +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} +Group: System Environment/Base +Summary: Server for the puppet system management tool +Requires: puppet = %{version}-%{release} +Requires(post): chkconfig +Requires(preun): chkconfig +Requires(preun): initscripts +Requires(postun): initscripts %description server Provides the central puppet server daemon which provides manifests to clients. @@ -45,7 +49,7 @@ The server can also function as a certificate authority and file server. %setup -q %build -for f in bin/* ; do +for f in bin/* ; do sed -i -e '1c#!/usr/bin/ruby' $f done # Fix some rpmlint complaints @@ -54,6 +58,9 @@ 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 + sed -i -e '1d' lib/puppet/$f +done find examples/ -type f -empty | xargs rm find examples/ -type f | xargs chmod a-x @@ -69,14 +76,14 @@ install -d -m0755 %{buildroot}%{_mandir}/man8 install -d -m0755 %{buildroot}%{_localstatedir}/lib/puppet install -d -m0755 %{buildroot}%{_localstatedir}/run/puppet install -d -m0755 %{buildroot}%{_localstatedir}/log/puppet -install -Dp -m0755 %{pbuild}/bin/* %{buildroot}%{_sbindir} +install -Dp -m0755 bin/* %{buildroot}%{_sbindir} mv %{buildroot}%{_sbindir}/puppet %{buildroot}%{_bindir}/puppet mv %{buildroot}%{_sbindir}/ralsh %{buildroot}%{_bindir}/ralsh mv %{buildroot}%{_sbindir}/filebucket %{buildroot}%{_bindir}/filebucket mv %{buildroot}%{_sbindir}/puppetrun %{buildroot}%{_bindir}/puppetrun mv %{buildroot}%{_sbindir}/puppetdoc %{buildroot}%{_bindir}/puppetdoc -install -Dp -m0644 %{pbuild}/lib/puppet.rb %{buildroot}%{ruby_sitelibdir}/puppet.rb -cp -a %{pbuild}/lib/puppet %{buildroot}%{ruby_sitelibdir} +install -Dp -m0644 lib/puppet.rb %{buildroot}%{ruby_sitelibdir}/puppet.rb +cp -a lib/puppet %{buildroot}%{ruby_sitelibdir} find %{buildroot}%{ruby_sitelibdir} -type f -perm +ugo+x -print0 | xargs -0 -r chmod a-x install -Dp -m0644 %{confdir}/client.sysconfig %{buildroot}%{_sysconfdir}/sysconfig/puppet install -Dp -m0755 %{confdir}/client.init %{buildroot}%{_initrddir}/puppet @@ -136,40 +143,59 @@ touch %{buildroot}%{_sysconfdir}/puppet/puppetd.conf %doc %{_mandir}/man8/puppetrun.8.gz %pre -/usr/sbin/groupadd -r puppet 2>/dev/null || : -/usr/sbin/useradd -g puppet -c "Puppet" \ - -s /sbin/nologin -r -d /var/lib/puppet puppet 2> /dev/null || : +getent group puppet >/dev/null || groupadd -r puppet +getent passwd puppet >/dev/null || \ +useradd -r -g puppet -d %{_localstatedir}/lib/puppet -s /sbin/nologin \ + -c "Puppet" puppet || : +# ensure that old setups have the right puppet home dir if [ $1 -gt 1 ] ; then - /usr/sbin/usermod -d /var/lib/puppet puppet || : + usermod -d %{_localstatedir}/lib/puppet puppet || : fi + %post -/sbin/chkconfig --add puppet -exit 0 +/sbin/chkconfig --add puppet || : %post server -/sbin/chkconfig --add puppetmaster +/sbin/chkconfig --add puppetmaster || : %preun if [ "$1" = 0 ] ; then /sbin/service puppet stop > /dev/null 2>&1 - /sbin/chkconfig --del puppet + /sbin/chkconfig --del puppet || : fi %preun server if [ "$1" = 0 ] ; then /sbin/service puppetmaster stop > /dev/null 2>&1 - /sbin/chkconfig --del puppetmaster + /sbin/chkconfig --del puppetmaster || : +fi + +%postun +if [ "$1" -ge 1 ]; then + /sbin/service puppet condrestart >/dev/null 2>&1 || : fi %postun server if [ "$1" -ge 1 ]; then - /sbin/service puppetmaster condrestart > /dev/null 2>&1 + /sbin/service puppetmaster condrestart > /dev/null 2>&1 || : fi %clean rm -rf %{buildroot} %changelog +* Wed Oct 22 2008 Todd Zullinger <tmz@pobox.com> - 0.24.6-1 +- Update to 0.24.6 +- Require ruby-shadow on Fedora and RHEL >= 5 +- Simplify Fedora/RHEL version checks for ruby(abi) and BuildArch +- Require chkconfig and initstripts for preun, post, and postun scripts +- Conditionally restart puppet in %%postun +- Ensure %%preun, %%post, and %%postun scripts exit cleanly +- Create puppet user/group according to Fedora packaging guidelines +- Quiet a few rpmlint complaints +- Remove useless %%pbuild macro +- Make specfile more like the Fedora/EPEL template + * Mon Jul 28 2008 David Lutterkort <dlutter@redhat.com> - 0.24.5-1 - Add /usr/bin/puppetdoc @@ -205,7 +231,7 @@ rm -rf %{buildroot} - Remove old config files * Wed Jun 20 2007 David Lutterkort <dlutter@redhat.com> - 0.23.0-1 -- Install one puppet.conf instead of old config files, keep old configs +- Install one puppet.conf instead of old config files, keep old configs around to ease update - Use plain shell commands in install instead of macros @@ -266,7 +292,7 @@ rm -rf %{buildroot} * Mon Jun 19 2006 David Lutterkort <dlutter@redhat.com> - 0.18.0-1 - Patch config for LSB compliance (lsb-config.patch) -- Changed config moves /var/puppet to /var/lib/puppet, /etc/puppet/ssl +- Changed config moves /var/puppet to /var/lib/puppet, /etc/puppet/ssl to /var/lib/puppet, /etc/puppet/clases.txt to /var/lib/puppet/classes.txt, /etc/puppet/localconfig.yaml to /var/lib/puppet/localconfig.yaml @@ -289,7 +315,7 @@ rm -rf %{buildroot} - Rebuilt for new version * Wed Mar 22 2006 David Lutterkort <dlutter@redhat.com> - 0.15.1-1 -- Patch0: Run puppetmaster as root; running as puppet is not ready +- Patch0: Run puppetmaster as root; running as puppet is not ready for primetime * Mon Mar 13 2006 David Lutterkort <dlutter@redhat.com> - 0.15.0-1 @@ -304,7 +330,7 @@ rm -rf %{buildroot} allocate the puppet uid/gid dynamically * Sun Feb 19 2006 David Lutterkort <dlutter@redhat.com> - 0.13.0-4 -- Use fedora-usermgmt to create puppet user/group. Use uid/gid 24. Fixed +- Use fedora-usermgmt to create puppet user/group. Use uid/gid 24. Fixed problem with listing fileserver.conf and puppetmaster.conf twice * Wed Feb 8 2006 David Lutterkort <dlutter@redhat.com> - 0.13.0-3 @@ -329,7 +355,7 @@ problem with listing fileserver.conf and puppetmaster.conf twice - 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 +- 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> diff --git a/lib/puppet/feature/base.rb b/lib/puppet/feature/base.rb index 518e9b419..0b12d730a 100644 --- a/lib/puppet/feature/base.rb +++ b/lib/puppet/feature/base.rb @@ -22,3 +22,6 @@ Puppet.features.add(:mongrel, :libs => %w{rubygems mongrel puppet/network/http_s # We have lcs diff Puppet.features.add :diff, :libs => %w{diff/lcs diff/lcs/hunk} + +# We have augeas +Puppet.features.add(:augeas, :libs => ["augeas"]) diff --git a/lib/puppet/parameter.rb b/lib/puppet/parameter.rb index f90193fc8..06dfe5b91 100644 --- a/lib/puppet/parameter.rb +++ b/lib/puppet/parameter.rb @@ -63,7 +63,7 @@ class Puppet::Parameter end unless regs.empty? @doc += " Values can also match ``" + - regs.join("``, ``") + "``." + regs.collect { |r| r.inspect }.join("``, ``") + "``." end end diff --git a/lib/puppet/parser/ast/astarray.rb b/lib/puppet/parser/ast/astarray.rb index 8f09aa922..0fccbca75 100644 --- a/lib/puppet/parser/ast/astarray.rb +++ b/lib/puppet/parser/ast/astarray.rb @@ -30,10 +30,9 @@ class Puppet::Parser::AST items << child end } - rets = items.flatten.collect { |child| child.safeevaluate(scope) - } + }.flatten return rets.reject { |o| o.nil? } end diff --git a/lib/puppet/parser/ast/hostclass.rb b/lib/puppet/parser/ast/hostclass.rb index 7f89f8151..4f5c4797c 100644 --- a/lib/puppet/parser/ast/hostclass.rb +++ b/lib/puppet/parser/ast/hostclass.rb @@ -56,7 +56,12 @@ class Puppet::Parser::AST::HostClass < Puppet::Parser::AST::Definition # Don't create a subscope for the top-level class, since it already # has its own scope. - scope = subscope(scope, resource) unless resource.title == :main + unless resource.title == :main + scope = subscope(scope, resource) + + scope.setvar("title", resource.title) + scope.setvar("name", resource.name) + end # Add the parent scope namespaces to our own. if pnames diff --git a/lib/puppet/parser/lexer.rb b/lib/puppet/parser/lexer.rb index 9226434da..dd6c29d9f 100644 --- a/lib/puppet/parser/lexer.rb +++ b/lib/puppet/parser/lexer.rb @@ -157,6 +157,11 @@ class Puppet::Parser::Lexer TOKENS.add_token :COMMENT, %r{#.*}, :skip => true + TOKENS.add_token :MLCOMMENT, %r{/\*(.*?)\*/}m do |lexer, value| + lexer.line += value.count("\n") + [nil,nil] + end + TOKENS.add_token :RETURN, "\n", :skip => true, :incr_line => true, :skip_text => true TOKENS.add_token :SQUOTE, "'" do |lexer, value| diff --git a/lib/puppet/parser/parser_support.rb b/lib/puppet/parser/parser_support.rb index 853d6aa86..1583973a7 100644 --- a/lib/puppet/parser/parser_support.rb +++ b/lib/puppet/parser/parser_support.rb @@ -291,10 +291,14 @@ class Puppet::Parser::Parser if tmp == "" tmp = "main" end - + Puppet.debug addcontext("Adding code to %s" % tmp) # Else, add our code to it. if other.code and code + # promote if neededcodes to ASTArray so that we can append code + # ASTArray knows how to evaluate its members. + other.code = ast AST::ASTArray, :children => [other.code] unless other.code.is_a?(AST::ASTArray) + code = ast AST::ASTArray, :children => [code] unless code.is_a?(AST::ASTArray) other.code.children += code.children else other.code ||= code diff --git a/lib/puppet/provider/augeas/augeas.rb b/lib/puppet/provider/augeas/augeas.rb new file mode 100644 index 000000000..cadbd667b --- /dev/null +++ b/lib/puppet/provider/augeas/augeas.rb @@ -0,0 +1,189 @@ +#-- +# Copyright (C) 2008 Red Hat Inc. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# Author: Bryan Kearney <bkearney@redhat.com> + +require 'augeas' if Puppet.features.augeas? + +Puppet::Type.type(:augeas).provide(:augeas) do +#class Puppet::Provider::Augeas < Puppet::Provider + include Puppet::Util + + confine :true => Puppet.features.augeas? + + has_features :parse_commands, :need_to_run?,:execute_changes + + # Extracts an 2 dimensional array of commands which are in the + # form of command path value. + # The input can be + # - A string with one command + # - A string with many commands per line + # - An array of strings. + def parse_commands(data) + commands = Array.new() + if data.is_a?(String) + data.each_line do |line| + cmd_array = Array.new() + tokens = line.split(" ") + cmd = tokens.shift() + file = tokens.shift() + other = tokens.join(" ") + cmd_array << cmd if !cmd.nil? + cmd_array << file if !file.nil? + cmd_array << other if other != "" + commands << cmd_array + end + elsif data.is_a?(Array) + data.each do |datum| + commands.concat(parse_commands(datum)) + end + end + + return commands + end + + def open_augeas + flags = 0 + (flags = 1 << 2 ) if self.resource[:type_check] == :true + root = self.resource[:root] + load_path = self.resource[:load_path] + debug("Opening augeas with root #{root}, lens path #{load_path}, flags #{flags}") + Augeas.open(root, load_path,flags) + end + + # Used by the need_to_run? method to process get filters. Returns + # true if there is a match, false if otherwise + # Assumes a syntax of get /files/path [COMPARATOR] value + def process_get(cmd_array) + return_value = false + + #validate and tear apart the command + fail ("Invalid command: #{cmd_array.join(" ")}") if cmd_array.length < 4 + cmd = cmd_array.shift() + path = cmd_array.shift() + comparator = cmd_array.shift() + arg = cmd_array.join(" ") + + #check the value in augeas + aug = open_augeas() + result = aug.get(path) || '' + unless result.nil? + case comparator + when "!=": + return_value = true if !(result == arg) + when "=~": + regex = Regexp.new(arg) + loc = result=~ regex + return_value = true if ! loc.nil? + else + return_value = true if (result.send(comparator, arg)) + end + end + return_value + end + + # Used by the need_to_run? method to process match filters. Returns + # true if there is a match, false if otherwise + def process_match(cmd_array) + return_value = false + + #validate and tear apart the command + fail("Invalid command: #{cmd_array.join(" ")}") if cmd_array.length < 4 + cmd = cmd_array.shift() + path = cmd_array.shift() + verb = cmd_array.shift() + + #Get the values from augeas + aug = open_augeas() + result = aug.match(path) || '' + # Now do the work + if (!result.nil?) + case verb + when "size": + fail("Invalid command: #{cmd_array.join(" ")}") if cmd_array.length != 2 + comparator = cmd_array.shift() + arg = cmd_array.shift().to_i + return_value = true if (result.size.send(comparator, arg)) + when "include": + arg = cmd_array.join(" ") + return_value = true if result.include?(arg) + when "==": + begin + arg = cmd_array.join(" ") + new_array = eval arg + return_value = true if result == new_array + rescue + fail("Invalid array in command: #{cmd_array.join(" ")}") + end + end + end + return_value + end + + # Determines if augeas acutally needs to run. + def need_to_run? + return_value = true + filter = resource[:onlyif] + unless (filter == "") + cmd_array = filter.split + command = cmd_array[0]; + cmd_array[1]= File.join(resource[:context], cmd_array[1]) + begin + data = nil + case command + when "get" then return_value = process_get(cmd_array) + when "match" then return_value = process_match(cmd_array) + end + rescue Exception => e + fail("Error sending command '#{command}' with params #{cmd_array[1..-1].inspect}/#{e.message}") + end + end + return_value + end + + # Actually execute the augeas changes. + def execute_changes + aug = open_augeas + commands = resource[:changes] + context = resource[:context] + commands.each do |cmd_array| + fail("invalid command #{cmd_array.join[" "]}") if cmd_array.length < 2 + command = cmd_array[0] + cmd_array.shift() + cmd_array[0]=File.join(context, cmd_array[0]) + debug("sending command '#{command}' with params #{cmd_array.inspect}") + begin + case command + when "set": aug.set(cmd_array[0], cmd_array[1]) + when "rm", "remove": aug.rm(cmd_array[0]) + when "clear": aug.clear(cmd_array[0]) + when "insert", "ins": aug.insert(cmd_array[0]) + else fail("Command '#{command}' is not supported") + end + rescue Exception => e + fail("Error sending command '#{command}' with params #{cmd_array.inspect}/#{e.message}") + end + end + success = aug.save() + if (success != true) + fail("Save failed with return code #{success}") + end + + return :executed + end + +end diff --git a/lib/puppet/type/augeas.rb b/lib/puppet/type/augeas.rb new file mode 100644 index 000000000..61339407b --- /dev/null +++ b/lib/puppet/type/augeas.rb @@ -0,0 +1,150 @@ +#-- +# Copyright (C) 2008 Red Hat Inc. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Publicretu +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# Author: Bryan Kearney <bkearney@redhat.com> + +Puppet::Type.newtype(:augeas) do + include Puppet::Util + + feature :parse_commands, "Parse the command string" + feature :need_to_run?, "If the command should run" + feature :execute_changes, "Actually make the changes" + + @doc = "Apply the changes (single or array of changes) to the filesystem + via the augeas tool. + + Requires: + - augeas to be installed (http://www.augeas.net) + - ruby-augeas bindings + + Sample usage with a string: + augeas{\"test1\" : + context => \"/files/etc/sysconfig/firstboot\", + changes => \"set RUN_FIRSTBOOT YES\", + onlyif => \"match other_value size > 0\", + } + + Sample usage with an array and custom lenses: + augeas{\"jboss_conf\": + context => \"/files\", + changes => [ + \"set /etc/jbossas/jbossas.conf/JBOSS_IP $ipaddress\", + \"set /etc/jbossas/jbossas.conf/JAVA_HOME /usr\" + ], + load_path => \"$/usr/share/jbossas/lenses\", + } + " + + newparam (:name) do + desc "The name of this task. Used for uniqueness" + isnamevar + end + + newparam (:context) do + desc "Optional context path. This value is pre-pended to the paths of all changes" + defaultto "" + end + + newparam (:onlyif) do + desc "Optional augeas command and comparisons to control the execution of this type. + Supported onlyif syntax: + get [AUGEAS_PATH] [COMPARATOR] [STRING] + match [MATCH_PATH] size [COMPARATOR] [INT] + match [MATCH_PATH] include [STRING] + match [MATCH_PATH] == [AN_ARRAY] + + where + AUGEAS_PATH is a valid path scoped by the context + MATCH_PATH is a valid match synatx scoped by the context + COMPARATOR is in the set [> >= != == <= <] + STRING is a string + INT is a number + AN_ARRAY is in the form ['a string', 'another'] " + defaultto "" + end + + + newparam(:changes) do + desc "The changes which should be applied to the filesystem. This + can be either a string which contains a command or an array of commands. + Commands supported are: + + set [PATH] [VALUE] Sets the value VALUE at loction PATH + rm [PATH] Removes the node at location PATH + remove [PATH] Synonym for rm + clear [PATH] Keeps the node at PATH, but removes the value. + ins [PATH] Inserts an empty node at PATH. + insert [PATH] Synonym for ins + + If the parameter 'context' is set that that value is prepended to PATH" + + munge do |value| + provider.parse_commands(value) + end + end + + + newparam(:root) do + desc "A file system path; all files loaded by Augeas are loaded underneath ROOT" + defaultto "/" + end + + newparam(:load_path) do + desc "Optional colon separated list of directories; these directories are searched for schema definitions" + defaultto "" + end + + + newparam(:type_check) do + desc "Set to true if augeas should perform typechecking. Optional, defaults to false" + newvalues(:true, :false) + + defaultto :false + end + + # This is the acutal meat of the code. It forces + # augeas to be run and fails or not based on the augeas return + # code. + newproperty(:returns) do |property| + include Puppet::Util + desc "The expected return code from the augeas command. Should not be set" + + defaultto 0 + + # Make output a bit prettier + def change_to_s(currentvalue, newvalue) + return "executed successfully" + end + + # if the onlyif resource is provided, then the value is parsed. + # a return value of 0 will stop exection becuase it matches the + # default value. + def retrieve + if @resource.provider.need_to_run?() + :need_to_run + else + 0 + end + end + + # Actually execute the command. + def sync + @resource.provider.execute_changes() + end + end + +end diff --git a/lib/puppet/type/k5login.rb b/lib/puppet/type/k5login.rb index 2372f658a..d22be11b7 100644 --- a/lib/puppet/type/k5login.rb +++ b/lib/puppet/type/k5login.rb @@ -46,7 +46,7 @@ Puppet::Type.newtype(:k5login) do write(@resource.should(:principals)) should_mode = @resource.should(:mode) unless self.mode == should_mode - self.mode should_mode + self.mode = should_mode end end diff --git a/lib/puppet/type/mount.rb b/lib/puppet/type/mount.rb index 1679b73a3..4eb149488 100755 --- a/lib/puppet/type/mount.rb +++ b/lib/puppet/type/mount.rb @@ -143,7 +143,7 @@ module Puppet desc "Whether to dump the mount. Not all platforms support this. Valid values are ``1`` or ``0``. Default is ``0``." - newvalue(%r{(0|1)}) { } + newvalue(%r{(0|1)}) defaultto { if @resource.managed? diff --git a/lib/puppet/type/tidy.rb b/lib/puppet/type/tidy.rb index fe8bde9ab..c352ec85b 100755 --- a/lib/puppet/type/tidy.rb +++ b/lib/puppet/type/tidy.rb @@ -2,7 +2,10 @@ module Puppet newtype(:tidy, :parent => Puppet.type(:file)) do @doc = "Remove unwanted files based on specific criteria. Multiple criteria are OR'd together, so a file that is too large but is not - old enough will still get tidied." + old enough will still get tidied. + + You must specify either the size or age of the file (or both) for + files to be tidied." newparam(:path) do desc "The path to the file or directory to manage. Must be fully @@ -249,6 +252,23 @@ module Puppet newparam(:recurse) do desc "If target is a directory, recursively descend into the directory looking for files to tidy." + + newvalues(:true, :false, :inf, /^[0-9]+$/) + + # Replace the validation so that we allow numbers in + # addition to string representations of them. + validate { |arg| } + munge do |value| + newval = super(value) + case newval + when :true, :inf: true + when :false: false + when Integer, Fixnum, Bignum: value + when /^\d+$/: Integer(value) + else + raise ArgumentError, "Invalid recurse value %s" % value.inspect + end + end end newparam(:rmdirs) do diff --git a/lib/puppet/util/log.rb b/lib/puppet/util/log.rb index 0dfd36dfa..b57faad42 100644 --- a/lib/puppet/util/log.rb +++ b/lib/puppet/util/log.rb @@ -369,11 +369,7 @@ class Puppet::Util::Log end def handle(msg) - # Only add messages from objects, since anything else is - # probably unrelated to this run. - if msg.objectsource? - @report.newlog(msg) - end + @report.newlog(msg) end end @@ -505,15 +501,6 @@ class Puppet::Util::Log Log.newmessage(self) end - # Was the source of this log a Puppet resource or parameter? - def objectsource? - if defined? @objectsource and @objectsource - @objectsource - else - false - end - end - # If they pass a source in to us, we make sure it is a string, and # we retrieve any tags we can. def source=(source) @@ -521,10 +508,8 @@ class Puppet::Util::Log # We can't just check for whether it responds to :path, because # plenty of providers respond to that in their normal function. if (source.is_a?(Puppet::Type) or source.is_a?(Puppet::Parameter)) and source.respond_to?(:path) - @objectsource = true @source = source.path else - @objectsource = false @source = source.to_s end if source.respond_to?(:tags) diff --git a/spec/unit/parser/ast/astarray.rb b/spec/unit/parser/ast/astarray.rb new file mode 100755 index 000000000..f1c28ce47 --- /dev/null +++ b/spec/unit/parser/ast/astarray.rb @@ -0,0 +1,66 @@ +#!/usr/bin/env ruby + +require File.dirname(__FILE__) + '/../../../spec_helper' + +describe Puppet::Parser::AST::ASTArray do + before :each do + @scope = Puppet::Parser::Scope.new() + end + + it "should have a [] accessor" do + array = Puppet::Parser::AST::ASTArray.new :children => [] + array.should respond_to(:[]) + end + + it "should evaluate all its children" do + item1 = stub "item1", :is_a? => true + item2 = stub "item2", :is_a? => true + + item1.expects(:safeevaluate).with(@scope).returns(123) + item2.expects(:safeevaluate).with(@scope).returns(246) + + operator = Puppet::Parser::AST::ASTArray.new :children => [item1,item2] + operator.evaluate(@scope) + end + + it "should evaluate childrens of type ASTArray" do + item1 = stub "item1", :is_a? => true + item2 = stub "item2" + item2.stubs(:is_a?).with(Puppet::Parser::AST).returns(true) + item2.stubs(:instance_of?).with(Puppet::Parser::AST::ASTArray).returns(true) + item2.stubs(:each).yields(item1) + + item1.expects(:safeevaluate).with(@scope).returns(123) + + operator = Puppet::Parser::AST::ASTArray.new :children => [item2] + operator.evaluate(@scope).should == [123] + end + + it "should flatten children coming from children ASTArray" do + item1 = stub "item1", :is_a? => true + item2 = stub "item2" + item2.stubs(:is_a?).with(Puppet::Parser::AST).returns(true) + item2.stubs(:instance_of?).with(Puppet::Parser::AST::ASTArray).returns(true) + item2.stubs(:each).yields([item1]) + + item1.expects(:safeevaluate).with(@scope).returns(123) + + operator = Puppet::Parser::AST::ASTArray.new :children => [item2] + operator.evaluate(@scope).should == [123] + end + + it "should flatten the results of children evaluation" do + item1 = stub "item1", :is_a? => true + item2 = stub "item2" + item2.stubs(:is_a?).with(Puppet::Parser::AST).returns(true) + item2.stubs(:instance_of?).with(Puppet::Parser::AST::ASTArray).returns(true) + item2.stubs(:each).yields([item1]) + + item1.expects(:safeevaluate).with(@scope).returns([123]) + + operator = Puppet::Parser::AST::ASTArray.new :children => [item2] + operator.evaluate(@scope).should == [123] + end + + +end diff --git a/spec/unit/parser/ast/hostclass.rb b/spec/unit/parser/ast/hostclass.rb index 0abc174d9..10aa62176 100755 --- a/spec/unit/parser/ast/hostclass.rb +++ b/spec/unit/parser/ast/hostclass.rb @@ -123,6 +123,19 @@ describe Puppet::Parser::AST::HostClass do @compiler.class_scope(@middle).parent.should equal(@compiler.class_scope(@top)) end + it "should add the class's name and title to its own scope" do + @top_resource.stubs(:safeevaluate) + @middle_resource.stubs(:safeevaluate) + resource = @middle.evaluate(@scope) + scope = stub_everything 'scope', :compiler => @compiler + @middle.stubs(:subscope).returns(scope) + + scope.expects(:setvar).with("title","top::middle") + scope.expects(:setvar).with("name","top::middle") + + @middle.evaluate_code(resource) + end + it "should add the parent class's namespace to its namespace search path" do @top_resource.stubs(:safeevaluate) @middle_resource.stubs(:safeevaluate) diff --git a/spec/unit/parser/lexer.rb b/spec/unit/parser/lexer.rb index 3b0df96a9..d62d99258 100755 --- a/spec/unit/parser/lexer.rb +++ b/spec/unit/parser/lexer.rb @@ -201,7 +201,7 @@ describe Puppet::Parser::Lexer::TOKENS do end # These tokens' strings don't matter, just that the tokens exist. - [:DQTEXT, :SQTEXT, :BOOLEAN, :NAME, :NUMBER, :COMMENT, :RETURN, :SQUOTE, :DQUOTE, :VARIABLE].each do |name| + [:DQTEXT, :SQTEXT, :BOOLEAN, :NAME, :NUMBER, :COMMENT, :MLCOMMENT, :RETURN, :SQUOTE, :DQUOTE, :VARIABLE].each do |name| it "should have a token named #{name.to_s}" do Puppet::Parser::Lexer::TOKENS[name].should_not be_nil end @@ -287,6 +287,34 @@ describe Puppet::Parser::Lexer::TOKENS[:COMMENT] do end end +describe Puppet::Parser::Lexer::TOKENS[:MLCOMMENT] do + before do + @token = Puppet::Parser::Lexer::TOKENS[:MLCOMMENT] + @lexer = stub 'lexer', :line => 0 + end + + it "should match against lines enclosed with '/*' and '*/'" do + @token.regex.should =~ "/* this is a comment */" + end + + it "should match multiple lines enclosed with '/*' and '*/'" do + @token.regex.should =~ """/* + this is a comment + */""" + end + + it "should increase the lexer current line number by the amount of lines spanned by the comment" do + @lexer.expects(:line=).with(2) + @token.convert(@lexer, "1\n2\n3") + end + + it "should not greedily match comments" do + match = @token.regex.match("/* first */ word /* second */") + match[1].should == " first " + end + +end + describe Puppet::Parser::Lexer::TOKENS[:RETURN] do before { @token = Puppet::Parser::Lexer::TOKENS[:RETURN] } diff --git a/spec/unit/parser/parser.rb b/spec/unit/parser/parser.rb index 07aad588d..077f93d98 100755 --- a/spec/unit/parser/parser.rb +++ b/spec/unit/parser/parser.rb @@ -171,6 +171,34 @@ describe Puppet::Parser do it "should not raise errors with a trailing comma" do lambda { @parser.parse("$a = [1,2,]") }.should_not raise_error end + end + + describe Puppet::Parser, "when instantiating class of same name" do + + before :each do + @one = stub 'one', :is_a? => true + @one.stubs(:is_a?).with(AST::ASTArray).returns(false) + @one.stubs(:is_a?).with(AST).returns(true) + + @two = stub 'two' + @two.stubs(:is_a?).with(AST::ASTArray).returns(false) + @two.stubs(:is_a?).with(AST).returns(true) + end + + it "should return the first class" do + + klass1 = @parser.newclass("one", { :code => @one }) + + @parser.newclass("one", { :code => @two }).should == klass1 + end + + it "should concatenate code" do + klass1 = @parser.newclass("one", { :code => @one }) + + @parser.newclass("one", { :code => @two }) + + klass1.code.children.should == [@one,@two] + end end diff --git a/spec/unit/provider/augeas/augeas.rb b/spec/unit/provider/augeas/augeas.rb new file mode 100644 index 000000000..1bbf18f83 --- /dev/null +++ b/spec/unit/provider/augeas/augeas.rb @@ -0,0 +1,238 @@ +#!/usr/bin/env ruby + +require File.dirname(__FILE__) + '/../../../spec_helper' + +provider_class = Puppet::Type.type(:augeas).provider(:augeas) + +describe provider_class do + describe "command parsing" do + it "should break apart a single line into three tokens" do + provider = provider_class.new() + tokens = provider.parse_commands("set /Jar/Jar Binks") + tokens.size.should == 1 + tokens[0].size.should == 3 + tokens[0][0].should == "set" + tokens[0][1].should == "/Jar/Jar" + tokens[0][2].should == "Binks" + end + + it "should break apart a multiple line into six tokens" do + provider = provider_class.new() + tokens = provider.parse_commands("set /Jar/Jar Binks\nrm anakin skywalker") + tokens.size.should == 2 + tokens[0].size.should == 3 + tokens[1].size.should == 3 + tokens[0][0].should == "set" + tokens[0][1].should == "/Jar/Jar" + tokens[0][2].should == "Binks" + tokens[1][0].should == "rm" + tokens[1][1].should == "anakin" + tokens[1][2].should == "skywalker" + end + + it "should handle arrays" do + provider = provider_class.new() + commands = ["set /Jar/Jar Binks", "rm anakin skywalker"] + tokens = provider.parse_commands(commands) + tokens.size.should == 2 + tokens[0].size.should == 3 + tokens[1].size.should == 3 + tokens[0][0].should == "set" + tokens[0][1].should == "/Jar/Jar" + tokens[0][2].should == "Binks" + tokens[1][0].should == "rm" + tokens[1][1].should == "anakin" + tokens[1][2].should == "skywalker" + end + + it "should concat the last values" do + provider = provider_class.new() + tokens = provider.parse_commands("set /Jar/Jar Binks is my copilot") + tokens.size.should == 1 + tokens[0].size.should == 3 + tokens[0][0].should == "set" + tokens[0][1].should == "/Jar/Jar" + tokens[0][2].should == "Binks is my copilot" + end + end + + describe "get filters" do + before do + augeas_stub = stub("augeas", :get => "value") + @provider = provider_class.new() + @provider.stubs(:open_augeas).returns(augeas_stub) + end + + it "should return false for a = nonmatch" do + command = ["get", "fake value", "==", "value"] + @provider.process_get(command).should == true + end + + it "should return true for a != match" do + command = ["get", "fake value", "!=", "value"] + @provider.process_get(command).should == false + end + + it "should return true for a =~ match" do + command = ["get", "fake value", "=~", "val*"] + @provider.process_get(command).should == true + end + + it "should return false for a == nonmatch" do + command = ["get", "fake value", "=~", "num*"] + @provider.process_get(command).should == false + end + end + + describe "match filters" do + before do + augeas_stub = stub("augeas", :match => ["set", "of", "values"]) + @provider = provider_class.new() + @provider.stubs(:open_augeas).returns(augeas_stub) + end + + it "should return true for size match" do + command = ["match", "fake value", "size", "==", "3"] + @provider.process_match(command).should == true + end + + it "should return false for a size non match" do + command = ["match", "fake value", "size", "<", "3"] + @provider.process_match(command).should == false + end + + it "should return true for includes match" do + command = ["get", "fake value", "include", "values"] + @provider.process_match(command).should == true + end + + it "should return false for includes non match" do + command = ["get", "fake value", "include", "JarJar"] + @provider.process_match(command).should == false + end + + it "should return true for an array match" do + command = ["get", "fake value", "==", "['set', 'of', 'values']"] + @provider.process_match(command).should == true + end + + it "should return false for an array non match" do + command = ["get", "fake value", "==", "['this', 'should', 'not', 'match']"] + @provider.process_match(command).should == false + end + end + + describe "need_to_run" do + it "should handle no filters" do + resource = stub("resource", :[] => "") + provider = provider_class.new(resource) + provider.need_to_run?.should == true + end + + it "should return true when a get filter matches" do + resource = stub("resource", :[] => "get path == value") + provider = provider_class.new(resource) + augeas_stub = stub("augeas", :get => "value") + provider.stubs(:open_augeas).returns(augeas_stub) + provider.need_to_run?.should == true + end + + it "should return false when a get filter does not match" do + resource = stub("resource", :[] => "get path == another value") + provider = provider_class.new(resource) + augeas_stub = stub("augeas", :get => "value") + provider.stubs(:open_augeas).returns(augeas_stub) + provider.need_to_run?.should == false + end + + it "should return true when a match filter matches" do + resource = stub("resource", :[] => "match path size == 3") + provider = provider_class.new(resource) + augeas_stub = stub("augeas", :match => ["set", "of", "values"]) + provider.stubs(:open_augeas).returns(augeas_stub) + provider.need_to_run?.should == true + end + + it "should return false when a match filter does not match" do + resource = stub("resource", :[] => "match path size == 2") + provider = provider_class.new(resource) + augeas_stub = stub("augeas", :match => ["set", "of", "values"]) + provider.stubs(:open_augeas).returns(augeas_stub) + provider.need_to_run?.should == false + end + end + + describe "augeas integration" do + + before do + @resource = stub("resource") + @provider = provider_class.new(@resource) + @augeas = stub("augeas") + @provider.stubs(:open_augeas).returns(@augeas) + end + + it "should handle set commands" do + command = [["set", "/Jar/Jar", "Binks"]] + context = "/some/path" + @resource.expects(:[]).times(2).returns(command).then.returns(context) + @augeas.expects(:set).with("/some/path/Jar/Jar", "Binks") + @augeas.expects(:save).returns(true) + @provider.execute_changes.should == :executed + end + + it "should handle rm commands" do + command = [["rm", "/Jar/Jar"]] + context = "" + @resource.expects(:[]).times(2).returns(command).then.returns(context) + @augeas.expects(:rm).with("/Jar/Jar") + @augeas.expects(:save).returns(true) + @provider.execute_changes.should == :executed + end + + it "should handle remove commands" do + command = [["remove", "Jar/Jar"]] + context = "" + @resource.expects(:[]).times(2).returns(command).then.returns(context) + @augeas.expects(:rm).with("/Jar/Jar") + @augeas.expects(:save).returns(true) + @provider.execute_changes.should == :executed + end + + it "should handle clear commands" do + command = [["clear", "/Jar/Jar"]] + context = "/foo" + @resource.expects(:[]).times(2).returns(command).then.returns(context) + @augeas.expects(:clear).with("/foo/Jar/Jar") + @augeas.expects(:save).returns(true) + @provider.execute_changes.should == :executed + end + + it "should handle insert commands" do + command = [["insert", "/Jar/Jar"]] + context = "/foo" + @resource.expects(:[]).times(2).returns(command).then.returns(context) + @augeas.expects(:insert).with("/foo/Jar/Jar") + @augeas.expects(:save).returns(true) + @provider.execute_changes.should == :executed + end + + it "should handle ins commands" do + command = [["ins", "/Jar/Jar"]] + context = "/foo" + @resource.expects(:[]).times(2).returns(command).then.returns(context) + @augeas.expects(:insert).with("/foo/Jar/Jar") + @augeas.expects(:save).returns(true) + @provider.execute_changes.should == :executed + end + + it "should handle multiple commands" do + command = [["ins", "/Jar/Jar"], ["clear", "/Jar/Jar"]] + context = "/foo" + @resource.expects(:[]).times(2).returns(command).then.returns(context) + @augeas.expects(:insert).with("/foo/Jar/Jar") + @augeas.expects(:clear).with("/foo/Jar/Jar") + @augeas.expects(:save).returns(true) + @provider.execute_changes.should == :executed + end + end +end diff --git a/spec/unit/type/augeas.rb b/spec/unit/type/augeas.rb new file mode 100644 index 000000000..bda98b697 --- /dev/null +++ b/spec/unit/type/augeas.rb @@ -0,0 +1,103 @@ +#!/usr/bin/env ruby + +require File.dirname(__FILE__) + '/../../spec_helper' + +augeas = Puppet::Type.type(:augeas) + +describe augeas do + + describe "basic structure" do + it "should have a default provider inheriting from Puppet::Provider" do + augeas.defaultprovider.ancestors.should be_include(Puppet::Provider) + end + + it "should have a valid provider" do + augeas.create(:name => "foo").provider.class.ancestors.should be_include(Puppet::Provider) + end + + it "should be able to create a instance" do + augeas.create(:name => "bar").should_not be_nil + end + + it "should have an parse_commands feature" do + augeas.provider_feature(:parse_commands).should_not be_nil + end + + it "should have an need_to_run? feature" do + augeas.provider_feature(:need_to_run?).should_not be_nil + end + + it "should have an execute_changes feature" do + augeas.provider_feature(:execute_changes).should_not be_nil + end + + properties = [:returns] + params = [:name, :context, :onlyif, :changes, :root, :load_path, :type_check] + + properties.each do |property| + it "should have a %s property" % property do + augeas.attrclass(property).ancestors.should be_include(Puppet::Property) + end + + it "should have documentation for its %s property" % property do + augeas.attrclass(property).doc.should be_instance_of(String) + end + end + + params.each do |param| + it "should have a %s parameter" % param do + augeas.attrclass(param).ancestors.should be_include(Puppet::Parameter) + end + + it "should have documentation for its %s parameter" % param do + augeas.attrclass(param).doc.should be_instance_of(String) + end + end + end + + describe "default values" do + it "should be blank for context" do + augeas.create(:name => :context)[:context].should == "" + end + + it "should be blank for onlyif" do + augeas.create(:name => :onlyif)[:onlyif].should == "" + end + + it "should be blank for load_path" do + augeas.create(:name => :load_path)[:load_path].should == "" + end + + it "should be / for root" do + augeas.create(:name => :root)[:root].should == "/" + end + + it "should be false for type_check" do + augeas.create(:name => :type_check)[:type_check].should == :false + end + end + + describe "provider interaction" do + it "should munge the changes" do + provider = stub("provider", :parse_commands => "Jar Jar Binks") + resource = stub('resource', :resource => nil, :provider => provider, :line => nil, :file => nil) + changes = augeas.attrclass(:changes).new(:resource => resource) + changes.value= "Testing 123" + changes.value.should == "Jar Jar Binks" + end + + it "should return 0 if it does not need to run" do + provider = stub("provider", :need_to_run? => false) + resource = stub('resource', :resource => nil, :provider => provider, :line => nil, :file => nil) + changes = augeas.attrclass(:returns).new(:resource => resource) + changes.retrieve.should == 0 + end + + it "should return :need_to_run if it needs to run" do + provider = stub("provider", :need_to_run? => true) + resource = stub('resource', :resource => nil, :provider => provider, :line => nil, :file => nil) + changes = augeas.attrclass(:returns).new(:resource => resource) + changes.retrieve.should == :need_to_run + end + end +end diff --git a/spec/unit/type/mount.rb b/spec/unit/type/mount.rb index 9d09225cc..7ddb7ea26 100755 --- a/spec/unit/type/mount.rb +++ b/spec/unit/type/mount.rb @@ -180,3 +180,32 @@ describe Puppet::Type.type(:mount)::Ensure do end end end + +describe Puppet::Type.type(:mount), "when modifying an existing mount entry" do + before do + @provider = stub 'provider', :class => Puppet::Type.type(:mount).defaultprovider, :clear => nil, :satisfies? => true, :name => :mock, :remount => nil + Puppet::Type.type(:mount).defaultprovider.stubs(:new).returns(@provider) + @mount = Puppet::Type.type(:mount).create(:name => "yay", :ensure => :mounted) + + {:device => "/foo/bar", :blockdevice => "/other/bar", :target => "/what/ever", :fstype => 'eh', :options => "", :pass => 0, :dump => 0, :atboot => 0, + :ensure => :mounted}.each do + |param, value| + @mount.provider.stubs(param).returns value + @mount[param] = value + end + + @mount.provider.stubs(:mounted?).returns true + + @catalog = Puppet::Node::Catalog.new + @catalog.add_resource @mount + end + + it "should use the provider to change the dump value" do + @mount.provider.expects(:dump).returns 0 + @mount.provider.expects(:dump=).with(1) + + @mount[:dump] = 1 + + @catalog.apply + end +end diff --git a/spec/unit/type/tidy.rb b/spec/unit/type/tidy.rb new file mode 100755 index 000000000..89f178389 --- /dev/null +++ b/spec/unit/type/tidy.rb @@ -0,0 +1,59 @@ +#!/usr/bin/env ruby + +require File.dirname(__FILE__) + '/../../spec_helper' + +tidy = Puppet::Type.type(:tidy) + +describe tidy do + [:ensure, :age, :size].each do |property| + it "should have a %s property" % property do + tidy.attrclass(property).ancestors.should be_include(Puppet::Property) + end + + it "should have documentation for its %s property" % property do + tidy.attrclass(property).doc.should be_instance_of(String) + end + end + + [:path, :matches, :type, :recurse, :rmdirs].each do |param| + it "should have a %s parameter" % param do + tidy.attrclass(param).ancestors.should be_include(Puppet::Parameter) + end + + it "should have documentation for its %s param" % param do + tidy.attrclass(param).doc.should be_instance_of(String) + end + end + + describe "when validating parameter values" do + describe "for 'recurse'" do + before do + @tidy = tidy.create :path => "/tmp", :age => "100d" + end + + it "should allow 'true'" do + lambda { @tidy[:recurse] = true }.should_not raise_error + end + + it "should allow 'false'" do + lambda { @tidy[:recurse] = false }.should_not raise_error + end + + it "should allow integers" do + lambda { @tidy[:recurse] = 10 }.should_not raise_error + end + + it "should allow string representations of integers" do + lambda { @tidy[:recurse] = "10" }.should_not raise_error + end + + it "should allow 'inf'" do + lambda { @tidy[:recurse] = "inf" }.should_not raise_error + end + + it "should not allow arbitrary values" do + lambda { @tidy[:recurse] = "whatever" }.should raise_error + end + end + end +end diff --git a/spec/unit/util/log.rb b/spec/unit/util/log.rb index aa00602a9..c42b25c74 100755 --- a/spec/unit/util/log.rb +++ b/spec/unit/util/log.rb @@ -103,51 +103,5 @@ describe Puppet::Util::Log do report.should be_include(log.source) report.should be_include(log.time.to_s) end - - it "should have a method for indicating whether it was created by a resource" do - Puppet::Util::Log.new(:level => "notice", :message => :foo).should respond_to(:objectsource?) - end - - describe "when setting a source" do - it "should mark itself as from a Puppet resource if its source is a Puppet resource" do - file = Puppet::Type.type(:file).create :path => "/testing/object/source/in/logs" - Puppet::Util::Log.new(:level => "notice", :message => :foo, :source => file).should be_objectsource - end - - it "should use the resource's path when its source is a resource" do - # Use a different path, so we don't use 'clear', which is deprecated in master - file = Puppet::Type.type(:file).create :path => "/testing/object/source/in/logs/with/path" - file.expects(:path).returns "mypath" - Puppet::Util::Log.new(:level => "notice", :message => :foo, :source => file).source.should == "mypath" - end - - it "should mark itself as from a Puppet resource if its source is a Puppet parameter" do - file = Puppet::Type.type(:file).create :path => "/testing/object/source/in/logs/with/parameters", :mode => "500" - mode = file.property(:mode) - Puppet::Util::Log.new(:level => "notice", :message => :foo, :source => mode).should be_objectsource - end - - it "should use the resource's path when its source is a Puppet parameter" do - # Use a different path, so we don't use 'clear', which is deprecated in master - file = Puppet::Type.type(:file).create :path => "/testing/object/source/in/logs/with/path/in/parameters", :mode => "500" - mode = file.property(:mode) - mode.expects(:path).returns "mypath" - Puppet::Util::Log.new(:level => "notice", :message => :foo, :source => mode).source.should == "mypath" - end - - it "should acquire its source's tags if its source has any" do - file = Puppet::Type.type(:file).create :path => "/testing/object/source/in/logs/with/tags" - file.tag("foo") - file.tag("bar") - log = Puppet::Util::Log.new(:level => "notice", :message => :foo, :source => file) - - log.should be_tagged("foo") - log.should be_tagged("bar") - end - - it "should not set objectsource if the source is not a Parameter or Resource" do - Puppet::Util::Log.new(:level => "notice", :message => :foo, :source => "mysource").should_not be_objectsource - end - end end end diff --git a/test/certmgr/support.rb b/test/certmgr/support.rb index 10d431939..d418c6771 100755 --- a/test/certmgr/support.rb +++ b/test/certmgr/support.rb @@ -86,17 +86,11 @@ class TestCertSupport < Test::Unit::TestCase # Write a key out to disk in a file containing upper-case. key = OpenSSL::PKey::RSA.new(32) should_path = Puppet[:hostprivkey] - puts "%s: %s" % [should_path, FileTest.exist?(should_path).inspect] dir, file = File.split(should_path) newfile = file.sub(/^([a-z.]+)\./) { $1.upcase + "."} - puts "%s: %s" % [should_path, FileTest.exist?(should_path).inspect] upper_path = File.join(dir, newfile) - puts "%s: %s" % [should_path, FileTest.exist?(should_path).inspect] - puts "%s: %s" % [upper_path, FileTest.exist?(upper_path).inspect] File.open(upper_path, "w") { |f| f.print key.to_s } - puts "%s: %s" % [should_path, FileTest.exist?(should_path).inspect] - puts "%s: %s" % [upper_path, FileTest.exist?(upper_path).inspect] user = CertUser.new diff --git a/test/data/snippets/multilinecomments.pp b/test/data/snippets/multilinecomments.pp new file mode 100644 index 000000000..816baebd7 --- /dev/null +++ b/test/data/snippets/multilinecomments.pp @@ -0,0 +1,6 @@ + +/* +file { + "/tmp/multilinecomments": content => "pouet" +} +*/ diff --git a/test/data/snippets/multipleclass.pp b/test/data/snippets/multipleclass.pp new file mode 100644 index 000000000..ae02edc38 --- /dev/null +++ b/test/data/snippets/multipleclass.pp @@ -0,0 +1,9 @@ +class one { + file { "/tmp/multipleclassone": content => "one" } +} + +class one { + file { "/tmp/multipleclasstwo": content => "two" } +} + +include one diff --git a/test/language/snippets.rb b/test/language/snippets.rb index 069f7aced..2a997c877 100755 --- a/test/language/snippets.rb +++ b/test/language/snippets.rb @@ -30,6 +30,13 @@ class TestSnippets < Test::Unit::TestCase end end + def assert_not_file(path, msg = nil) + if file = @file[path] + msg ||= "File %s exists!" % path + raise msg + end + end + def assert_mode_equal(mode, path) unless file = @catalog.resource(:file, path) raise "Could not find file %s" % path @@ -459,6 +466,15 @@ class TestSnippets < Test::Unit::TestCase "Did not make second file from array") end + def snippet_multipleclass + assert_file("/tmp/multipleclassone", "one") + assert_file("/tmp/multipleclasstwo", "two") + end + + def snippet_multilinecomments + assert_not_file("/tmp/multilinecomments","Did create a commented resource"); + end + # Iterate across each of the snippets and create a test. Dir.entries(snippetdir).sort.each { |file| next if file =~ /^\./ |