From c7dc73f272c1e004ff1b7c806d5f47460b6bfe6d Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Tue, 8 Jul 2008 14:57:20 -0500 Subject: Fixing the user ldap provider tests Signed-off-by: Luke Kanies --- spec/unit/provider/user/ldap.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/unit/provider/user/ldap.rb b/spec/unit/provider/user/ldap.rb index 7e039d582..f1c571779 100755 --- a/spec/unit/provider/user/ldap.rb +++ b/spec/unit/provider/user/ldap.rb @@ -26,6 +26,7 @@ describe provider_class do it "should be able to manage passwords" do provider_class.should be_manages_passwords + end it "should use the ldap group provider to convert group names to numbers" do provider = provider_class.new(:name => "foo") -- cgit From 9eb9affe11b4dbe69c7cd55aff28f39dffde27e8 Mon Sep 17 00:00:00 2001 From: James Turnbull Date: Wed, 9 Jul 2008 09:29:51 +1000 Subject: Fixed #1368 - updated Red Hat init scripts --- CHANGELOG | 4 +++- conf/redhat/client.init | 10 +++++++++- conf/redhat/server.init | 10 +++++++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index e88e20269..5214d6462 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,7 @@ 0.24.5 - Added message referencing ReductveLabs build library + Fixed #1368 - updated Red Hat init scripts + + Added message referencing ReductiveLabs build library Fixed #1396 - Added sha1 function from DavidS to core diff --git a/conf/redhat/client.init b/conf/redhat/client.init index b77bd017a..c3cb91e90 100644 --- a/conf/redhat/client.init +++ b/conf/redhat/client.init @@ -62,6 +62,11 @@ restart() { start } +genconfig() { + echo -n $"Generate configuration puppet: " + $puppetd ${PUPPET_OPTS} ${PUPPET_EXTRA_OPTS} --genconfig +} + case "$1" in start) start @@ -86,8 +91,11 @@ case "$1" in shift $puppetd -o ${PUPPET_OPTS} ${PUPPET_EXTRA_OPTS} $@ ;; + genconfig) + genconfig + ;; *) - echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart|once}" + echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart|once|genconfig}" exit 1 esac diff --git a/conf/redhat/server.init b/conf/redhat/server.init index b64622140..8266977de 100644 --- a/conf/redhat/server.init +++ b/conf/redhat/server.init @@ -62,6 +62,11 @@ restart() { start } +genconfig() { + echo -n $"Generate configuration puppetmaster: " + $PUPPETMASTER $PUPPETMASTER_OPTS --genconfig +} + case "$1" in start) start @@ -79,8 +84,11 @@ case "$1" in status $PUPPETMASTER RETVAL=$? ;; + genconfig) + genconfig + ;; *) - echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart}" + echo $"Usage: $0 {start|stop|status|restart|reload|force-reload|condrestart|genconfig}" exit 1 esac -- cgit From d25c2b282cc4cd703bba3d2457f93431098ddc85 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Wed, 9 Jul 2008 10:29:45 -0500 Subject: Fixed #1407 - allowdupe is now a boolean group parameter. This just fixes a regression. Signed-off-by: Luke Kanies --- lib/puppet/type/group.rb | 2 +- spec/unit/type/group.rb | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100755 spec/unit/type/group.rb diff --git a/lib/puppet/type/group.rb b/lib/puppet/type/group.rb index 36a4d49fa..2a5ac30da 100755 --- a/lib/puppet/type/group.rb +++ b/lib/puppet/type/group.rb @@ -110,7 +110,7 @@ module Puppet isnamevar end - newparam(:allowdupe) do + newparam(:allowdupe, :boolean => true) do desc "Whether to allow duplicate GIDs. This option does not work on FreeBSD (contract to the ``pw`` man page)." diff --git a/spec/unit/type/group.rb b/spec/unit/type/group.rb new file mode 100755 index 000000000..d7e06dcd8 --- /dev/null +++ b/spec/unit/type/group.rb @@ -0,0 +1,40 @@ +#!/usr/bin/env ruby + +require File.dirname(__FILE__) + '/../../spec_helper' + +describe Puppet::Type.type(:group) do + before do + @class = Puppet::Type.type(:group) + end + + after do + @class.clear + end + + it "should have a default provider" do + @class.defaultprovider.should_not be_nil + end + + it "should have a default provider inheriting from Puppet::Provider" do + @class.defaultprovider.ancestors.should be_include(Puppet::Provider) + end + + describe "when validating attributes" do + [:name, :allowdupe].each do |param| + it "should have a #{param} parameter" do + @class.attrtype(param).should == :param + end + end + + [:ensure, :gid].each do |param| + it "should have a #{param} property" do + @class.attrtype(param).should == :property + end + end + end + + # #1407 - we need to declare the allowdupe param as boolean. + it "should have a boolean method for determining if duplicates are allowed" do + @class.create(:name => "foo").methods.should be_include("allowdupe?") + end +end -- cgit From 605d760dd72b7b6bd3fd54e9f6c3ffacb1b9ee52 Mon Sep 17 00:00:00 2001 From: James Turnbull Date: Thu, 10 Jul 2008 19:52:26 +1000 Subject: Moved debian to conf and updated examples directory --- CHANGELOG | 2 + conf/debian/README.source | 2 + conf/debian/TODO.Debian | 1 + conf/debian/changelog | 257 +++++++++++++++++++++ conf/debian/compat | 1 + conf/debian/control | 45 ++++ conf/debian/copyright | 17 ++ conf/debian/docs | 1 + conf/debian/fileserver.conf | 12 + conf/debian/puppet.NEWS | 63 +++++ conf/debian/puppet.conf | 8 + conf/debian/puppet.dirs | 7 + conf/debian/puppet.files | 6 + conf/debian/puppet.init | 64 +++++ conf/debian/puppet.logrotate | 11 + conf/debian/puppet.postinst | 9 + conf/debian/puppet.postrm | 21 ++ conf/debian/puppet.preinst | 25 ++ conf/debian/puppetmaster.files | 4 + conf/debian/puppetmaster.init | 58 +++++ conf/debian/rules | 115 +++++++++ conf/debian/watch | 2 + debian/README.source | 2 - debian/TODO.Debian | 1 - debian/changelog | 257 --------------------- debian/compat | 1 - debian/control | 45 ---- debian/copyright | 17 -- debian/docs | 1 - debian/fileserver.conf | 12 - debian/puppet.NEWS | 63 ----- debian/puppet.conf | 8 - debian/puppet.dirs | 7 - debian/puppet.files | 6 - debian/puppet.init | 64 ----- debian/puppet.logrotate | 11 - debian/puppet.postinst | 9 - debian/puppet.postrm | 21 -- debian/puppet.preinst | 25 -- debian/puppetmaster.files | 4 - debian/puppetmaster.init | 58 ----- debian/rules | 115 --------- debian/watch | 2 - examples/allatonce | 13 ++ examples/assignments | 11 + examples/code/allatonce | 13 -- examples/code/assignments | 11 - examples/code/components | 73 ------ examples/code/execs | 16 -- examples/code/file.bl | 11 - examples/code/filedefaults | 10 - examples/code/fileparsing | 116 ---------- examples/code/filerecursion | 15 -- examples/code/functions | 3 - examples/code/groups | 7 - examples/code/head | 30 --- examples/code/importing | 8 - examples/code/mac_automount.pp | 16 -- examples/code/mac_dscl.pp | 28 --- examples/code/mac_dscl_revert.pp | 26 --- examples/code/mac_netinfo.pp | 5 - examples/code/mac_pkgdmg.pp | 7 - examples/code/modules/sample-module.pp | 10 - examples/code/modules/sample-module/README.txt | 17 -- .../lib/puppet/parser/functions/hostname_to_dn.rb | 36 --- .../code/modules/sample-module/manifests/init.pp | 12 - .../modules/sample-module/templates/sample.erb | 5 - examples/code/nodes | 20 -- examples/code/one | 8 - examples/code/relationships | 34 --- examples/code/selectors | 28 --- examples/code/simpletests | 11 - examples/code/svncommit | 13 -- examples/components | 73 ++++++ examples/execs | 16 ++ examples/file.bl | 11 + examples/filedefaults | 10 + examples/fileparsing | 116 ++++++++++ examples/filerecursion | 15 ++ examples/functions | 3 + examples/groups | 7 + examples/head | 30 +++ examples/importing | 8 + examples/mac_automount.pp | 16 ++ examples/mac_dscl.pp | 28 +++ examples/mac_dscl_revert.pp | 26 +++ examples/mac_netinfo.pp | 5 + examples/mac_pkgdmg.pp | 7 + examples/modules/sample-module.pp | 10 + examples/modules/sample-module/README.txt | 17 ++ .../lib/puppet/parser/functions/hostname_to_dn.rb | 36 +++ examples/modules/sample-module/manifests/init.pp | 12 + .../modules/sample-module/templates/sample.erb | 5 + examples/nodes | 20 ++ examples/one | 8 + examples/relationships | 34 +++ examples/root/bin/sleeper | 67 ------ examples/root/etc/configfile | 0 examples/root/etc/debian-passwd | 29 --- examples/root/etc/debian-syslog.conf | 71 ------ examples/root/etc/init.d/sleeper | 72 ------ examples/root/etc/otherfile | 0 examples/root/etc/puppet/fileserver.conf | 13 -- examples/root/etc/puppet/namespaceauth.conf | 20 -- examples/root/etc/puppet/puppet.conf | 10 - examples/root/etc/puppet/tagmail.conf | 1 - examples/selectors | 28 +++ examples/simpletests | 11 + examples/svncommit | 13 ++ ext/root/bin/sleeper | 67 ++++++ ext/root/etc/configfile | 0 ext/root/etc/debian-passwd | 29 +++ ext/root/etc/debian-syslog.conf | 71 ++++++ ext/root/etc/init.d/sleeper | 72 ++++++ ext/root/etc/otherfile | 0 ext/root/etc/puppet/fileserver.conf | 13 ++ ext/root/etc/puppet/namespaceauth.conf | 20 ++ ext/root/etc/puppet/puppet.conf | 10 + ext/root/etc/puppet/tagmail.conf | 1 + 119 files changed, 1603 insertions(+), 1601 deletions(-) create mode 100644 conf/debian/README.source create mode 100644 conf/debian/TODO.Debian create mode 100644 conf/debian/changelog create mode 100644 conf/debian/compat create mode 100644 conf/debian/control create mode 100644 conf/debian/copyright create mode 100644 conf/debian/docs create mode 100644 conf/debian/fileserver.conf create mode 100644 conf/debian/puppet.NEWS create mode 100644 conf/debian/puppet.conf create mode 100644 conf/debian/puppet.dirs create mode 100644 conf/debian/puppet.files create mode 100644 conf/debian/puppet.init create mode 100644 conf/debian/puppet.logrotate create mode 100644 conf/debian/puppet.postinst create mode 100644 conf/debian/puppet.postrm create mode 100644 conf/debian/puppet.preinst create mode 100644 conf/debian/puppetmaster.files create mode 100644 conf/debian/puppetmaster.init create mode 100755 conf/debian/rules create mode 100644 conf/debian/watch delete mode 100644 debian/README.source delete mode 100644 debian/TODO.Debian delete mode 100644 debian/changelog delete mode 100644 debian/compat delete mode 100644 debian/control delete mode 100644 debian/copyright delete mode 100644 debian/docs delete mode 100644 debian/fileserver.conf delete mode 100644 debian/puppet.NEWS delete mode 100644 debian/puppet.conf delete mode 100644 debian/puppet.dirs delete mode 100644 debian/puppet.files delete mode 100644 debian/puppet.init delete mode 100644 debian/puppet.logrotate delete mode 100644 debian/puppet.postinst delete mode 100644 debian/puppet.postrm delete mode 100644 debian/puppet.preinst delete mode 100644 debian/puppetmaster.files delete mode 100644 debian/puppetmaster.init delete mode 100755 debian/rules delete mode 100644 debian/watch create mode 100644 examples/allatonce create mode 100644 examples/assignments delete mode 100644 examples/code/allatonce delete mode 100644 examples/code/assignments delete mode 100644 examples/code/components delete mode 100644 examples/code/execs delete mode 100644 examples/code/file.bl delete mode 100644 examples/code/filedefaults delete mode 100644 examples/code/fileparsing delete mode 100644 examples/code/filerecursion delete mode 100644 examples/code/functions delete mode 100644 examples/code/groups delete mode 100644 examples/code/head delete mode 100644 examples/code/importing delete mode 100644 examples/code/mac_automount.pp delete mode 100755 examples/code/mac_dscl.pp delete mode 100755 examples/code/mac_dscl_revert.pp delete mode 100755 examples/code/mac_netinfo.pp delete mode 100755 examples/code/mac_pkgdmg.pp delete mode 100644 examples/code/modules/sample-module.pp delete mode 100644 examples/code/modules/sample-module/README.txt delete mode 100644 examples/code/modules/sample-module/lib/puppet/parser/functions/hostname_to_dn.rb delete mode 100644 examples/code/modules/sample-module/manifests/init.pp delete mode 100644 examples/code/modules/sample-module/templates/sample.erb delete mode 100644 examples/code/nodes delete mode 100644 examples/code/one delete mode 100644 examples/code/relationships delete mode 100644 examples/code/selectors delete mode 100644 examples/code/simpletests delete mode 100644 examples/code/svncommit create mode 100644 examples/components create mode 100644 examples/execs create mode 100644 examples/file.bl create mode 100644 examples/filedefaults create mode 100644 examples/fileparsing create mode 100644 examples/filerecursion create mode 100644 examples/functions create mode 100644 examples/groups create mode 100644 examples/head create mode 100644 examples/importing create mode 100644 examples/mac_automount.pp create mode 100755 examples/mac_dscl.pp create mode 100755 examples/mac_dscl_revert.pp create mode 100755 examples/mac_netinfo.pp create mode 100755 examples/mac_pkgdmg.pp create mode 100644 examples/modules/sample-module.pp create mode 100644 examples/modules/sample-module/README.txt create mode 100644 examples/modules/sample-module/lib/puppet/parser/functions/hostname_to_dn.rb create mode 100644 examples/modules/sample-module/manifests/init.pp create mode 100644 examples/modules/sample-module/templates/sample.erb create mode 100644 examples/nodes create mode 100644 examples/one create mode 100644 examples/relationships delete mode 100755 examples/root/bin/sleeper delete mode 100644 examples/root/etc/configfile delete mode 100644 examples/root/etc/debian-passwd delete mode 100644 examples/root/etc/debian-syslog.conf delete mode 100755 examples/root/etc/init.d/sleeper delete mode 100644 examples/root/etc/otherfile delete mode 100644 examples/root/etc/puppet/fileserver.conf delete mode 100644 examples/root/etc/puppet/namespaceauth.conf delete mode 100644 examples/root/etc/puppet/puppet.conf delete mode 100644 examples/root/etc/puppet/tagmail.conf create mode 100644 examples/selectors create mode 100644 examples/simpletests create mode 100644 examples/svncommit create mode 100755 ext/root/bin/sleeper create mode 100644 ext/root/etc/configfile create mode 100644 ext/root/etc/debian-passwd create mode 100644 ext/root/etc/debian-syslog.conf create mode 100755 ext/root/etc/init.d/sleeper create mode 100644 ext/root/etc/otherfile create mode 100644 ext/root/etc/puppet/fileserver.conf create mode 100644 ext/root/etc/puppet/namespaceauth.conf create mode 100644 ext/root/etc/puppet/puppet.conf create mode 100644 ext/root/etc/puppet/tagmail.conf diff --git a/CHANGELOG b/CHANGELOG index 5214d6462..e85f9f249 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,6 @@ 0.24.5 + Moved debian to conf and updated examples directory + Fixed #1368 - updated Red Hat init scripts Added message referencing ReductiveLabs build library diff --git a/conf/debian/README.source b/conf/debian/README.source new file mode 100644 index 000000000..fd9155241 --- /dev/null +++ b/conf/debian/README.source @@ -0,0 +1,2 @@ +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 new file mode 100644 index 000000000..ac70b97be --- /dev/null +++ b/conf/debian/TODO.Debian @@ -0,0 +1 @@ +* 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 new file mode 100644 index 000000000..69984d622 --- /dev/null +++ b/conf/debian/changelog @@ -0,0 +1,257 @@ +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 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 Sun, 30 Dec 2007 19:13:47 +0100 + +puppet (0.24.0-1) unstable; urgency=low + + * New upstream release + + -- Thom May 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 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 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 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 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 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 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 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 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 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 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 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 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 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 Tue, 21 Aug 2007 12:54:40 +1000 + +puppet (0.23.2-1) unstable; urgency=low + + * New upstream release. + + -- Matthew Palmer 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 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 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 Thu, 3 May 2007 15:04:15 +1000 + +puppet (0.22.4-1) unstable; urgency=low + + * New upstream release. + + -- Matthew Palmer 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 Wed, 18 Apr 2007 14:03:33 +1000 + +puppet (0.22.1-1) unstable; urgency=low + + * New upstream release. + + -- Matthew Palmer 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 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 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 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 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 Tue, 27 Jun 2006 15:05:32 +1000 + +puppet (0.18.0-1) unstable; urgency=low + + * Initial release. (Closes: #348625) + + -- Matthew Palmer Wed, 24 May 2006 13:10:01 +1000 diff --git a/conf/debian/compat b/conf/debian/compat new file mode 100644 index 000000000..b8626c4cf --- /dev/null +++ b/conf/debian/compat @@ -0,0 +1 @@ +4 diff --git a/conf/debian/control b/conf/debian/control new file mode 100644 index 000000000..8b0e92e7e --- /dev/null +++ b/conf/debian/control @@ -0,0 +1,45 @@ +Source: puppet +Section: admin +Priority: optional +Maintainer: Puppet Package Maintainers +Uploaders: Thom May +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 new file mode 100644 index 000000000..06bdcab30 --- /dev/null +++ b/conf/debian/copyright @@ -0,0 +1,17 @@ +This package was debianized by Jamie Wilkinson on +Thu, 27 Apr 2006 10:18:04 +1000. + +It was downloaded from http://reductivelabs.com/downloads/puppet + +Copyright Holder: Luke Kanies + +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 new file mode 100644 index 000000000..e845566c0 --- /dev/null +++ b/conf/debian/docs @@ -0,0 +1 @@ +README diff --git a/conf/debian/fileserver.conf b/conf/debian/fileserver.conf new file mode 100644 index 000000000..04a51c080 --- /dev/null +++ b/conf/debian/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 /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 new file mode 100644 index 000000000..a712aafd4 --- /dev/null +++ b/conf/debian/puppet.NEWS @@ -0,0 +1,63 @@ +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 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 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 Mon, 25 Jun 2007 10:43:53 +1000 diff --git a/conf/debian/puppet.conf b/conf/debian/puppet.conf new file mode 100644 index 000000000..c541c748a --- /dev/null +++ b/conf/debian/puppet.conf @@ -0,0 +1,8 @@ +[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 new file mode 100644 index 000000000..9ce18f88e --- /dev/null +++ b/conf/debian/puppet.dirs @@ -0,0 +1,7 @@ +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 new file mode 100644 index 000000000..d92ac32e9 --- /dev/null +++ b/conf/debian/puppet.files @@ -0,0 +1,6 @@ +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 new file mode 100644 index 000000000..063f9273f --- /dev/null +++ b/conf/debian/puppet.init @@ -0,0 +1,64 @@ +#! /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 new file mode 100644 index 000000000..3864e396d --- /dev/null +++ b/conf/debian/puppet.logrotate @@ -0,0 +1,11 @@ +/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 new file mode 100644 index 000000000..ac765ba85 --- /dev/null +++ b/conf/debian/puppet.postinst @@ -0,0 +1,9 @@ +#!/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 new file mode 100644 index 000000000..da994c3c3 --- /dev/null +++ b/conf/debian/puppet.postrm @@ -0,0 +1,21 @@ +#! /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 new file mode 100644 index 000000000..ce8e76083 --- /dev/null +++ b/conf/debian/puppet.preinst @@ -0,0 +1,25 @@ +#! /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 new file mode 100644 index 000000000..15bc694b1 --- /dev/null +++ b/conf/debian/puppetmaster.files @@ -0,0 +1,4 @@ +usr/sbin/puppetmasterd +usr/sbin/puppetca +usr/sbin/puppetrun +etc/puppet/ diff --git a/conf/debian/puppetmaster.init b/conf/debian/puppetmaster.init new file mode 100644 index 000000000..ea5c1bafb --- /dev/null +++ b/conf/debian/puppetmaster.init @@ -0,0 +1,58 @@ +#! /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 new file mode 100755 index 000000000..ecabcbad0 --- /dev/null +++ b/conf/debian/rules @@ -0,0 +1,115 @@ +#!/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 new file mode 100644 index 000000000..29d439f6d --- /dev/null +++ b/conf/debian/watch @@ -0,0 +1,2 @@ +version=3 +http://reductivelabs.com/downloads/puppet/puppet-([0-9]+\..*)\.tgz diff --git a/debian/README.source b/debian/README.source deleted file mode 100644 index fd9155241..000000000 --- a/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/debian/TODO.Debian b/debian/TODO.Debian deleted file mode 100644 index ac70b97be..000000000 --- a/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/debian/changelog b/debian/changelog deleted file mode 100644 index 69984d622..000000000 --- a/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 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 Sun, 30 Dec 2007 19:13:47 +0100 - -puppet (0.24.0-1) unstable; urgency=low - - * New upstream release - - -- Thom May 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 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 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 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 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 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 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 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 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 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 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 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 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 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 Tue, 21 Aug 2007 12:54:40 +1000 - -puppet (0.23.2-1) unstable; urgency=low - - * New upstream release. - - -- Matthew Palmer 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 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 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 Thu, 3 May 2007 15:04:15 +1000 - -puppet (0.22.4-1) unstable; urgency=low - - * New upstream release. - - -- Matthew Palmer 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 Wed, 18 Apr 2007 14:03:33 +1000 - -puppet (0.22.1-1) unstable; urgency=low - - * New upstream release. - - -- Matthew Palmer 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 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 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 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 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 Tue, 27 Jun 2006 15:05:32 +1000 - -puppet (0.18.0-1) unstable; urgency=low - - * Initial release. (Closes: #348625) - - -- Matthew Palmer Wed, 24 May 2006 13:10:01 +1000 diff --git a/debian/compat b/debian/compat deleted file mode 100644 index b8626c4cf..000000000 --- a/debian/compat +++ /dev/null @@ -1 +0,0 @@ -4 diff --git a/debian/control b/debian/control deleted file mode 100644 index 8b0e92e7e..000000000 --- a/debian/control +++ /dev/null @@ -1,45 +0,0 @@ -Source: puppet -Section: admin -Priority: optional -Maintainer: Puppet Package Maintainers -Uploaders: Thom May -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/debian/copyright b/debian/copyright deleted file mode 100644 index 06bdcab30..000000000 --- a/debian/copyright +++ /dev/null @@ -1,17 +0,0 @@ -This package was debianized by Jamie Wilkinson on -Thu, 27 Apr 2006 10:18:04 +1000. - -It was downloaded from http://reductivelabs.com/downloads/puppet - -Copyright Holder: Luke Kanies - -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/debian/docs b/debian/docs deleted file mode 100644 index e845566c0..000000000 --- a/debian/docs +++ /dev/null @@ -1 +0,0 @@ -README diff --git a/debian/fileserver.conf b/debian/fileserver.conf deleted file mode 100644 index 04a51c080..000000000 --- a/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/debian/puppet.NEWS b/debian/puppet.NEWS deleted file mode 100644 index a712aafd4..000000000 --- a/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 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 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 Mon, 25 Jun 2007 10:43:53 +1000 diff --git a/debian/puppet.conf b/debian/puppet.conf deleted file mode 100644 index c541c748a..000000000 --- a/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/debian/puppet.dirs b/debian/puppet.dirs deleted file mode 100644 index 9ce18f88e..000000000 --- a/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/debian/puppet.files b/debian/puppet.files deleted file mode 100644 index d92ac32e9..000000000 --- a/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/debian/puppet.init b/debian/puppet.init deleted file mode 100644 index 063f9273f..000000000 --- a/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/debian/puppet.logrotate b/debian/puppet.logrotate deleted file mode 100644 index 3864e396d..000000000 --- a/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/debian/puppet.postinst b/debian/puppet.postinst deleted file mode 100644 index ac765ba85..000000000 --- a/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/debian/puppet.postrm b/debian/puppet.postrm deleted file mode 100644 index da994c3c3..000000000 --- a/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/debian/puppet.preinst b/debian/puppet.preinst deleted file mode 100644 index ce8e76083..000000000 --- a/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/debian/puppetmaster.files b/debian/puppetmaster.files deleted file mode 100644 index 15bc694b1..000000000 --- a/debian/puppetmaster.files +++ /dev/null @@ -1,4 +0,0 @@ -usr/sbin/puppetmasterd -usr/sbin/puppetca -usr/sbin/puppetrun -etc/puppet/ diff --git a/debian/puppetmaster.init b/debian/puppetmaster.init deleted file mode 100644 index ea5c1bafb..000000000 --- a/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/debian/rules b/debian/rules deleted file mode 100755 index ecabcbad0..000000000 --- a/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/debian/watch b/debian/watch deleted file mode 100644 index 29d439f6d..000000000 --- a/debian/watch +++ /dev/null @@ -1,2 +0,0 @@ -version=3 -http://reductivelabs.com/downloads/puppet/puppet-([0-9]+\..*)\.tgz diff --git a/examples/allatonce b/examples/allatonce new file mode 100644 index 000000000..8912ec4e7 --- /dev/null +++ b/examples/allatonce @@ -0,0 +1,13 @@ +# $Id$ + +define thingie { + file { "/tmp/classtest": ensure => file, mode => 755 } + #testing {} +} + +class testing { + thingie { "componentname": } +} + +#component {} +testing { "testingname": } diff --git a/examples/assignments b/examples/assignments new file mode 100644 index 000000000..3edcef84e --- /dev/null +++ b/examples/assignments @@ -0,0 +1,11 @@ +# $Id$ + +$goodness = sunos + +$subvariable = $goodness + +$yayness = "this is a string of text" + +#$sleeper = service { sleeper: +# running => "1" +#} diff --git a/examples/code/allatonce b/examples/code/allatonce deleted file mode 100644 index 8912ec4e7..000000000 --- a/examples/code/allatonce +++ /dev/null @@ -1,13 +0,0 @@ -# $Id$ - -define thingie { - file { "/tmp/classtest": ensure => file, mode => 755 } - #testing {} -} - -class testing { - thingie { "componentname": } -} - -#component {} -testing { "testingname": } diff --git a/examples/code/assignments b/examples/code/assignments deleted file mode 100644 index 3edcef84e..000000000 --- a/examples/code/assignments +++ /dev/null @@ -1,11 +0,0 @@ -# $Id$ - -$goodness = sunos - -$subvariable = $goodness - -$yayness = "this is a string of text" - -#$sleeper = service { sleeper: -# running => "1" -#} diff --git a/examples/code/components b/examples/code/components deleted file mode 100644 index 3da43c571..000000000 --- a/examples/code/components +++ /dev/null @@ -1,73 +0,0 @@ -# $Id$ - -# i still have no 'require'-like functionality, and i should also -# have 'recommend'-like functionality... -define apache(php,docroot,user,group) { - package { apache: - version => "2.0.53" - } - service { apache: - running => true - } - - - # this definitely won't parse - #if $php == "true" { - # # this needs to do two things: - # # - mark a dependency - # # - cause this apache component to receive refresh events generated by php - # #require("php") - # $var = value - #} - - #file { "../examples/root/etc/configfile": - # owner => $user - #} -} - -define sudo() { - package { sudo: - version => "1.6.8p7" - } - file { "/etc/sudoers": - owner => root, - group => root, - mode => "440" - } -} - -define ssh { - package { ssh: - version => "3.4.4.4" - } - service { "sshd": - running => true - } -} - -define sleeper(path,mode) { - Service { - path => "../examples/root/etc/init.d" - } - - service { sleeper: - running => true, - path => "../examples/root/etc/init.d" - } - file { $path: - mode => $mode - } - $files = ["/tmp/testness","/tmp/funtest"] - file { $files: - ensure => file - } -} - -#apache { "test": -# php => false, -# docroot => "/export/html", -# user => "www-data", -# group => "www-data" -#} - -#ssh { "yucko":} diff --git a/examples/code/execs b/examples/code/execs deleted file mode 100644 index 44f133098..000000000 --- a/examples/code/execs +++ /dev/null @@ -1,16 +0,0 @@ -$path = "/usr/bin:/bin" - -exec { "mkdir -p /tmp/fakedir": - path => $path -} - -exec { "rm -rf /tmp/fakedir": - path => $path -} - -exec { "touch /this/directory/does/not/exist": - path => $path, - returns => 1 -} - - diff --git a/examples/code/file.bl b/examples/code/file.bl deleted file mode 100644 index ef46ba223..000000000 --- a/examples/code/file.bl +++ /dev/null @@ -1,11 +0,0 @@ -# $Id$ - -file { - "/tmp/atest": ensure => file, mode => 755; - "/tmp/btest": ensure => file, mode => 755 -} - -file { - "/tmp/ctest": ensure => file; - "/tmp/dtest": ensure => file; -} diff --git a/examples/code/filedefaults b/examples/code/filedefaults deleted file mode 100644 index 56cf76a9a..000000000 --- a/examples/code/filedefaults +++ /dev/null @@ -1,10 +0,0 @@ -# $Id$ - -File { - mode => 755, - recurse => true -} - -file { "/tmp/filedefaultstest": - ensure => file -} diff --git a/examples/code/fileparsing b/examples/code/fileparsing deleted file mode 100644 index f9766b9f6..000000000 --- a/examples/code/fileparsing +++ /dev/null @@ -1,116 +0,0 @@ -# $Id$ - -# this will eventually parse different config files - -# this creates the 'passwd' type, but it does not create any instances -filetype { "passwd": - linesplit => "\n", - escapednewlines => false -} - - -# this creates the 'PasswdUser' type, but again, no instances -filerecord { "user": - filetype => passwd, - fields => [name, password, uid, gid, gcos, home, shell], - namevar => name, - splitchar => ":" - -} - -filetype { ini: - linesplit => "\n\n" -} - -# ini files are different because we don't really care about validating fields -# or at least, we can't do it for most files... -filerecord { "initrecord": - filetype => ini, - fields => [name, password, uid, gid, gcos, home, shell], - namevar => name, - splitchar => ":" - -} - -# this won't work for multiple record types, will it? -# or at least, it requires that we specify multiple times -# ah, and it doesn't specify which of the available record types -# it works for... -passwd { user: - complete => true, # manage the whole file - path => "/etc/passwd" -} - -user { yaytest: - password => x, - uid => 10000, - gid => 10000, - home => "/home/yaytest", - gcos => "The Yaytest", - shell => "/bin/sh" -} - # there seems to be an intrinsic problem here -- i've got subtypes that only - # make sense when an instance of the super type already exists, and i need - # to associate the instances of the subtype with the instances of the supertype - # even if i created the parsers manually, I'd have the same problem - -# this is the crux of it -- i want to be able to say 'user' here without having -# to specify the file, which leaves two options: -# 1) associate the record type with a filetype instance (BAD) -# 2) once the filetype and record type are created, have another command -# that specifically creates a filetype instance and gives names for instances -# of its record types - -define syslog { - - # create a new type, with all defaults - filetype { "syslog": - escapednewlines => true - } - - filerecord { "log": - filetype => syslog, - regex => "^([^#\s]+)\s+(\S+)$", - joinchar => "\t", - fields => [logs, dest] - } - - # these two should just be supported within the filetypes - filerecord { "comment": - filetype => syslog, - regex => "^(#.*)$", - joinchar => "s", - fields => [comment] - } - - filerecord { "blank": - filetype => syslog, - regex => "^(\s*)$", - joinchar => "s", - fields => blank - } -} - -define cron { - filetype { "usercrontab": - } - - # this won't actually work, of course - filerecord { "cronjob": - filetype => crontab, - regex => "^([^#\s]+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(.+)$", - joinchar => " ", - fields => [minute, hour, day, month, weekday, command], - defaults => ["*", "*", "*", "*", "*", nil], - optional => [minute, hour, day, month, weekday] - } - - crontab { "luke": - } -} - -# XXX this doesn't work in the slightest -define crontab(name,path) { - usercrontab { "${path}/${name}": - } -} diff --git a/examples/code/filerecursion b/examples/code/filerecursion deleted file mode 100644 index b7d8278c2..000000000 --- a/examples/code/filerecursion +++ /dev/null @@ -1,15 +0,0 @@ -# $Id$ - -file { "/tmp/dirtest/b/a": - mode => 755, -} - -file { "/tmp/dirtest": - mode => 755, - recurse => true, -} - -file { "/tmp/dirtest/b/b": - mode => 644, -} - diff --git a/examples/code/functions b/examples/code/functions deleted file mode 100644 index 8e95c3a72..000000000 --- a/examples/code/functions +++ /dev/null @@ -1,3 +0,0 @@ -# $Id$ - -$yaytest = fact("operatingsystem") diff --git a/examples/code/groups b/examples/code/groups deleted file mode 100644 index 35505a2eb..000000000 --- a/examples/code/groups +++ /dev/null @@ -1,7 +0,0 @@ -# $Id$ - -# there need to be two forms of adding to groups: -# add the current host to a group, and add a list of hosts to a -# group by name - -$group = "crap" diff --git a/examples/code/head b/examples/code/head deleted file mode 100644 index 59cbb6593..000000000 --- a/examples/code/head +++ /dev/null @@ -1,30 +0,0 @@ -# $Id$ - -# this file is responsible for importing all of the files we want to actually test - -# these are all of the simple tests -import "simpletests" -import "assignments" -import "selectors" -#import "iftest" -import "importing" -import "execs" -import "filedefaults" - -# facts are now imported into the top of the namespace -#import "facts" - -# obsoleted -#import "functions" - -# files we no longer need to import directly, or at all in some cases -#import "one" -#import "classing" -#import "components" -#import "file.bl" -#import "fileparsing.disabled" -#import "groups" - -# this imports the more complex files -import "allatonce" # imports classing and components -import "nodes" # imports classing and components diff --git a/examples/code/importing b/examples/code/importing deleted file mode 100644 index f02604109..000000000 --- a/examples/code/importing +++ /dev/null @@ -1,8 +0,0 @@ -# $Id$ - -#import "groups" -# testing import loops -import "importing" - -$name = "value" -$system = $operatingsystem diff --git a/examples/code/mac_automount.pp b/examples/code/mac_automount.pp deleted file mode 100644 index bab0136fc..000000000 --- a/examples/code/mac_automount.pp +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env puppet -# Jeff McCune -# -# Apple's Automounter spawns a child that sends the parent -# a SIGTERM. This makes it *very* difficult to figure out -# if the process started correctly or not. -# - -service {"automount-test": - provider => base, - hasrestart => false, - pattern => '/tmp/hometest', - start => "/usr/sbin/automount -m /tmp/home /dev/null -mnt /tmp/hometest", - stop => "ps auxww | grep '/tmp/hometest' | grep -v grep | awk '{print \$2}' | xargs kill", - ensure => running -} diff --git a/examples/code/mac_dscl.pp b/examples/code/mac_dscl.pp deleted file mode 100755 index ff59f9d8d..000000000 --- a/examples/code/mac_dscl.pp +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env puppet --debug --verbose --trace -# -# Jeff McCune: I use this for developing and testing the directory service -# provider. - -User { provider => "directoryservice" } -Group { provider => "directoryservice" } - -user { - "testgone": - ensure => absent, - uid => 550; - "testhere": - ensure => present, - password => "foobar", - shell => "/bin/bash", - uid => 551; -} - -group { - "testgone": - ensure => absent, - gid => 550; - "testhere": - ensure => present, - gid => 551; - -} \ No newline at end of file diff --git a/examples/code/mac_dscl_revert.pp b/examples/code/mac_dscl_revert.pp deleted file mode 100755 index c9bd2b541..000000000 --- a/examples/code/mac_dscl_revert.pp +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env puppet --debug --verbose --trace -# -# Jeff McCune: I use this for developing and testing the directory service -# provider. - -User { provider => "directoryservice" } -Group { provider => "directoryservice" } - -user { - "testgone": - ensure => absent, - uid => 550; - "testhere": - ensure => absent, - uid => 551; -} - -group { - "testgone": - ensure => absent, - gid => 550; - "testhere": - ensure => absent, - gid => 551; - -} diff --git a/examples/code/mac_netinfo.pp b/examples/code/mac_netinfo.pp deleted file mode 100755 index 544b64818..000000000 --- a/examples/code/mac_netinfo.pp +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env puppet --debug - -user { - "jmccune": provider => "netinfo", ensure => present; -} diff --git a/examples/code/mac_pkgdmg.pp b/examples/code/mac_pkgdmg.pp deleted file mode 100755 index a2499e815..000000000 --- a/examples/code/mac_pkgdmg.pp +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env puppet -# - -package -{ - "Foobar.pkg.dmg": ensure => present, provider => pkgdmg; -} diff --git a/examples/code/modules/sample-module.pp b/examples/code/modules/sample-module.pp deleted file mode 100644 index 57079a0aa..000000000 --- a/examples/code/modules/sample-module.pp +++ /dev/null @@ -1,10 +0,0 @@ -# Jeff McCune -# 2007-08-14 -# -# Use: -# puppet --verbose --debug --modulepath=`pwd` ./sample-module.pp -# -# sample-module demonstrates the use of a custom language function -# included within the module bundle. - -include sample-module diff --git a/examples/code/modules/sample-module/README.txt b/examples/code/modules/sample-module/README.txt deleted file mode 100644 index ee4b8201a..000000000 --- a/examples/code/modules/sample-module/README.txt +++ /dev/null @@ -1,17 +0,0 @@ -Jeff McCune -2007-08-14 - -This small, sample module demonstrates how to extend the puppet language -with a new parser function. - -See: -manifests/init.pp -lib/puppet/parser/functions/hostname_to_dn.rb -templates/sample.erb - -Note the consistent naming of files for Puppet::Util::Autoload - -Reference Documents: -http://reductivelabs.com/trac/puppet/wiki/ModuleOrganisation -http://reductivelabs.com/trac/puppet/wiki/WritingYourOwnFunctions -http://reductivelabs.com/trac/puppet/wiki/FunctionReference diff --git a/examples/code/modules/sample-module/lib/puppet/parser/functions/hostname_to_dn.rb b/examples/code/modules/sample-module/lib/puppet/parser/functions/hostname_to_dn.rb deleted file mode 100644 index 9f732b5bc..000000000 --- a/examples/code/modules/sample-module/lib/puppet/parser/functions/hostname_to_dn.rb +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright (C) David Schmitt -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. Neither the name of the Author nor the names of its contributors -# may be used to endorse or promote products derived from this software -# without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -# SUCH DAMAGE. - -# Jeff McCune -# 2007-08-14 -# See: http://reductivelabs.com/trac/puppet/wiki/WritingYourOwnFunctions - -module Puppet::Parser::Functions - newfunction(:hostname_to_dn, :type => :rvalue, :doc => "Given 'foo.bar.com', return 'dc=foo,dc=bar,dc=com'.") do |args| - args[0].split(/\./).map do |s| "dc=%s"%[s] end.join(",") - end -end diff --git a/examples/code/modules/sample-module/manifests/init.pp b/examples/code/modules/sample-module/manifests/init.pp deleted file mode 100644 index 1af8dff1f..000000000 --- a/examples/code/modules/sample-module/manifests/init.pp +++ /dev/null @@ -1,12 +0,0 @@ -# Jeff McCune -# -# Demonstration of a custom parser function and erb template within -# a module, working in concert. - -class sample-module { - $fqdn_to_dn = hostname_to_dn($domain) - $sample_template = template("sample-module/sample.erb") - - notice("hostname_to_dn module function returned: [$fqdn_to_dn]") - info("sample.erb looks like:\n$sample_template") -} diff --git a/examples/code/modules/sample-module/templates/sample.erb b/examples/code/modules/sample-module/templates/sample.erb deleted file mode 100644 index b13561b45..000000000 --- a/examples/code/modules/sample-module/templates/sample.erb +++ /dev/null @@ -1,5 +0,0 @@ - -## Jeff McCune -fqdn: <%= fqdn %> -basedn: <%= fqdn_to_dn %> -## end sample.erb ## diff --git a/examples/code/nodes b/examples/code/nodes deleted file mode 100644 index 42488e689..000000000 --- a/examples/code/nodes +++ /dev/null @@ -1,20 +0,0 @@ -# $Id$ - -# define nodes - -#service.setpath("../examples/root/etc/init.d") - -Service { - path => "../examples/root/etc/init.d" -} - -import "classing" - -sleepserver { - path => $operatingsystem ? { - sunos => "../examples/root/etc/configfile", - hpux => "../examples/other/etc/configfile", - default => "../examples/root/etc/configfile" - }, - schedule => true -} diff --git a/examples/code/one b/examples/code/one deleted file mode 100644 index 452d32f3e..000000000 --- a/examples/code/one +++ /dev/null @@ -1,8 +0,0 @@ -# $Id$ - -# this service doesn't actually exist, so we noop it -# and this way, we can test noop :) -service { "funtest": - running => "0", - noop => true -} diff --git a/examples/code/relationships b/examples/code/relationships deleted file mode 100644 index 795788947..000000000 --- a/examples/code/relationships +++ /dev/null @@ -1,34 +0,0 @@ -# $Id$ - -#service.setpath("../examples/root/etc/init.d") -#puppet.statefile("/tmp/puppetstate") -$path = "../examples/root/etc/configfile" - path => "../examples/root/etc/init.d" - - -define files { - file { "/tmp/yaytest": - ensure => file, - mode => 755 - } - file { "/tmp/exists": - checksum => md5 - } -} - -define sleeper { - file { $path: - mode => 755 - } - service { sleeper: - path => "../examples/root/etc/init.d", - running => 1 - } -} - -files { } - -sleeper { - require => files["yay"], - schedule => true -} diff --git a/examples/code/selectors b/examples/code/selectors deleted file mode 100644 index a70399bc7..000000000 --- a/examples/code/selectors +++ /dev/null @@ -1,28 +0,0 @@ -# $Id$ -# - -$platform = SunOS - -$funtest = $platform ? { - SunOS => yayness, - AIX => goodness, - default => badness -} - -# this is a comment - -$filename = "/tmp/yayness" - -$sleeper = file { $filename: - mode => $platform ? { - SunOS => 644, - default => 755 - }, - create => $platform ? "SunOS" => true -} - -# i guess it has to be solved this way... - -#$platform ? sunos => file { $filename: -# mode => 644 -#} diff --git a/examples/code/simpletests b/examples/code/simpletests deleted file mode 100644 index b4fd3234e..000000000 --- a/examples/code/simpletests +++ /dev/null @@ -1,11 +0,0 @@ -# $Id$ - -file { - "/tmp/atest": ensure => file; - "/tmp/btest": ensure => file -} - -file { - "/tmp/ctest": ensure => file; - "/tmp/dtest": ensure => file; -} diff --git a/examples/code/svncommit b/examples/code/svncommit deleted file mode 100644 index 350cd8580..000000000 --- a/examples/code/svncommit +++ /dev/null @@ -1,13 +0,0 @@ -$path = "/usr/bin:/bin" - -file { "/tmp/svntests": - recurse => true, - checksum => md5 -} - -exec { "echo 'files have been updated'": - cwd => "/tmp/svntests", - refreshonly => true, - require => file["/tmp/svntests"], - path => $path -} diff --git a/examples/components b/examples/components new file mode 100644 index 000000000..3da43c571 --- /dev/null +++ b/examples/components @@ -0,0 +1,73 @@ +# $Id$ + +# i still have no 'require'-like functionality, and i should also +# have 'recommend'-like functionality... +define apache(php,docroot,user,group) { + package { apache: + version => "2.0.53" + } + service { apache: + running => true + } + + + # this definitely won't parse + #if $php == "true" { + # # this needs to do two things: + # # - mark a dependency + # # - cause this apache component to receive refresh events generated by php + # #require("php") + # $var = value + #} + + #file { "../examples/root/etc/configfile": + # owner => $user + #} +} + +define sudo() { + package { sudo: + version => "1.6.8p7" + } + file { "/etc/sudoers": + owner => root, + group => root, + mode => "440" + } +} + +define ssh { + package { ssh: + version => "3.4.4.4" + } + service { "sshd": + running => true + } +} + +define sleeper(path,mode) { + Service { + path => "../examples/root/etc/init.d" + } + + service { sleeper: + running => true, + path => "../examples/root/etc/init.d" + } + file { $path: + mode => $mode + } + $files = ["/tmp/testness","/tmp/funtest"] + file { $files: + ensure => file + } +} + +#apache { "test": +# php => false, +# docroot => "/export/html", +# user => "www-data", +# group => "www-data" +#} + +#ssh { "yucko":} diff --git a/examples/execs b/examples/execs new file mode 100644 index 000000000..44f133098 --- /dev/null +++ b/examples/execs @@ -0,0 +1,16 @@ +$path = "/usr/bin:/bin" + +exec { "mkdir -p /tmp/fakedir": + path => $path +} + +exec { "rm -rf /tmp/fakedir": + path => $path +} + +exec { "touch /this/directory/does/not/exist": + path => $path, + returns => 1 +} + + diff --git a/examples/file.bl b/examples/file.bl new file mode 100644 index 000000000..ef46ba223 --- /dev/null +++ b/examples/file.bl @@ -0,0 +1,11 @@ +# $Id$ + +file { + "/tmp/atest": ensure => file, mode => 755; + "/tmp/btest": ensure => file, mode => 755 +} + +file { + "/tmp/ctest": ensure => file; + "/tmp/dtest": ensure => file; +} diff --git a/examples/filedefaults b/examples/filedefaults new file mode 100644 index 000000000..56cf76a9a --- /dev/null +++ b/examples/filedefaults @@ -0,0 +1,10 @@ +# $Id$ + +File { + mode => 755, + recurse => true +} + +file { "/tmp/filedefaultstest": + ensure => file +} diff --git a/examples/fileparsing b/examples/fileparsing new file mode 100644 index 000000000..f9766b9f6 --- /dev/null +++ b/examples/fileparsing @@ -0,0 +1,116 @@ +# $Id$ + +# this will eventually parse different config files + +# this creates the 'passwd' type, but it does not create any instances +filetype { "passwd": + linesplit => "\n", + escapednewlines => false +} + + +# this creates the 'PasswdUser' type, but again, no instances +filerecord { "user": + filetype => passwd, + fields => [name, password, uid, gid, gcos, home, shell], + namevar => name, + splitchar => ":" + +} + +filetype { ini: + linesplit => "\n\n" +} + +# ini files are different because we don't really care about validating fields +# or at least, we can't do it for most files... +filerecord { "initrecord": + filetype => ini, + fields => [name, password, uid, gid, gcos, home, shell], + namevar => name, + splitchar => ":" + +} + +# this won't work for multiple record types, will it? +# or at least, it requires that we specify multiple times +# ah, and it doesn't specify which of the available record types +# it works for... +passwd { user: + complete => true, # manage the whole file + path => "/etc/passwd" +} + +user { yaytest: + password => x, + uid => 10000, + gid => 10000, + home => "/home/yaytest", + gcos => "The Yaytest", + shell => "/bin/sh" +} + # there seems to be an intrinsic problem here -- i've got subtypes that only + # make sense when an instance of the super type already exists, and i need + # to associate the instances of the subtype with the instances of the supertype + # even if i created the parsers manually, I'd have the same problem + +# this is the crux of it -- i want to be able to say 'user' here without having +# to specify the file, which leaves two options: +# 1) associate the record type with a filetype instance (BAD) +# 2) once the filetype and record type are created, have another command +# that specifically creates a filetype instance and gives names for instances +# of its record types + +define syslog { + + # create a new type, with all defaults + filetype { "syslog": + escapednewlines => true + } + + filerecord { "log": + filetype => syslog, + regex => "^([^#\s]+)\s+(\S+)$", + joinchar => "\t", + fields => [logs, dest] + } + + # these two should just be supported within the filetypes + filerecord { "comment": + filetype => syslog, + regex => "^(#.*)$", + joinchar => "s", + fields => [comment] + } + + filerecord { "blank": + filetype => syslog, + regex => "^(\s*)$", + joinchar => "s", + fields => blank + } +} + +define cron { + filetype { "usercrontab": + } + + # this won't actually work, of course + filerecord { "cronjob": + filetype => crontab, + regex => "^([^#\s]+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(.+)$", + joinchar => " ", + fields => [minute, hour, day, month, weekday, command], + defaults => ["*", "*", "*", "*", "*", nil], + optional => [minute, hour, day, month, weekday] + } + + crontab { "luke": + } +} + +# XXX this doesn't work in the slightest +define crontab(name,path) { + usercrontab { "${path}/${name}": + } +} diff --git a/examples/filerecursion b/examples/filerecursion new file mode 100644 index 000000000..b7d8278c2 --- /dev/null +++ b/examples/filerecursion @@ -0,0 +1,15 @@ +# $Id$ + +file { "/tmp/dirtest/b/a": + mode => 755, +} + +file { "/tmp/dirtest": + mode => 755, + recurse => true, +} + +file { "/tmp/dirtest/b/b": + mode => 644, +} + diff --git a/examples/functions b/examples/functions new file mode 100644 index 000000000..8e95c3a72 --- /dev/null +++ b/examples/functions @@ -0,0 +1,3 @@ +# $Id$ + +$yaytest = fact("operatingsystem") diff --git a/examples/groups b/examples/groups new file mode 100644 index 000000000..35505a2eb --- /dev/null +++ b/examples/groups @@ -0,0 +1,7 @@ +# $Id$ + +# there need to be two forms of adding to groups: +# add the current host to a group, and add a list of hosts to a +# group by name + +$group = "crap" diff --git a/examples/head b/examples/head new file mode 100644 index 000000000..59cbb6593 --- /dev/null +++ b/examples/head @@ -0,0 +1,30 @@ +# $Id$ + +# this file is responsible for importing all of the files we want to actually test + +# these are all of the simple tests +import "simpletests" +import "assignments" +import "selectors" +#import "iftest" +import "importing" +import "execs" +import "filedefaults" + +# facts are now imported into the top of the namespace +#import "facts" + +# obsoleted +#import "functions" + +# files we no longer need to import directly, or at all in some cases +#import "one" +#import "classing" +#import "components" +#import "file.bl" +#import "fileparsing.disabled" +#import "groups" + +# this imports the more complex files +import "allatonce" # imports classing and components +import "nodes" # imports classing and components diff --git a/examples/importing b/examples/importing new file mode 100644 index 000000000..f02604109 --- /dev/null +++ b/examples/importing @@ -0,0 +1,8 @@ +# $Id$ + +#import "groups" +# testing import loops +import "importing" + +$name = "value" +$system = $operatingsystem diff --git a/examples/mac_automount.pp b/examples/mac_automount.pp new file mode 100644 index 000000000..bab0136fc --- /dev/null +++ b/examples/mac_automount.pp @@ -0,0 +1,16 @@ +#!/usr/bin/env puppet +# Jeff McCune +# +# Apple's Automounter spawns a child that sends the parent +# a SIGTERM. This makes it *very* difficult to figure out +# if the process started correctly or not. +# + +service {"automount-test": + provider => base, + hasrestart => false, + pattern => '/tmp/hometest', + start => "/usr/sbin/automount -m /tmp/home /dev/null -mnt /tmp/hometest", + stop => "ps auxww | grep '/tmp/hometest' | grep -v grep | awk '{print \$2}' | xargs kill", + ensure => running +} diff --git a/examples/mac_dscl.pp b/examples/mac_dscl.pp new file mode 100755 index 000000000..ff59f9d8d --- /dev/null +++ b/examples/mac_dscl.pp @@ -0,0 +1,28 @@ +#!/usr/bin/env puppet --debug --verbose --trace +# +# Jeff McCune: I use this for developing and testing the directory service +# provider. + +User { provider => "directoryservice" } +Group { provider => "directoryservice" } + +user { + "testgone": + ensure => absent, + uid => 550; + "testhere": + ensure => present, + password => "foobar", + shell => "/bin/bash", + uid => 551; +} + +group { + "testgone": + ensure => absent, + gid => 550; + "testhere": + ensure => present, + gid => 551; + +} \ No newline at end of file diff --git a/examples/mac_dscl_revert.pp b/examples/mac_dscl_revert.pp new file mode 100755 index 000000000..c9bd2b541 --- /dev/null +++ b/examples/mac_dscl_revert.pp @@ -0,0 +1,26 @@ +#!/usr/bin/env puppet --debug --verbose --trace +# +# Jeff McCune: I use this for developing and testing the directory service +# provider. + +User { provider => "directoryservice" } +Group { provider => "directoryservice" } + +user { + "testgone": + ensure => absent, + uid => 550; + "testhere": + ensure => absent, + uid => 551; +} + +group { + "testgone": + ensure => absent, + gid => 550; + "testhere": + ensure => absent, + gid => 551; + +} diff --git a/examples/mac_netinfo.pp b/examples/mac_netinfo.pp new file mode 100755 index 000000000..544b64818 --- /dev/null +++ b/examples/mac_netinfo.pp @@ -0,0 +1,5 @@ +#!/usr/bin/env puppet --debug + +user { + "jmccune": provider => "netinfo", ensure => present; +} diff --git a/examples/mac_pkgdmg.pp b/examples/mac_pkgdmg.pp new file mode 100755 index 000000000..a2499e815 --- /dev/null +++ b/examples/mac_pkgdmg.pp @@ -0,0 +1,7 @@ +#!/usr/bin/env puppet +# + +package +{ + "Foobar.pkg.dmg": ensure => present, provider => pkgdmg; +} diff --git a/examples/modules/sample-module.pp b/examples/modules/sample-module.pp new file mode 100644 index 000000000..57079a0aa --- /dev/null +++ b/examples/modules/sample-module.pp @@ -0,0 +1,10 @@ +# Jeff McCune +# 2007-08-14 +# +# Use: +# puppet --verbose --debug --modulepath=`pwd` ./sample-module.pp +# +# sample-module demonstrates the use of a custom language function +# included within the module bundle. + +include sample-module diff --git a/examples/modules/sample-module/README.txt b/examples/modules/sample-module/README.txt new file mode 100644 index 000000000..ee4b8201a --- /dev/null +++ b/examples/modules/sample-module/README.txt @@ -0,0 +1,17 @@ +Jeff McCune +2007-08-14 + +This small, sample module demonstrates how to extend the puppet language +with a new parser function. + +See: +manifests/init.pp +lib/puppet/parser/functions/hostname_to_dn.rb +templates/sample.erb + +Note the consistent naming of files for Puppet::Util::Autoload + +Reference Documents: +http://reductivelabs.com/trac/puppet/wiki/ModuleOrganisation +http://reductivelabs.com/trac/puppet/wiki/WritingYourOwnFunctions +http://reductivelabs.com/trac/puppet/wiki/FunctionReference diff --git a/examples/modules/sample-module/lib/puppet/parser/functions/hostname_to_dn.rb b/examples/modules/sample-module/lib/puppet/parser/functions/hostname_to_dn.rb new file mode 100644 index 000000000..9f732b5bc --- /dev/null +++ b/examples/modules/sample-module/lib/puppet/parser/functions/hostname_to_dn.rb @@ -0,0 +1,36 @@ +# Copyright (C) David Schmitt +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. Neither the name of the Author nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. + +# Jeff McCune +# 2007-08-14 +# See: http://reductivelabs.com/trac/puppet/wiki/WritingYourOwnFunctions + +module Puppet::Parser::Functions + newfunction(:hostname_to_dn, :type => :rvalue, :doc => "Given 'foo.bar.com', return 'dc=foo,dc=bar,dc=com'.") do |args| + args[0].split(/\./).map do |s| "dc=%s"%[s] end.join(",") + end +end diff --git a/examples/modules/sample-module/manifests/init.pp b/examples/modules/sample-module/manifests/init.pp new file mode 100644 index 000000000..1af8dff1f --- /dev/null +++ b/examples/modules/sample-module/manifests/init.pp @@ -0,0 +1,12 @@ +# Jeff McCune +# +# Demonstration of a custom parser function and erb template within +# a module, working in concert. + +class sample-module { + $fqdn_to_dn = hostname_to_dn($domain) + $sample_template = template("sample-module/sample.erb") + + notice("hostname_to_dn module function returned: [$fqdn_to_dn]") + info("sample.erb looks like:\n$sample_template") +} diff --git a/examples/modules/sample-module/templates/sample.erb b/examples/modules/sample-module/templates/sample.erb new file mode 100644 index 000000000..b13561b45 --- /dev/null +++ b/examples/modules/sample-module/templates/sample.erb @@ -0,0 +1,5 @@ + +## Jeff McCune +fqdn: <%= fqdn %> +basedn: <%= fqdn_to_dn %> +## end sample.erb ## diff --git a/examples/nodes b/examples/nodes new file mode 100644 index 000000000..42488e689 --- /dev/null +++ b/examples/nodes @@ -0,0 +1,20 @@ +# $Id$ + +# define nodes + +#service.setpath("../examples/root/etc/init.d") + +Service { + path => "../examples/root/etc/init.d" +} + +import "classing" + +sleepserver { + path => $operatingsystem ? { + sunos => "../examples/root/etc/configfile", + hpux => "../examples/other/etc/configfile", + default => "../examples/root/etc/configfile" + }, + schedule => true +} diff --git a/examples/one b/examples/one new file mode 100644 index 000000000..452d32f3e --- /dev/null +++ b/examples/one @@ -0,0 +1,8 @@ +# $Id$ + +# this service doesn't actually exist, so we noop it +# and this way, we can test noop :) +service { "funtest": + running => "0", + noop => true +} diff --git a/examples/relationships b/examples/relationships new file mode 100644 index 000000000..795788947 --- /dev/null +++ b/examples/relationships @@ -0,0 +1,34 @@ +# $Id$ + +#service.setpath("../examples/root/etc/init.d") +#puppet.statefile("/tmp/puppetstate") +$path = "../examples/root/etc/configfile" + path => "../examples/root/etc/init.d" + + +define files { + file { "/tmp/yaytest": + ensure => file, + mode => 755 + } + file { "/tmp/exists": + checksum => md5 + } +} + +define sleeper { + file { $path: + mode => 755 + } + service { sleeper: + path => "../examples/root/etc/init.d", + running => 1 + } +} + +files { } + +sleeper { + require => files["yay"], + schedule => true +} diff --git a/examples/root/bin/sleeper b/examples/root/bin/sleeper deleted file mode 100755 index 980d66ac1..000000000 --- a/examples/root/bin/sleeper +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env ruby -w - -### -# sleep indefinitely as a debug - -require 'getoptlong' - -#----------------------------------------------------------------- -def daemonize - outfile = "/tmp/sleeperout" - if pid = fork() - Process.detach(pid) - sleep 1 - # verify that we didn't have any problems starting the daemon - if FileTest.exists?(outfile) - $stderr.puts "Sleeper failed: %s" % File.read(outfile) - File.unlink(outfile) - exit(14) - else - exit(0) - end - end - Process.setsid - Dir.chdir("/") - begin - $stdin.reopen "/dev/null" - $stdout.reopen "/dev/null", "a" - $stderr.reopen $stdin - rescue => detail - File.open(outfile, "w") { |f| - f.puts detail - } - exit(12) - end -end -#----------------------------------------------------------------- - -debug = false - -result = GetoptLong.new( - [ "--debug", "-d", GetoptLong::NO_ARGUMENT ], - [ "--help", "-h", GetoptLong::NO_ARGUMENT ] -) - -result.each { |opt,arg| - case opt - when "--help" - puts "There is no help yet" - exit - when "--debug" - debug = true - else - raise "Invalid option '#{opt}'" - end -} - -trap(:INT) { - exit -} - -unless debug - daemonize() -end - -# Sleep for no more than two minutes -sleep 120 -exit diff --git a/examples/root/etc/configfile b/examples/root/etc/configfile deleted file mode 100644 index e69de29bb..000000000 diff --git a/examples/root/etc/debian-passwd b/examples/root/etc/debian-passwd deleted file mode 100644 index 59cdf4acf..000000000 --- a/examples/root/etc/debian-passwd +++ /dev/null @@ -1,29 +0,0 @@ -root:x:0:0:root:/root:/bin/bash -daemon:x:1:1:daemon:/usr/sbin:/bin/sh -bin:x:2:2:bin:/bin:/bin/sh -sys:x:3:3:sys:/dev:/bin/sh -sync:x:4:65534:sync:/bin:/bin/sync -games:x:5:60:games:/usr/games:/bin/sh -man:x:6:12:man:/var/cache/man:/bin/sh -lp:x:7:7:lp:/var/spool/lpd:/bin/sh -mail:x:8:8:mail:/var/mail:/bin/sh -news:x:9:9:news:/var/spool/news:/bin/sh -uucp:x:10:10:uucp:/var/spool/uucp:/bin/sh -proxy:x:13:13:proxy:/bin:/bin/sh -postgres:x:31:32:postgres:/var/lib/postgres:/bin/sh -www-data:x:33:33:www-data:/var/www:/bin/sh -backup:x:34:34:backup:/var/backups:/bin/sh -operator:x:37:37:Operator:/var:/bin/sh -list:x:38:38:Mailing List Manager:/var/list:/bin/sh -irc:x:39:39:ircd:/var/run/ircd:/bin/sh -gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/bin/sh -nobody:x:65534:65534:nobody:/nonexistent:/bin/sh -sshd:x:102:65534::/var/run/sshd:/bin/false -gdm:x:101:101:Gnome Display Manager:/var/lib/gdm:/bin/false -telnetd:x:103:103::/usr/lib/telnetd:/bin/false -nagios:x:1000:1001::/home/nagios: -messagebus:x:104:107::/var/run/dbus:/bin/false -saned:x:109:109::/home/saned:/bin/false -ganglia:x:105:110:Ganglia Monitor:/var/lib/ganglia:/bin/false -zope:x:106:111::/var/lib/zope2.7/var:/bin/false -fbgetty:x:112:112::/home/fbgetty:/bin/false diff --git a/examples/root/etc/debian-syslog.conf b/examples/root/etc/debian-syslog.conf deleted file mode 100644 index 8f2925960..000000000 --- a/examples/root/etc/debian-syslog.conf +++ /dev/null @@ -1,71 +0,0 @@ -# /etc/syslog.conf Configuration file for syslogd. -# -# For more information see syslog.conf(5) -# manpage. - -# -# First some standard logfiles. Log by facility. -# - -auth,authpriv.* /var/log/auth.log -*.*;auth,authpriv.none -/var/log/syslog -#cron.* /var/log/cron.log -daemon.* -/var/log/daemon.log -kern.* -/var/log/kern.log -lpr.* -/var/log/lpr.log -mail.* -/var/log/mail.log -user.* -/var/log/user.log -uucp.* /var/log/uucp.log - -# -# Logging for the mail system. Split it up so that -# it is easy to write scripts to parse these files. -# -mail.info -/var/log/mail.info -mail.warn -/var/log/mail.warn -mail.err /var/log/mail.err - -# Logging for INN news system -# -news.crit /var/log/news/news.crit -news.err /var/log/news/news.err -news.notice -/var/log/news/news.notice - -# -# Some `catch-all' logfiles. -# -*.=debug;\ - auth,authpriv.none;\ - news.none;mail.none -/var/log/debug -*.=info;*.=notice;*.=warn;\ - auth,authpriv.none;\ - cron,daemon.none;\ - mail,news.none -/var/log/messages - -# -# Emergencies are sent to everybody logged in. -# -*.emerg * - -# -# I like to have messages displayed on the console, but only on a virtual -# console I usually leave idle. -# -#daemon,mail.*;\ -# news.=crit;news.=err;news.=notice;\ -# *.=debug;*.=info;\ -# *.=notice;*.=warn /dev/tty8 - -# The named pipe /dev/xconsole is for the `xconsole' utility. To use it, -# you must invoke `xconsole' with the `-file' option: -# -# $ xconsole -file /dev/xconsole [...] -# -# NOTE: adjust the list below, or you'll go crazy if you have a reasonably -# busy site.. -# -daemon.*;mail.*;\ - news.crit;news.err;news.notice;\ - *.=debug;*.=info;\ - *.=notice;*.=warn |/dev/xconsole - diff --git a/examples/root/etc/init.d/sleeper b/examples/root/etc/init.d/sleeper deleted file mode 100755 index 6da5eae32..000000000 --- a/examples/root/etc/init.d/sleeper +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash - -# $Id$ - -script=$0 -path=`echo $script | sed 's/etc..*/bin/'` - -PATH=$PATH:$path - -ps=`facter ps` - -if [ -z "$ps" ]; then - ps="ps -ef" -fi - -function start -{ - cd $path - ./sleeper -} - -function stop -{ - #if [ -n `which pgrep` ]; then - # pid=`pgrep sleeper` - #else - pid=`$ps | grep -v grep | grep sleeper | grep ruby | awk '{print $2}'` - #fi - if [ -n "$pid" ]; then - kill $pid - fi -} - -function restart -{ - stop - start -} - -function status -{ - #if [ -n `which pgrep` ]; then - # cmd="pgrep sleeper" - #else - #cmd="$ps | grep -v grep | grep sleeper | grep ruby | awk '{print $2}'" - #fi - #$cmd - $ps | grep -v grep | grep sleeper | grep ruby -} - -case "$1" in - start) - start - ;; - stop) - stop - ;; - restart) - stop; start - ;; - status) - output=`status` - #status - exit $? - ;; - *) - echo "Usage: $N {start|stop|restart|force-reload}" >&2 - exit 1 - ;; -esac - -exit 0 diff --git a/examples/root/etc/otherfile b/examples/root/etc/otherfile deleted file mode 100644 index e69de29bb..000000000 diff --git a/examples/root/etc/puppet/fileserver.conf b/examples/root/etc/puppet/fileserver.conf deleted file mode 100644 index 32dfcdd5c..000000000 --- a/examples/root/etc/puppet/fileserver.conf +++ /dev/null @@ -1,13 +0,0 @@ -# $Id$ - -[dist] - path /dist - allow *.madstop.com - -[plugins] - path /var/puppet/plugins - allow *.madstop.com - -[facts] - path /var/puppet/facts - allow *.madstop.com diff --git a/examples/root/etc/puppet/namespaceauth.conf b/examples/root/etc/puppet/namespaceauth.conf deleted file mode 100644 index fb08d428b..000000000 --- a/examples/root/etc/puppet/namespaceauth.conf +++ /dev/null @@ -1,20 +0,0 @@ -# This file is only necessary if your clients listen. -# Note that it affects all puppet daemons, including puppetmasterd, -# which is why puppetmaster is in there. -[fileserver] - allow *.madstop.com - -[puppetmaster] - allow *.madstop.com - -[pelementserver] - allow puppet.madstop.com - -[puppetrunner] - allow culain.madstop.com - -[puppetbucket] - allow *.madstop.com - -[puppetreports] - allow *.madstop.com diff --git a/examples/root/etc/puppet/puppet.conf b/examples/root/etc/puppet/puppet.conf deleted file mode 100644 index 151364ebd..000000000 --- a/examples/root/etc/puppet/puppet.conf +++ /dev/null @@ -1,10 +0,0 @@ -[puppetd] -report = true -factsync = true -pluginsync = true - -[puppetmasterd] -reports = store,rrdgraph,tagmail,log -node_terminus = ldap -ldapserver = culain.madstop.com -ldapbase = dc=madstop,dc=com diff --git a/examples/root/etc/puppet/tagmail.conf b/examples/root/etc/puppet/tagmail.conf deleted file mode 100644 index 31c77f4bc..000000000 --- a/examples/root/etc/puppet/tagmail.conf +++ /dev/null @@ -1 +0,0 @@ -all: user@domain.com diff --git a/examples/selectors b/examples/selectors new file mode 100644 index 000000000..a70399bc7 --- /dev/null +++ b/examples/selectors @@ -0,0 +1,28 @@ +# $Id$ +# + +$platform = SunOS + +$funtest = $platform ? { + SunOS => yayness, + AIX => goodness, + default => badness +} + +# this is a comment + +$filename = "/tmp/yayness" + +$sleeper = file { $filename: + mode => $platform ? { + SunOS => 644, + default => 755 + }, + create => $platform ? "SunOS" => true +} + +# i guess it has to be solved this way... + +#$platform ? sunos => file { $filename: +# mode => 644 +#} diff --git a/examples/simpletests b/examples/simpletests new file mode 100644 index 000000000..b4fd3234e --- /dev/null +++ b/examples/simpletests @@ -0,0 +1,11 @@ +# $Id$ + +file { + "/tmp/atest": ensure => file; + "/tmp/btest": ensure => file +} + +file { + "/tmp/ctest": ensure => file; + "/tmp/dtest": ensure => file; +} diff --git a/examples/svncommit b/examples/svncommit new file mode 100644 index 000000000..350cd8580 --- /dev/null +++ b/examples/svncommit @@ -0,0 +1,13 @@ +$path = "/usr/bin:/bin" + +file { "/tmp/svntests": + recurse => true, + checksum => md5 +} + +exec { "echo 'files have been updated'": + cwd => "/tmp/svntests", + refreshonly => true, + require => file["/tmp/svntests"], + path => $path +} diff --git a/ext/root/bin/sleeper b/ext/root/bin/sleeper new file mode 100755 index 000000000..980d66ac1 --- /dev/null +++ b/ext/root/bin/sleeper @@ -0,0 +1,67 @@ +#!/usr/bin/env ruby -w + +### +# sleep indefinitely as a debug + +require 'getoptlong' + +#----------------------------------------------------------------- +def daemonize + outfile = "/tmp/sleeperout" + if pid = fork() + Process.detach(pid) + sleep 1 + # verify that we didn't have any problems starting the daemon + if FileTest.exists?(outfile) + $stderr.puts "Sleeper failed: %s" % File.read(outfile) + File.unlink(outfile) + exit(14) + else + exit(0) + end + end + Process.setsid + Dir.chdir("/") + begin + $stdin.reopen "/dev/null" + $stdout.reopen "/dev/null", "a" + $stderr.reopen $stdin + rescue => detail + File.open(outfile, "w") { |f| + f.puts detail + } + exit(12) + end +end +#----------------------------------------------------------------- + +debug = false + +result = GetoptLong.new( + [ "--debug", "-d", GetoptLong::NO_ARGUMENT ], + [ "--help", "-h", GetoptLong::NO_ARGUMENT ] +) + +result.each { |opt,arg| + case opt + when "--help" + puts "There is no help yet" + exit + when "--debug" + debug = true + else + raise "Invalid option '#{opt}'" + end +} + +trap(:INT) { + exit +} + +unless debug + daemonize() +end + +# Sleep for no more than two minutes +sleep 120 +exit diff --git a/ext/root/etc/configfile b/ext/root/etc/configfile new file mode 100644 index 000000000..e69de29bb diff --git a/ext/root/etc/debian-passwd b/ext/root/etc/debian-passwd new file mode 100644 index 000000000..59cdf4acf --- /dev/null +++ b/ext/root/etc/debian-passwd @@ -0,0 +1,29 @@ +root:x:0:0:root:/root:/bin/bash +daemon:x:1:1:daemon:/usr/sbin:/bin/sh +bin:x:2:2:bin:/bin:/bin/sh +sys:x:3:3:sys:/dev:/bin/sh +sync:x:4:65534:sync:/bin:/bin/sync +games:x:5:60:games:/usr/games:/bin/sh +man:x:6:12:man:/var/cache/man:/bin/sh +lp:x:7:7:lp:/var/spool/lpd:/bin/sh +mail:x:8:8:mail:/var/mail:/bin/sh +news:x:9:9:news:/var/spool/news:/bin/sh +uucp:x:10:10:uucp:/var/spool/uucp:/bin/sh +proxy:x:13:13:proxy:/bin:/bin/sh +postgres:x:31:32:postgres:/var/lib/postgres:/bin/sh +www-data:x:33:33:www-data:/var/www:/bin/sh +backup:x:34:34:backup:/var/backups:/bin/sh +operator:x:37:37:Operator:/var:/bin/sh +list:x:38:38:Mailing List Manager:/var/list:/bin/sh +irc:x:39:39:ircd:/var/run/ircd:/bin/sh +gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/bin/sh +nobody:x:65534:65534:nobody:/nonexistent:/bin/sh +sshd:x:102:65534::/var/run/sshd:/bin/false +gdm:x:101:101:Gnome Display Manager:/var/lib/gdm:/bin/false +telnetd:x:103:103::/usr/lib/telnetd:/bin/false +nagios:x:1000:1001::/home/nagios: +messagebus:x:104:107::/var/run/dbus:/bin/false +saned:x:109:109::/home/saned:/bin/false +ganglia:x:105:110:Ganglia Monitor:/var/lib/ganglia:/bin/false +zope:x:106:111::/var/lib/zope2.7/var:/bin/false +fbgetty:x:112:112::/home/fbgetty:/bin/false diff --git a/ext/root/etc/debian-syslog.conf b/ext/root/etc/debian-syslog.conf new file mode 100644 index 000000000..8f2925960 --- /dev/null +++ b/ext/root/etc/debian-syslog.conf @@ -0,0 +1,71 @@ +# /etc/syslog.conf Configuration file for syslogd. +# +# For more information see syslog.conf(5) +# manpage. + +# +# First some standard logfiles. Log by facility. +# + +auth,authpriv.* /var/log/auth.log +*.*;auth,authpriv.none -/var/log/syslog +#cron.* /var/log/cron.log +daemon.* -/var/log/daemon.log +kern.* -/var/log/kern.log +lpr.* -/var/log/lpr.log +mail.* -/var/log/mail.log +user.* -/var/log/user.log +uucp.* /var/log/uucp.log + +# +# Logging for the mail system. Split it up so that +# it is easy to write scripts to parse these files. +# +mail.info -/var/log/mail.info +mail.warn -/var/log/mail.warn +mail.err /var/log/mail.err + +# Logging for INN news system +# +news.crit /var/log/news/news.crit +news.err /var/log/news/news.err +news.notice -/var/log/news/news.notice + +# +# Some `catch-all' logfiles. +# +*.=debug;\ + auth,authpriv.none;\ + news.none;mail.none -/var/log/debug +*.=info;*.=notice;*.=warn;\ + auth,authpriv.none;\ + cron,daemon.none;\ + mail,news.none -/var/log/messages + +# +# Emergencies are sent to everybody logged in. +# +*.emerg * + +# +# I like to have messages displayed on the console, but only on a virtual +# console I usually leave idle. +# +#daemon,mail.*;\ +# news.=crit;news.=err;news.=notice;\ +# *.=debug;*.=info;\ +# *.=notice;*.=warn /dev/tty8 + +# The named pipe /dev/xconsole is for the `xconsole' utility. To use it, +# you must invoke `xconsole' with the `-file' option: +# +# $ xconsole -file /dev/xconsole [...] +# +# NOTE: adjust the list below, or you'll go crazy if you have a reasonably +# busy site.. +# +daemon.*;mail.*;\ + news.crit;news.err;news.notice;\ + *.=debug;*.=info;\ + *.=notice;*.=warn |/dev/xconsole + diff --git a/ext/root/etc/init.d/sleeper b/ext/root/etc/init.d/sleeper new file mode 100755 index 000000000..6da5eae32 --- /dev/null +++ b/ext/root/etc/init.d/sleeper @@ -0,0 +1,72 @@ +#!/bin/bash + +# $Id$ + +script=$0 +path=`echo $script | sed 's/etc..*/bin/'` + +PATH=$PATH:$path + +ps=`facter ps` + +if [ -z "$ps" ]; then + ps="ps -ef" +fi + +function start +{ + cd $path + ./sleeper +} + +function stop +{ + #if [ -n `which pgrep` ]; then + # pid=`pgrep sleeper` + #else + pid=`$ps | grep -v grep | grep sleeper | grep ruby | awk '{print $2}'` + #fi + if [ -n "$pid" ]; then + kill $pid + fi +} + +function restart +{ + stop + start +} + +function status +{ + #if [ -n `which pgrep` ]; then + # cmd="pgrep sleeper" + #else + #cmd="$ps | grep -v grep | grep sleeper | grep ruby | awk '{print $2}'" + #fi + #$cmd + $ps | grep -v grep | grep sleeper | grep ruby +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart) + stop; start + ;; + status) + output=`status` + #status + exit $? + ;; + *) + echo "Usage: $N {start|stop|restart|force-reload}" >&2 + exit 1 + ;; +esac + +exit 0 diff --git a/ext/root/etc/otherfile b/ext/root/etc/otherfile new file mode 100644 index 000000000..e69de29bb diff --git a/ext/root/etc/puppet/fileserver.conf b/ext/root/etc/puppet/fileserver.conf new file mode 100644 index 000000000..32dfcdd5c --- /dev/null +++ b/ext/root/etc/puppet/fileserver.conf @@ -0,0 +1,13 @@ +# $Id$ + +[dist] + path /dist + allow *.madstop.com + +[plugins] + path /var/puppet/plugins + allow *.madstop.com + +[facts] + path /var/puppet/facts + allow *.madstop.com diff --git a/ext/root/etc/puppet/namespaceauth.conf b/ext/root/etc/puppet/namespaceauth.conf new file mode 100644 index 000000000..fb08d428b --- /dev/null +++ b/ext/root/etc/puppet/namespaceauth.conf @@ -0,0 +1,20 @@ +# This file is only necessary if your clients listen. +# Note that it affects all puppet daemons, including puppetmasterd, +# which is why puppetmaster is in there. +[fileserver] + allow *.madstop.com + +[puppetmaster] + allow *.madstop.com + +[pelementserver] + allow puppet.madstop.com + +[puppetrunner] + allow culain.madstop.com + +[puppetbucket] + allow *.madstop.com + +[puppetreports] + allow *.madstop.com diff --git a/ext/root/etc/puppet/puppet.conf b/ext/root/etc/puppet/puppet.conf new file mode 100644 index 000000000..151364ebd --- /dev/null +++ b/ext/root/etc/puppet/puppet.conf @@ -0,0 +1,10 @@ +[puppetd] +report = true +factsync = true +pluginsync = true + +[puppetmasterd] +reports = store,rrdgraph,tagmail,log +node_terminus = ldap +ldapserver = culain.madstop.com +ldapbase = dc=madstop,dc=com diff --git a/ext/root/etc/puppet/tagmail.conf b/ext/root/etc/puppet/tagmail.conf new file mode 100644 index 000000000..31c77f4bc --- /dev/null +++ b/ext/root/etc/puppet/tagmail.conf @@ -0,0 +1 @@ +all: user@domain.com -- cgit From 80436550a1e3040399e410be3edf7c44d29fc320 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Wed, 9 Jul 2008 17:41:21 -0700 Subject: Fixing #1408 - --loadclasses works again. The problem was that the mechanism I was using for passing the node to the compiler was conflicting with the Indirector::Request's method of handling node authentication. Signed-off-by: Luke Kanies --- bin/puppet | 2 +- lib/puppet/indirector/catalog/compiler.rb | 2 +- spec/integration/node/catalog.rb | 10 ++++++++++ spec/unit/indirector/catalog/compiler.rb | 8 +++++--- 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/bin/puppet b/bin/puppet index 530766800..0e64b1cf3 100755 --- a/bin/puppet +++ b/bin/puppet @@ -207,7 +207,7 @@ end begin # Compile our catalog - catalog = Puppet::Node::Catalog.find(node.name, :node => node) + catalog = Puppet::Node::Catalog.find(node.name, :use_node => node) # Translate it to a RAL catalog catalog = catalog.to_ral diff --git a/lib/puppet/indirector/catalog/compiler.rb b/lib/puppet/indirector/catalog/compiler.rb index 455a92cc7..a6a812817 100644 --- a/lib/puppet/indirector/catalog/compiler.rb +++ b/lib/puppet/indirector/catalog/compiler.rb @@ -14,7 +14,7 @@ class Puppet::Node::Catalog::Compiler < Puppet::Indirector::Code # Compile a node's catalog. def find(request) - unless node = request.options[:node] || find_node(request.key) + unless node = request.options[:use_node] || find_node(request.key) raise ArgumentError, "Could not find node '%s'; cannot compile" % request.key end diff --git a/spec/integration/node/catalog.rb b/spec/integration/node/catalog.rb index 1fa2afbb0..ed38ae987 100755 --- a/spec/integration/node/catalog.rb +++ b/spec/integration/node/catalog.rb @@ -40,5 +40,15 @@ describe Puppet::Node::Catalog do Puppet::Node::Catalog.find("me").should be_nil end + + it "should pass provided node information directly to the terminus" do + terminus = mock 'terminus' + + Puppet::Node::Catalog.indirection.stubs(:terminus).returns terminus + + node = mock 'node' + terminus.expects(:find).with { |request| request.options[:use_node] == node } + Puppet::Node::Catalog.find("me", :use_node => node) + end end end diff --git a/spec/unit/indirector/catalog/compiler.rb b/spec/unit/indirector/catalog/compiler.rb index cf7186a5a..8cd3c72f4 100755 --- a/spec/unit/indirector/catalog/compiler.rb +++ b/spec/unit/indirector/catalog/compiler.rb @@ -114,13 +114,12 @@ describe Puppet::Node::Catalog::Compiler, " when creating catalogs" do @node = Puppet::Node.new @name @node.stubs(:merge) @request = stub 'request', :key => @name, :options => {} - Puppet::Node.stubs(:find).with(@name).returns(@node) end it "should directly use provided nodes" do Puppet::Node.expects(:find).never - @compiler.interpreter.expects(:compile).with(@node) - @request.stubs(:options).returns(:node => @node) + @compiler.expects(:compile).with(@node) + @request.stubs(:options).returns(:use_node => @node) @compiler.find(@request) end @@ -130,12 +129,14 @@ describe Puppet::Node::Catalog::Compiler, " when creating catalogs" do end it "should pass the found node to the interpreter for compiling" do + Puppet::Node.expects(:find).with(@name).returns(@node) config = mock 'config' @compiler.interpreter.expects(:compile).with(@node) @compiler.find(@request) end it "should return the results of compiling as the catalog" do + Puppet::Node.stubs(:find).returns(@node) config = mock 'config' result = mock 'result' @@ -144,6 +145,7 @@ describe Puppet::Node::Catalog::Compiler, " when creating catalogs" do end it "should benchmark the compile process" do + Puppet::Node.stubs(:find).returns(@node) @compiler.stubs(:networked?).returns(true) @compiler.expects(:benchmark).with do |level, message| level == :notice and message =~ /^Compiled catalog/ -- cgit From 4c5293b837807f61002365114fd7004d2f74ad57 Mon Sep 17 00:00:00 2001 From: Francois Deppierraz Date: Fri, 11 Jul 2008 14:39:52 +0200 Subject: Fix #1409, Move path expansion from the type into the provider This avoid exceptions during type instanciation when a user does not yet exist. The drawback is that we cannot use generated resources anymore and have to mkdir, chown and chmod directly in the provided which is somewhat hackish. --- lib/puppet/provider/ssh_authorized_key/parsed.rb | 36 +++++++++++++++++++++ lib/puppet/type/ssh_authorized_key.rb | 26 +-------------- spec/unit/provider/ssh_authorized_key/parsed.rb | 21 ++++++++++++ spec/unit/type/ssh_authorized_key.rb | 41 ------------------------ 4 files changed, 58 insertions(+), 66 deletions(-) diff --git a/lib/puppet/provider/ssh_authorized_key/parsed.rb b/lib/puppet/provider/ssh_authorized_key/parsed.rb index 351ebcd1b..3bd22c06b 100644 --- a/lib/puppet/provider/ssh_authorized_key/parsed.rb +++ b/lib/puppet/provider/ssh_authorized_key/parsed.rb @@ -29,5 +29,41 @@ Puppet::Type.type(:ssh_authorized_key).provide(:parsed, record[:options] = record[:options].join(',') end } + + def prefetch + # This was done in the type class but path expansion was failing for + # not yet existing users, the only workaround I found was to move that + # in the provider. + if user = @resource.should(:user) + target = File.expand_path("~%s/.ssh/authorized_keys" % user) + @property_hash[:target] = target + @resource[:target] = target + end + + super + end + + def flush + # As path expansion had to be moved in the provider, we cannot generate new file + # resources and thus have to chown and chmod here. It smells hackish. + + # Create target's parent directory if nonexistant + if target = @property_hash[:target] + dir = File.dirname(@property_hash[:target]) + if not File.exist? dir + Puppet.debug("Creating directory %s which did not exist" % dir) + Dir.mkdir(dir, 0700) + end + end + + # Generate the file + super + + # Ensure correct permissions + if target and user = @property_hash[:user] + File.chown(Puppet::Util.uid(user), nil, dir) + File.chown(Puppet::Util.uid(user), nil, @property_hash[:target]) + end + end end diff --git a/lib/puppet/type/ssh_authorized_key.rb b/lib/puppet/type/ssh_authorized_key.rb index 3a12e95ad..1db4a0ac3 100644 --- a/lib/puppet/type/ssh_authorized_key.rb +++ b/lib/puppet/type/ssh_authorized_key.rb @@ -27,11 +27,6 @@ module Puppet newproperty(:user) do desc "The user account in which the SSH key should be installed." - - def value=(value) - @resource[:target] = File.expand_path("~%s/.ssh/authorized_keys" % value) - super - end end newproperty(:target) do @@ -45,25 +40,6 @@ module Puppet defaultto do :absent end end - def generate - atype = Puppet::Type.type(:file) - target = self.should(:target) - dir = File.dirname(target) - user = should(:user) ? should(:user) : "root" - - rels = [] - - unless catalog.resource(:file, dir) - rels << atype.create(:name => dir, :ensure => :directory, :mode => 0700, :owner => user) - end - - unless catalog.resource(:file, target) - rels << atype.create(:name => target, :ensure => :present, :mode => 0600, :owner => user) - end - - rels - end - autorequire(:user) do if should(:user) should(:user) @@ -71,7 +47,7 @@ module Puppet end validate do - unless should(:target) + unless should(:target) or should(:user) raise Puppet::Error, "Attribute 'user' or 'target' is mandatory" end end diff --git a/spec/unit/provider/ssh_authorized_key/parsed.rb b/spec/unit/provider/ssh_authorized_key/parsed.rb index c35ddc513..16efc5b58 100755 --- a/spec/unit/provider/ssh_authorized_key/parsed.rb +++ b/spec/unit/provider/ssh_authorized_key/parsed.rb @@ -71,4 +71,25 @@ describe provider_class do genkey(key).should == "from=\"192.168.1.1\",no-pty,no-X11-forwarding ssh-rsa AAAAfsfddsjldjgksdflgkjsfdlgkj root@localhost\n" end + + it "should prefetch ~user/.ssh/authorized_keys when user is given" do + key = Puppet::Type.type(:ssh_authorized_key).create( + :name => "Test", + :key => "AA", + :type => "rsa", + :ensure => :present, + :user => "root") + prov = @provider.new key + + prov.prefetch + prov.target.should == File.expand_path("~root/.ssh/authorized_keys") + end + + it "should create destination dir" do + # No idea how to test the flush method + end + + it "should set correct default permissions" do + # No idea how to test the flush method + end end diff --git a/spec/unit/type/ssh_authorized_key.rb b/spec/unit/type/ssh_authorized_key.rb index 0b41af40a..e21478479 100755 --- a/spec/unit/type/ssh_authorized_key.rb +++ b/spec/unit/type/ssh_authorized_key.rb @@ -77,47 +77,6 @@ describe ssh_authorized_key do @class.attrtype(:target).should == :property end - it "should autorequire parent directories when user is given" do - @catalog.add_resource @class.create( - :name => "Test", - :key => "AAA", - :type => "ssh-rsa", - :ensure => :present, - :user => "root") - @catalog.apply - - target = File.expand_path("~root/.ssh") - @catalog.resource(:file, target).should be_an_instance_of(Puppet::Type.type(:file)) - end - - it "should set target when user is given" do - @catalog.add_resource @class.create( - :name => "Test", - :key => "AAA", - :type => "ssh-rsa", - :ensure => :present, - :user => "root") - @catalog.apply - - target = File.expand_path("~root/.ssh/authorized_keys") - @catalog.resource(:file, target).should be_an_instance_of(Puppet::Type.type(:file)) - end - - - it "should autorequire parent directories when target is given" do - target = "/tmp/home/foo/bar/.ssh/authorized_keys" - - @catalog.add_resource @class.create( - :name => "Test", - :key => "AAA", - :type => "ssh-rsa", - :ensure => :present, - :target => target) - @catalog.apply - - @catalog.resource(:file, target).should be_an_instance_of(Puppet::Type.type(:file)) - end - it "should raise an error when neither user nor target is given" do proc do @class.create( -- cgit From 4ce7159baba4c637867c91519b5a3b16627dfca5 Mon Sep 17 00:00:00 2001 From: Andrew Shafer Date: Mon, 14 Jul 2008 19:54:52 -0600 Subject: Fail instead of log when rescuing remote file connections Issue 1397 one line fix, very simple --- CHANGELOG | 2 ++ lib/puppet/type/file/source.rb | 3 +-- spec/unit/type/file.rb | 5 +++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index e85f9f249..70c542118 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,6 @@ 0.24.5 + Fixed #1397 One line fix, fail instead of log + Moved debian to conf and updated examples directory Fixed #1368 - updated Red Hat init scripts diff --git a/lib/puppet/type/file/source.rb b/lib/puppet/type/file/source.rb index f2704abb6..2514d3d1e 100755 --- a/lib/puppet/type/file/source.rb +++ b/lib/puppet/type/file/source.rb @@ -101,8 +101,7 @@ module Puppet begin desc = server.describe(path, @resource[:links]) rescue Puppet::Network::XMLRPCClientError => detail - self.err "Could not describe %s: %s" % [path, detail] - return nil + fail detail, "Could not describe %s: %s" % [path, detail] end return nil if desc == "" diff --git a/spec/unit/type/file.rb b/spec/unit/type/file.rb index f0ae70cd0..3ea4c3731 100755 --- a/spec/unit/type/file.rb +++ b/spec/unit/type/file.rb @@ -64,6 +64,11 @@ describe Puppet::Type.type(:file) do @file.property(:source).retrieve lambda { @file.property(:source).sync }.should raise_error(Puppet::Error) end + + it "should fail if it cannot describe remote contents" do + @filesource.server.stubs(:describe).raises(Puppet::Network::XMLRPCClientError.new("Testing")) + lambda { @file.retrieve }.should raise_error(Puppet::Error) + end end describe "when managing links" do -- cgit From 65b9869362cd39f20609abb93729cb0c3977f0cf Mon Sep 17 00:00:00 2001 From: James Turnbull Date: Tue, 15 Jul 2008 17:15:05 +1000 Subject: Further moves from the examples directory and ext directory --- CHANGELOG | 2 + examples/etc/init.d/sleeper | 72 ++++++++++++++++++++++++++++++++++ examples/etc/otherfile | 0 examples/etc/puppet/fileserver.conf | 13 ++++++ examples/etc/puppet/namespaceauth.conf | 20 ++++++++++ examples/etc/puppet/puppet.conf | 10 +++++ examples/etc/puppet/tagmail.conf | 1 + ext/bin/sleeper | 67 +++++++++++++++++++++++++++++++ ext/root/bin/sleeper | 67 ------------------------------- ext/root/etc/configfile | 0 ext/root/etc/debian-passwd | 29 -------------- ext/root/etc/debian-syslog.conf | 71 --------------------------------- ext/root/etc/init.d/sleeper | 72 ---------------------------------- ext/root/etc/otherfile | 0 ext/root/etc/puppet/fileserver.conf | 13 ------ ext/root/etc/puppet/namespaceauth.conf | 20 ---------- ext/root/etc/puppet/puppet.conf | 10 ----- ext/root/etc/puppet/tagmail.conf | 1 - 18 files changed, 185 insertions(+), 283 deletions(-) create mode 100755 examples/etc/init.d/sleeper create mode 100644 examples/etc/otherfile create mode 100644 examples/etc/puppet/fileserver.conf create mode 100644 examples/etc/puppet/namespaceauth.conf create mode 100644 examples/etc/puppet/puppet.conf create mode 100644 examples/etc/puppet/tagmail.conf create mode 100755 ext/bin/sleeper delete mode 100755 ext/root/bin/sleeper delete mode 100644 ext/root/etc/configfile delete mode 100644 ext/root/etc/debian-passwd delete mode 100644 ext/root/etc/debian-syslog.conf delete mode 100755 ext/root/etc/init.d/sleeper delete mode 100644 ext/root/etc/otherfile delete mode 100644 ext/root/etc/puppet/fileserver.conf delete mode 100644 ext/root/etc/puppet/namespaceauth.conf delete mode 100644 ext/root/etc/puppet/puppet.conf delete mode 100644 ext/root/etc/puppet/tagmail.conf diff --git a/CHANGELOG b/CHANGELOG index 70c542118..a3d96323d 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,6 @@ 0.24.5 + Further moves from the examples directory and ext directory + Fixed #1397 One line fix, fail instead of log Moved debian to conf and updated examples directory diff --git a/examples/etc/init.d/sleeper b/examples/etc/init.d/sleeper new file mode 100755 index 000000000..6da5eae32 --- /dev/null +++ b/examples/etc/init.d/sleeper @@ -0,0 +1,72 @@ +#!/bin/bash + +# $Id$ + +script=$0 +path=`echo $script | sed 's/etc..*/bin/'` + +PATH=$PATH:$path + +ps=`facter ps` + +if [ -z "$ps" ]; then + ps="ps -ef" +fi + +function start +{ + cd $path + ./sleeper +} + +function stop +{ + #if [ -n `which pgrep` ]; then + # pid=`pgrep sleeper` + #else + pid=`$ps | grep -v grep | grep sleeper | grep ruby | awk '{print $2}'` + #fi + if [ -n "$pid" ]; then + kill $pid + fi +} + +function restart +{ + stop + start +} + +function status +{ + #if [ -n `which pgrep` ]; then + # cmd="pgrep sleeper" + #else + #cmd="$ps | grep -v grep | grep sleeper | grep ruby | awk '{print $2}'" + #fi + #$cmd + $ps | grep -v grep | grep sleeper | grep ruby +} + +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart) + stop; start + ;; + status) + output=`status` + #status + exit $? + ;; + *) + echo "Usage: $N {start|stop|restart|force-reload}" >&2 + exit 1 + ;; +esac + +exit 0 diff --git a/examples/etc/otherfile b/examples/etc/otherfile new file mode 100644 index 000000000..e69de29bb diff --git a/examples/etc/puppet/fileserver.conf b/examples/etc/puppet/fileserver.conf new file mode 100644 index 000000000..32dfcdd5c --- /dev/null +++ b/examples/etc/puppet/fileserver.conf @@ -0,0 +1,13 @@ +# $Id$ + +[dist] + path /dist + allow *.madstop.com + +[plugins] + path /var/puppet/plugins + allow *.madstop.com + +[facts] + path /var/puppet/facts + allow *.madstop.com diff --git a/examples/etc/puppet/namespaceauth.conf b/examples/etc/puppet/namespaceauth.conf new file mode 100644 index 000000000..fb08d428b --- /dev/null +++ b/examples/etc/puppet/namespaceauth.conf @@ -0,0 +1,20 @@ +# This file is only necessary if your clients listen. +# Note that it affects all puppet daemons, including puppetmasterd, +# which is why puppetmaster is in there. +[fileserver] + allow *.madstop.com + +[puppetmaster] + allow *.madstop.com + +[pelementserver] + allow puppet.madstop.com + +[puppetrunner] + allow culain.madstop.com + +[puppetbucket] + allow *.madstop.com + +[puppetreports] + allow *.madstop.com diff --git a/examples/etc/puppet/puppet.conf b/examples/etc/puppet/puppet.conf new file mode 100644 index 000000000..151364ebd --- /dev/null +++ b/examples/etc/puppet/puppet.conf @@ -0,0 +1,10 @@ +[puppetd] +report = true +factsync = true +pluginsync = true + +[puppetmasterd] +reports = store,rrdgraph,tagmail,log +node_terminus = ldap +ldapserver = culain.madstop.com +ldapbase = dc=madstop,dc=com diff --git a/examples/etc/puppet/tagmail.conf b/examples/etc/puppet/tagmail.conf new file mode 100644 index 000000000..31c77f4bc --- /dev/null +++ b/examples/etc/puppet/tagmail.conf @@ -0,0 +1 @@ +all: user@domain.com diff --git a/ext/bin/sleeper b/ext/bin/sleeper new file mode 100755 index 000000000..980d66ac1 --- /dev/null +++ b/ext/bin/sleeper @@ -0,0 +1,67 @@ +#!/usr/bin/env ruby -w + +### +# sleep indefinitely as a debug + +require 'getoptlong' + +#----------------------------------------------------------------- +def daemonize + outfile = "/tmp/sleeperout" + if pid = fork() + Process.detach(pid) + sleep 1 + # verify that we didn't have any problems starting the daemon + if FileTest.exists?(outfile) + $stderr.puts "Sleeper failed: %s" % File.read(outfile) + File.unlink(outfile) + exit(14) + else + exit(0) + end + end + Process.setsid + Dir.chdir("/") + begin + $stdin.reopen "/dev/null" + $stdout.reopen "/dev/null", "a" + $stderr.reopen $stdin + rescue => detail + File.open(outfile, "w") { |f| + f.puts detail + } + exit(12) + end +end +#----------------------------------------------------------------- + +debug = false + +result = GetoptLong.new( + [ "--debug", "-d", GetoptLong::NO_ARGUMENT ], + [ "--help", "-h", GetoptLong::NO_ARGUMENT ] +) + +result.each { |opt,arg| + case opt + when "--help" + puts "There is no help yet" + exit + when "--debug" + debug = true + else + raise "Invalid option '#{opt}'" + end +} + +trap(:INT) { + exit +} + +unless debug + daemonize() +end + +# Sleep for no more than two minutes +sleep 120 +exit diff --git a/ext/root/bin/sleeper b/ext/root/bin/sleeper deleted file mode 100755 index 980d66ac1..000000000 --- a/ext/root/bin/sleeper +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/env ruby -w - -### -# sleep indefinitely as a debug - -require 'getoptlong' - -#----------------------------------------------------------------- -def daemonize - outfile = "/tmp/sleeperout" - if pid = fork() - Process.detach(pid) - sleep 1 - # verify that we didn't have any problems starting the daemon - if FileTest.exists?(outfile) - $stderr.puts "Sleeper failed: %s" % File.read(outfile) - File.unlink(outfile) - exit(14) - else - exit(0) - end - end - Process.setsid - Dir.chdir("/") - begin - $stdin.reopen "/dev/null" - $stdout.reopen "/dev/null", "a" - $stderr.reopen $stdin - rescue => detail - File.open(outfile, "w") { |f| - f.puts detail - } - exit(12) - end -end -#----------------------------------------------------------------- - -debug = false - -result = GetoptLong.new( - [ "--debug", "-d", GetoptLong::NO_ARGUMENT ], - [ "--help", "-h", GetoptLong::NO_ARGUMENT ] -) - -result.each { |opt,arg| - case opt - when "--help" - puts "There is no help yet" - exit - when "--debug" - debug = true - else - raise "Invalid option '#{opt}'" - end -} - -trap(:INT) { - exit -} - -unless debug - daemonize() -end - -# Sleep for no more than two minutes -sleep 120 -exit diff --git a/ext/root/etc/configfile b/ext/root/etc/configfile deleted file mode 100644 index e69de29bb..000000000 diff --git a/ext/root/etc/debian-passwd b/ext/root/etc/debian-passwd deleted file mode 100644 index 59cdf4acf..000000000 --- a/ext/root/etc/debian-passwd +++ /dev/null @@ -1,29 +0,0 @@ -root:x:0:0:root:/root:/bin/bash -daemon:x:1:1:daemon:/usr/sbin:/bin/sh -bin:x:2:2:bin:/bin:/bin/sh -sys:x:3:3:sys:/dev:/bin/sh -sync:x:4:65534:sync:/bin:/bin/sync -games:x:5:60:games:/usr/games:/bin/sh -man:x:6:12:man:/var/cache/man:/bin/sh -lp:x:7:7:lp:/var/spool/lpd:/bin/sh -mail:x:8:8:mail:/var/mail:/bin/sh -news:x:9:9:news:/var/spool/news:/bin/sh -uucp:x:10:10:uucp:/var/spool/uucp:/bin/sh -proxy:x:13:13:proxy:/bin:/bin/sh -postgres:x:31:32:postgres:/var/lib/postgres:/bin/sh -www-data:x:33:33:www-data:/var/www:/bin/sh -backup:x:34:34:backup:/var/backups:/bin/sh -operator:x:37:37:Operator:/var:/bin/sh -list:x:38:38:Mailing List Manager:/var/list:/bin/sh -irc:x:39:39:ircd:/var/run/ircd:/bin/sh -gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/bin/sh -nobody:x:65534:65534:nobody:/nonexistent:/bin/sh -sshd:x:102:65534::/var/run/sshd:/bin/false -gdm:x:101:101:Gnome Display Manager:/var/lib/gdm:/bin/false -telnetd:x:103:103::/usr/lib/telnetd:/bin/false -nagios:x:1000:1001::/home/nagios: -messagebus:x:104:107::/var/run/dbus:/bin/false -saned:x:109:109::/home/saned:/bin/false -ganglia:x:105:110:Ganglia Monitor:/var/lib/ganglia:/bin/false -zope:x:106:111::/var/lib/zope2.7/var:/bin/false -fbgetty:x:112:112::/home/fbgetty:/bin/false diff --git a/ext/root/etc/debian-syslog.conf b/ext/root/etc/debian-syslog.conf deleted file mode 100644 index 8f2925960..000000000 --- a/ext/root/etc/debian-syslog.conf +++ /dev/null @@ -1,71 +0,0 @@ -# /etc/syslog.conf Configuration file for syslogd. -# -# For more information see syslog.conf(5) -# manpage. - -# -# First some standard logfiles. Log by facility. -# - -auth,authpriv.* /var/log/auth.log -*.*;auth,authpriv.none -/var/log/syslog -#cron.* /var/log/cron.log -daemon.* -/var/log/daemon.log -kern.* -/var/log/kern.log -lpr.* -/var/log/lpr.log -mail.* -/var/log/mail.log -user.* -/var/log/user.log -uucp.* /var/log/uucp.log - -# -# Logging for the mail system. Split it up so that -# it is easy to write scripts to parse these files. -# -mail.info -/var/log/mail.info -mail.warn -/var/log/mail.warn -mail.err /var/log/mail.err - -# Logging for INN news system -# -news.crit /var/log/news/news.crit -news.err /var/log/news/news.err -news.notice -/var/log/news/news.notice - -# -# Some `catch-all' logfiles. -# -*.=debug;\ - auth,authpriv.none;\ - news.none;mail.none -/var/log/debug -*.=info;*.=notice;*.=warn;\ - auth,authpriv.none;\ - cron,daemon.none;\ - mail,news.none -/var/log/messages - -# -# Emergencies are sent to everybody logged in. -# -*.emerg * - -# -# I like to have messages displayed on the console, but only on a virtual -# console I usually leave idle. -# -#daemon,mail.*;\ -# news.=crit;news.=err;news.=notice;\ -# *.=debug;*.=info;\ -# *.=notice;*.=warn /dev/tty8 - -# The named pipe /dev/xconsole is for the `xconsole' utility. To use it, -# you must invoke `xconsole' with the `-file' option: -# -# $ xconsole -file /dev/xconsole [...] -# -# NOTE: adjust the list below, or you'll go crazy if you have a reasonably -# busy site.. -# -daemon.*;mail.*;\ - news.crit;news.err;news.notice;\ - *.=debug;*.=info;\ - *.=notice;*.=warn |/dev/xconsole - diff --git a/ext/root/etc/init.d/sleeper b/ext/root/etc/init.d/sleeper deleted file mode 100755 index 6da5eae32..000000000 --- a/ext/root/etc/init.d/sleeper +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash - -# $Id$ - -script=$0 -path=`echo $script | sed 's/etc..*/bin/'` - -PATH=$PATH:$path - -ps=`facter ps` - -if [ -z "$ps" ]; then - ps="ps -ef" -fi - -function start -{ - cd $path - ./sleeper -} - -function stop -{ - #if [ -n `which pgrep` ]; then - # pid=`pgrep sleeper` - #else - pid=`$ps | grep -v grep | grep sleeper | grep ruby | awk '{print $2}'` - #fi - if [ -n "$pid" ]; then - kill $pid - fi -} - -function restart -{ - stop - start -} - -function status -{ - #if [ -n `which pgrep` ]; then - # cmd="pgrep sleeper" - #else - #cmd="$ps | grep -v grep | grep sleeper | grep ruby | awk '{print $2}'" - #fi - #$cmd - $ps | grep -v grep | grep sleeper | grep ruby -} - -case "$1" in - start) - start - ;; - stop) - stop - ;; - restart) - stop; start - ;; - status) - output=`status` - #status - exit $? - ;; - *) - echo "Usage: $N {start|stop|restart|force-reload}" >&2 - exit 1 - ;; -esac - -exit 0 diff --git a/ext/root/etc/otherfile b/ext/root/etc/otherfile deleted file mode 100644 index e69de29bb..000000000 diff --git a/ext/root/etc/puppet/fileserver.conf b/ext/root/etc/puppet/fileserver.conf deleted file mode 100644 index 32dfcdd5c..000000000 --- a/ext/root/etc/puppet/fileserver.conf +++ /dev/null @@ -1,13 +0,0 @@ -# $Id$ - -[dist] - path /dist - allow *.madstop.com - -[plugins] - path /var/puppet/plugins - allow *.madstop.com - -[facts] - path /var/puppet/facts - allow *.madstop.com diff --git a/ext/root/etc/puppet/namespaceauth.conf b/ext/root/etc/puppet/namespaceauth.conf deleted file mode 100644 index fb08d428b..000000000 --- a/ext/root/etc/puppet/namespaceauth.conf +++ /dev/null @@ -1,20 +0,0 @@ -# This file is only necessary if your clients listen. -# Note that it affects all puppet daemons, including puppetmasterd, -# which is why puppetmaster is in there. -[fileserver] - allow *.madstop.com - -[puppetmaster] - allow *.madstop.com - -[pelementserver] - allow puppet.madstop.com - -[puppetrunner] - allow culain.madstop.com - -[puppetbucket] - allow *.madstop.com - -[puppetreports] - allow *.madstop.com diff --git a/ext/root/etc/puppet/puppet.conf b/ext/root/etc/puppet/puppet.conf deleted file mode 100644 index 151364ebd..000000000 --- a/ext/root/etc/puppet/puppet.conf +++ /dev/null @@ -1,10 +0,0 @@ -[puppetd] -report = true -factsync = true -pluginsync = true - -[puppetmasterd] -reports = store,rrdgraph,tagmail,log -node_terminus = ldap -ldapserver = culain.madstop.com -ldapbase = dc=madstop,dc=com diff --git a/ext/root/etc/puppet/tagmail.conf b/ext/root/etc/puppet/tagmail.conf deleted file mode 100644 index 31c77f4bc..000000000 --- a/ext/root/etc/puppet/tagmail.conf +++ /dev/null @@ -1 +0,0 @@ -all: user@domain.com -- cgit From 61b9bcd26fe39502d0de1f876a8293e54f63b1c7 Mon Sep 17 00:00:00 2001 From: James Turnbull Date: Wed, 16 Jul 2008 10:31:36 +1000 Subject: Added Changelog entry for new auth_key type --- CHANGELOG | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index a3d96323d..8903c9e58 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,7 @@ 0.24.5 + Fixed #174 - a native type type for managing ssh authorized_keys + files is available. + Further moves from the examples directory and ext directory Fixed #1397 One line fix, fail instead of log -- cgit From 0a0fcafa3e2405aa18ecc62d1e6dc69bbd9883a1 Mon Sep 17 00:00:00 2001 From: James Turnbull Date: Thu, 17 Jul 2008 11:05:01 +1000 Subject: Fixed #1414 - Return code from waitpid now right shifted 8 bits --- CHANGELOG | 2 ++ lib/puppet/util.rb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 8903c9e58..9af050dd2 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,6 @@ 0.24.5 + Fixed #1414 - Return code from waitpid now right shifted 8 bits + Fixed #174 - a native type type for managing ssh authorized_keys files is available. diff --git a/lib/puppet/util.rb b/lib/puppet/util.rb index 560afe10b..94c96db0c 100644 --- a/lib/puppet/util.rb +++ b/lib/puppet/util.rb @@ -313,7 +313,7 @@ module Util $VERBOSE = oldverb if child_pid # Parent process executes this - child_status = Process.waitpid2(child_pid)[1] + child_status = (Process.waitpid2(child_pid)[1]).to_i >> 8 else # Child process executes this Process.setsid -- cgit From de6aec6e37edb9c575f9223686da03cea4063ad7 Mon Sep 17 00:00:00 2001 From: James Turnbull Date: Thu, 17 Jul 2008 11:12:35 +1000 Subject: Fix Ticket 1426 - services on redhat are restarted again as far I see there have been a regression while refactoring the redhat service provider to user /sbin/service. This commit fixes this bug (1426) and service restarts are working again on redhat based systems. There are no tests, as I couldn't figure out how that should be tested. It seems that some restart logic is already tested, however it looks like not every single kind of provider is covered by tests, nor I see at the moment how I could do that. --- CHANGELOG | 3 +++ lib/puppet/provider/service/redhat.rb | 12 ++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 9af050dd2..0cb38e4fd 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,7 @@ 0.24.5 + Fix #1426 - services on redhat are restarted again and status is + called from the Red Hat provider + Fixed #1414 - Return code from waitpid now right shifted 8 bits Fixed #174 - a native type type for managing ssh authorized_keys diff --git a/lib/puppet/provider/service/redhat.rb b/lib/puppet/provider/service/redhat.rb index e2d6ac947..48da577ec 100755 --- a/lib/puppet/provider/service/redhat.rb +++ b/lib/puppet/provider/service/redhat.rb @@ -50,10 +50,18 @@ Puppet::Type.type(:service).provide :redhat, :parent => :init do end def restart - if @resource[:hasrestart] == true + if @resource[:hasrestart] == :true service(@resource[:name], "restart") else - return false + super + end + end + + def status + if @resource[:hasstatus] == :true + service(@resource[:name], "status") + else + super end end -- cgit From bdbd992a6f5ff9628682179639923214d09a780c Mon Sep 17 00:00:00 2001 From: James Turnbull Date: Thu, 17 Jul 2008 13:08:15 +1000 Subject: Updated /spec/unit/rails.rb test --- CHANGELOG | 2 ++ spec/unit/rails.rb | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 0cb38e4fd..383621c0e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,6 @@ 0.24.5 + Updated /spec/unit/rails.rb test + Fix #1426 - services on redhat are restarted again and status is called from the Red Hat provider diff --git a/spec/unit/rails.rb b/spec/unit/rails.rb index bb2f991ca..382f7c0f4 100755 --- a/spec/unit/rails.rb +++ b/spec/unit/rails.rb @@ -4,7 +4,7 @@ require File.dirname(__FILE__) + '/../spec_helper' require 'puppet/rails' describe Puppet::Rails, "when initializing any connection" do - confine Puppet.features.rails? => "Cannot test without ActiveRecord" + confine "Cannot test without ActiveRecord" => Puppet.features.rails? before do @logger = mock 'logger' -- cgit From 7fa7251e30dfefc95dda6ef82181d4346f36880d Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Wed, 16 Jul 2008 22:00:38 -0500 Subject: The mongrel-related tests now run without mongrel. Here were the main changes necessary: * Fixed the class loader so it only loads mongrel if it's available. * Fixed the test runner to skip example groups contained in non-runnable example groups. * Fixed the Mongrel tests to use quoted class names instead of constants, since the constants themselves would be absent. Signed-off-by: Luke Kanies --- lib/puppet/network/http.rb | 14 ++++++++------ spec/integration/indirector/rest.rb | 4 ++-- spec/unit/network/http.rb | 12 +++++++++--- spec/unit/network/http/mongrel.rb | 6 +++--- spec/unit/network/http/mongrel/rest.rb | 16 ++++++++++++++-- spec/unit/network/http/webrick.rb | 1 + spec/unit/network/http/webrick/rest.rb | 1 + test/lib/puppettest/runnable_test.rb | 3 +++ 8 files changed, 41 insertions(+), 16 deletions(-) diff --git a/lib/puppet/network/http.rb b/lib/puppet/network/http.rb index 062c67c71..c219859b6 100644 --- a/lib/puppet/network/http.rb +++ b/lib/puppet/network/http.rb @@ -1,13 +1,15 @@ class Puppet::Network::HTTP def self.server_class_by_type(kind) - return Puppet::Network::HTTP::WEBrick if kind.to_sym == :webrick - if kind.to_sym == :mongrel + case kind.to_sym + when :webrick: + require 'puppet/network/http/webrick' + return Puppet::Network::HTTP::WEBrick + when :mongrel: raise ArgumentError, "Mongrel is not installed on this platform" unless Puppet.features.mongrel? + require 'puppet/network/http/mongrel' return Puppet::Network::HTTP::Mongrel + else + raise ArgumentError, "Unknown HTTP server name [#{kind}]" end - raise ArgumentError, "Unknown HTTP server name [#{kind}]" end end - -require 'puppet/network/http/webrick' -require 'puppet/network/http/mongrel' diff --git a/spec/integration/indirector/rest.rb b/spec/integration/indirector/rest.rb index 7edd0b865..9efcdcbd3 100755 --- a/spec/integration/indirector/rest.rb +++ b/spec/integration/indirector/rest.rb @@ -118,7 +118,7 @@ describe Puppet::Indirector::REST do end it 'should return the instance of the model class associated with the provided lookup key' do - Puppet::TestIndirectedFoo.search('bar').collect(&:value).should == @model_instances.collect(&:value) + Puppet::TestIndirectedFoo.search('bar').collect { |i| i.value }.should == @model_instances.collect { |i| i.value } end it 'should set a version timestamp on model instances' do @@ -334,7 +334,7 @@ describe Puppet::Indirector::REST do end it 'should return the instance of the model class associated with the provided lookup key' do - Puppet::TestIndirectedFoo.search('bar').collect(&:value).should == @model_instances.collect(&:value) + Puppet::TestIndirectedFoo.search('bar').collect { |i| i.value }.should == @model_instances.collect { |i| i.value } end it 'should set an expiration on model instances' do diff --git a/spec/unit/network/http.rb b/spec/unit/network/http.rb index 79a0a88d4..1fa025b0b 100755 --- a/spec/unit/network/http.rb +++ b/spec/unit/network/http.rb @@ -12,9 +12,15 @@ describe Puppet::Network::HTTP do Puppet::Network::HTTP.server_class_by_type(:webrick).should be(Puppet::Network::HTTP::WEBrick) end - if Puppet.features.mongrel? - it "should return the mongrel HTTP server class when asked for a mongrel server" do - Puppet::Network::HTTP.server_class_by_type(:mongrel).should be(Puppet::Network::HTTP::Mongrel) + describe "when asked for a mongrel server" do + if Puppet.features.mongrel? + it "should return the mongrel server class" do + Puppet::Network::HTTP.server_class_by_type(:mongrel).should be(Puppet::Network::HTTP::Mongrel) + end + else + it "should fail" do + lambda { Puppet::Network::HTTP.server_class_by_type(:mongrel) }.should raise_error(ArgumentError) + end end end diff --git a/spec/unit/network/http/mongrel.rb b/spec/unit/network/http/mongrel.rb index ccfca2f55..3a9cfb52f 100755 --- a/spec/unit/network/http/mongrel.rb +++ b/spec/unit/network/http/mongrel.rb @@ -6,7 +6,7 @@ require File.dirname(__FILE__) + '/../../../spec_helper' require 'puppet/network/http' -describe Puppet::Network::HTTP::Mongrel, "after initializing" do +describe "Puppet::Network::HTTP::Mongrel", "after initializing" do confine "Mongrel is not available" => Puppet.features.mongrel? it "should not be listening" do @@ -14,7 +14,7 @@ describe Puppet::Network::HTTP::Mongrel, "after initializing" do end end -describe Puppet::Network::HTTP::Mongrel, "when turning on listening" do +describe "Puppet::Network::HTTP::Mongrel", "when turning on listening" do confine "Mongrel is not available" => Puppet.features.mongrel? before do @@ -82,7 +82,7 @@ describe Puppet::Network::HTTP::Mongrel, "when turning on listening" do end end -describe Puppet::Network::HTTP::Mongrel, "when turning off listening" do +describe "Puppet::Network::HTTP::Mongrel", "when turning off listening" do confine "Mongrel is not available" => Puppet.features.mongrel? before do diff --git a/spec/unit/network/http/mongrel/rest.rb b/spec/unit/network/http/mongrel/rest.rb index 3df925133..de5254a7a 100755 --- a/spec/unit/network/http/mongrel/rest.rb +++ b/spec/unit/network/http/mongrel/rest.rb @@ -3,10 +3,12 @@ require File.dirname(__FILE__) + '/../../../../spec_helper' require 'puppet/network/http' -describe Puppet::Network::HTTP::MongrelREST, "when initializing" do +describe "Puppet::Network::HTTP::MongrelREST", "when initializing" do confine "Mongrel is not available" => Puppet.features.mongrel? before do + require 'puppet/network/http/mongrel/rest' + @mock_mongrel = mock('Mongrel server') @mock_mongrel.stubs(:register) @mock_model = mock('indirected model') @@ -33,7 +35,7 @@ describe Puppet::Network::HTTP::MongrelREST, "when initializing" do end end -describe Puppet::Network::HTTP::MongrelREST, "when receiving a request" do +describe "Puppet::Network::HTTP::MongrelREST", "when receiving a request" do confine "Mongrel is not available" => Puppet.features.mongrel? before do @@ -131,6 +133,8 @@ describe Puppet::Network::HTTP::MongrelREST, "when receiving a request" do end describe "and determining the request parameters", :shared => true do + confine "Mongrel is not available" => Puppet.features.mongrel? + before do @mock_request.stubs(:params).returns({}) end @@ -198,6 +202,8 @@ describe Puppet::Network::HTTP::MongrelREST, "when receiving a request" do end describe "when finding a model instance" do |variable| + confine "Mongrel is not available" => Puppet.features.mongrel? + it "should fail to find model if key is not specified" do @mock_request.stubs(:params).returns({ Mongrel::Const::REQUEST_METHOD => 'GET', Mongrel::Const::REQUEST_PATH => '/foo'}) @mock_response.expects(:start).with(404) @@ -236,6 +242,8 @@ describe Puppet::Network::HTTP::MongrelREST, "when receiving a request" do end describe "when destroying a model instance" do |variable| + confine "Mongrel is not available" => Puppet.features.mongrel? + it "should fail to destroy model if key is not specified" do @mock_request.stubs(:params).returns({ Mongrel::Const::REQUEST_METHOD => 'DELETE', Mongrel::Const::REQUEST_PATH => '/foo'}) @mock_response.expects(:start).with(404) @@ -281,6 +289,8 @@ describe Puppet::Network::HTTP::MongrelREST, "when receiving a request" do end describe "when saving a model instance" do |variable| + confine "Mongrel is not available" => Puppet.features.mongrel? + it "should fail to save model if data is not specified" do @mock_request.stubs(:params).returns({ Mongrel::Const::REQUEST_METHOD => 'PUT', Mongrel::Const::REQUEST_PATH => '/foo'}) @mock_request.stubs(:body).returns('') @@ -319,6 +329,8 @@ describe Puppet::Network::HTTP::MongrelREST, "when receiving a request" do end describe "when searching for model instances" do |variable| + confine "Mongrel is not available" => Puppet.features.mongrel? + it "should use a common method for determining the request parameters" do setup_search_request('QUERY_STRING' => 'foo=baz&bar=xyzzy') @handler.expects(:params).returns(:foo => :baz, :bar => :xyzzy) diff --git a/spec/unit/network/http/webrick.rb b/spec/unit/network/http/webrick.rb index 78bd39145..9b024ae31 100755 --- a/spec/unit/network/http/webrick.rb +++ b/spec/unit/network/http/webrick.rb @@ -5,6 +5,7 @@ require File.dirname(__FILE__) + '/../../../spec_helper' require 'puppet/network/http' +require 'puppet/network/http/webrick' describe Puppet::Network::HTTP::WEBrick, "after initializing" do it "should not be listening" do diff --git a/spec/unit/network/http/webrick/rest.rb b/spec/unit/network/http/webrick/rest.rb index 45e5f0bd2..17d47e54c 100755 --- a/spec/unit/network/http/webrick/rest.rb +++ b/spec/unit/network/http/webrick/rest.rb @@ -2,6 +2,7 @@ require File.dirname(__FILE__) + '/../../../../spec_helper' require 'puppet/network/http' +require 'puppet/network/http/webrick/rest' describe Puppet::Network::HTTP::WEBrickREST, "when initializing" do before do diff --git a/test/lib/puppettest/runnable_test.rb b/test/lib/puppettest/runnable_test.rb index e4b0f9033..e3cde5052 100644 --- a/test/lib/puppettest/runnable_test.rb +++ b/test/lib/puppettest/runnable_test.rb @@ -15,6 +15,9 @@ module PuppetTest # Evaluate all of our tests to see if any of them are false # and thus whether this test is considered not runnable. def runnable? + if superclass.respond_to?(:runnable?) and ! superclass.runnable? + return false + end @messages ||= [] return false unless @messages.empty? return true unless defined? @confines -- cgit From 8f8ce60819b8c4b3c6609fd9cc485f8322561469 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Thu, 17 Jul 2008 12:30:33 -0500 Subject: Fixed #1431 - Provider confines must now specify similar tests in one call. I.e., you can't do confine :operatingsystem => %w{a b} and then confine :operatingsystem => %w{b c}; you'd need to do them in one command. This now-obsolete behaviour does not seem to be used anywhere. The fix for #1431 is actually just removing the tests that exposed this change; the change happened when I refactored how confines work. Signed-off-by: Luke Kanies --- CHANGELOG | 7 +++++++ test/other/provider.rb | 45 --------------------------------------------- 2 files changed, 7 insertions(+), 45 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 383621c0e..baa693d67 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,11 @@ 0.24.5 + Fixed #1431 - Provider confines must now specify similar tests in one call. + I.e., you can't do confine :operatingsystem => %w{a b} and then + confine :operatingsystem => %w{b c}; you'd need to do them in one command. + This now-obsolete behaviour does not seem to be used anywhere. + The fix for #1431 is actually just removing the tests that exposed + this change; the change happened when I refactored how confines work. + Updated /spec/unit/rails.rb test Fix #1426 - services on redhat are restarted again and status is diff --git a/test/other/provider.rb b/test/other/provider.rb index 3e4ad83d6..b0860f634 100755 --- a/test/other/provider.rb +++ b/test/other/provider.rb @@ -48,51 +48,6 @@ class TestImpl < Test::Unit::TestCase end - def test_provider_false_confine - assert_nothing_raised do - @provider.confine :false => false - end - - assert(@provider.suitable?, "False did not check correctly") - end - - def test_provider_true_confine - assert_nothing_raised do - @provider.confine :true => true - end - - assert(@provider.suitable?, "True did not check correctly") - - # Now check whether we multiple true things work - assert_nothing_raised do - @provider.confine :true => false - @provider.confine :true => true - end - assert(! @provider.suitable?, "One truth overrode another") - end - - def test_provider_exists_confine - file = tempfile() - - assert_nothing_raised do - @provider.confine :exists => file - end - - assert(! @provider.suitable?, "Exists did not check correctly") - File.open(file, "w") { |f| f.puts "" } - assert(@provider.suitable?, "Exists did not find file correctly") - end - - def test_provider_facts_confine - # Now check for multiple platforms - assert_nothing_raised do - @provider.confine :operatingsystem => [Facter["operatingsystem"].value, :yayos] - @provider.confine :operatingsystem => [:fakeos, :otheros] - end - - assert(@provider.suitable?, "Implementation not considered suitable") - end - def test_provider_default nondef = nil assert_nothing_raised { -- cgit From a0fa09f6ee562dd1b61fe56dd4b914419d641986 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Fri, 18 Jul 2008 00:12:01 -0500 Subject: Revert "Fixed #1201 - all external node attributes are converted to strings." This reverts commit ac7f59618a80b6a4aac777f6184e7fa6a0614079. The reason for this revert is that the problem never really existed; Ruby's true and false are always used unless you quote them. --- CHANGELOG | 2 -- lib/puppet/indirector/node/exec.rb | 7 ------- spec/unit/indirector/node/exec.rb | 6 ------ 3 files changed, 15 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index baa693d67..13edbede9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -77,8 +77,6 @@ but external nodes just use the certificate name and any custom terminus types will use just the certificate name. - Fixed #1201 - all external node attributes are converted to strings. - Fixing #1168 (for 0.24.x) -- automatically downcasing the fqdn. Also requiring that passed in certnames be downcased; the setting system isn't currently flexible enough to automatically downcase diff --git a/lib/puppet/indirector/node/exec.rb b/lib/puppet/indirector/node/exec.rb index 029a35c4f..52cbc370c 100644 --- a/lib/puppet/indirector/node/exec.rb +++ b/lib/puppet/indirector/node/exec.rb @@ -30,13 +30,6 @@ class Puppet::Node::Exec < Puppet::Indirector::Exec def create_node(name, result) node = Puppet::Node.new(name) set = false - if current = result[:parameters] - result[:parameters] = current.inject({}) do |strings, ary| - param, value = ary - strings[param] = value.to_s - strings - end - end [:parameters, :classes, :environment].each do |param| if value = result[param] node.send(param.to_s + "=", value) diff --git a/spec/unit/indirector/node/exec.rb b/spec/unit/indirector/node/exec.rb index 2276e4298..09f13ab90 100755 --- a/spec/unit/indirector/node/exec.rb +++ b/spec/unit/indirector/node/exec.rb @@ -49,12 +49,6 @@ describe Puppet::Node::Exec do @searcher.find(@request) end - it "should convert all parameters into strings" do - @result[:parameters] = {"a" => true, "c" => 100} - @node.expects(:parameters=).with "a" => "true", "c" => "100" - @searcher.find(@request) - end - it "should set the resulting classes as the node classes" do @result[:classes] = %w{one two} @node.expects(:classes=).with %w{one two} -- cgit From d8937acb8c9b108e61330cbac703a17b2eaba9b3 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Fri, 18 Jul 2008 00:54:59 -0500 Subject: You can now select the encoding format when transferring the catalog, with 'yaml' still being the default but 'marshal' being an option. This is because testing has shown drastic performance differences between the two, with up to 70% of compile time being spent in YAML code. Use the 'catalog_format' setting to choose your format, and the setting must be set on the client. Signed-off-by: Luke Kanies --- CHANGELOG | 7 +++ lib/puppet/defaults.rb | 5 +- lib/puppet/network/client/master.rb | 15 ++++-- lib/puppet/network/handler/master.rb | 14 +++--- spec/integration/defaults.rb | 4 ++ spec/unit/network/client/master.rb | 96 +++++++++++++++++++++++++++++------- test/network/handler/master.rb | 34 +++++++++++++ 7 files changed, 144 insertions(+), 31 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 13edbede9..9004cf619 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,11 @@ 0.24.5 + You can now select the encoding format when transferring the catalog, + with 'yaml' still being the default but 'marshal' being an option. + This is because testing has shown drastic performance differences + between the two, with up to 70% of compile time being spent + in YAML code. Use the 'catalog_format' setting to choose your format, + and the setting must be set on the client. + Fixed #1431 - Provider confines must now specify similar tests in one call. I.e., you can't do confine :operatingsystem => %w{a b} and then confine :operatingsystem => %w{b c}; you'd need to do them in one command. diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb index 5f71bb8b7..87ccd62f6 100644 --- a/lib/puppet/defaults.rb +++ b/lib/puppet/defaults.rb @@ -416,7 +416,10 @@ module Puppet :ca_server => ["$server", "The server to use for certificate authority requests. It's a separate server because it cannot and does not need to horizontally scale."], - :ca_port => ["$masterport", "The port to use for the certificate authority."] + :ca_port => ["$masterport", "The port to use for the certificate authority."], + :catalog_format => ["yaml", "What format to use to dump the catalog. Only supports + 'marshal' and 'yaml'. Only matters on the client, since it asks the server + for a specific format."] ) self.setdefaults(:filebucket, diff --git a/lib/puppet/network/client/master.rb b/lib/puppet/network/client/master.rb index 0de3a117b..2da6cf890 100644 --- a/lib/puppet/network/client/master.rb +++ b/lib/puppet/network/client/master.rb @@ -143,15 +143,20 @@ class Puppet::Network::Client::Master < Puppet::Network::Client # If we can't retrieve the catalog, just return, which will either # fail, or use the in-memory catalog. - unless yaml_objects = get_actual_config(facts) + unless marshalled_objects = get_actual_config(facts) use_cached_config(true) return end begin - objects = YAML.load(yaml_objects) + case Puppet[:catalog_format] + when "marshal": objects = Marshal.load(marshalled_objects) + when "yaml": objects = YAML.load(marshalled_objects) + else + raise "Invalid catalog format '%s'" % Puppet[:catalog_format] + end rescue => detail - msg = "Configuration could not be translated from yaml" + msg = "Configuration could not be translated from %s" % Puppet[:catalog_format] msg += "; using cached catalog" if use_cached_config(true) Puppet.warning msg return @@ -175,7 +180,7 @@ class Puppet::Network::Client::Master < Puppet::Network::Client end if ! @catalog.from_cache - self.cache(yaml_objects) + self.cache(marshalled_objects) end # Keep the state database up to date. @@ -442,7 +447,7 @@ class Puppet::Network::Client::Master < Puppet::Network::Client benchmark(:debug, "Retrieved catalog") do # error handling for this is done in the network client begin - textobjects = @driver.getconfig(textfacts, "yaml") + textobjects = @driver.getconfig(textfacts, Puppet[:catalog_format]) begin textobjects = CGI.unescape(textobjects) rescue => detail diff --git a/lib/puppet/network/handler/master.rb b/lib/puppet/network/handler/master.rb index a050b089b..9682c460e 100644 --- a/lib/puppet/network/handler/master.rb +++ b/lib/puppet/network/handler/master.rb @@ -64,7 +64,14 @@ class Puppet::Network::Handler catalog = Puppet::Node::Catalog.find(client) - return translate(catalog.extract) + case format + when "yaml": + return CGI.escape(catalog.extract.to_yaml(:UseBlock => true)) + when "marshal": + return CGI.escape(Marshal.dump(catalog.extract)) + else + raise "Invalid markup format '%s'" % format + end end # @@ -90,11 +97,6 @@ class Puppet::Network::Handler # Translate our configuration appropriately for sending back to a client. def translate(config) - if local? - config - else - CGI.escape(config.to_yaml(:UseBlock => true)) - end end end end diff --git a/spec/integration/defaults.rb b/spec/integration/defaults.rb index c506700c8..54b673a1a 100755 --- a/spec/integration/defaults.rb +++ b/spec/integration/defaults.rb @@ -40,4 +40,8 @@ describe "Puppet defaults" do Puppet.settings.element(:rundir).owner.should be_nil Puppet.settings.element(:rundir).group.should be_nil end + + it "should default to yaml as the catalog format" do + Puppet.settings[:catalog_format].should == "yaml" + end end diff --git a/spec/unit/network/client/master.rb b/spec/unit/network/client/master.rb index 79ab8c86f..754fd0583 100755 --- a/spec/unit/network/client/master.rb +++ b/spec/unit/network/client/master.rb @@ -59,34 +59,92 @@ describe Puppet::Network::Client::Master, " when retrieving the catalog" do @client.getconfig end - it "should load the retrieved catalog using YAML" do - @client.stubs(:dostorage) - @client.class.stubs(:facts).returns(@facts) - @master.stubs(:getconfig).returns("myconfig") + describe "when the catalog format is set to yaml" do + before do + Puppet.settings.stubs(:value).returns "foo" + Puppet.settings.stubs(:value).with(:pluginsync).returns false + Puppet.settings.stubs(:value).with(:configtimeout).returns 10 + Puppet.settings.stubs(:value).with(:factsync).returns false + Puppet.settings.stubs(:value).with(:catalog_format).returns "yaml" + end - config = mock 'config' - YAML.expects(:load).with("myconfig").returns(config) + it "should request a yaml-encoded catalog" do + @client.stubs(:dostorage) + @client.class.stubs(:facts).returns(@facts) + @master.expects(:getconfig).with { |*args| args[1] == "yaml" } - @client.stubs(:setclasses) + @client.getconfig + end - config.stubs(:classes) - config.stubs(:to_catalog).returns(config) - config.stubs(:host_config=) - config.stubs(:from_cache).returns(true) + it "should load the retrieved catalog using YAML" do + @client.stubs(:dostorage) + @client.class.stubs(:facts).returns(@facts) + @master.stubs(:getconfig).returns("myconfig") - @client.getconfig + config = mock 'config' + YAML.expects(:load).with("myconfig").returns(config) + + @client.stubs(:setclasses) + + config.stubs(:classes) + config.stubs(:to_catalog).returns(config) + config.stubs(:host_config=) + config.stubs(:from_cache).returns(true) + + @client.getconfig + end + + it "should use the cached catalog if the retrieved catalog cannot be converted from YAML" do + @client.stubs(:dostorage) + @client.class.stubs(:facts).returns(@facts) + @master.stubs(:getconfig).returns("myconfig") + + YAML.expects(:load).with("myconfig").raises(ArgumentError) + + @client.expects(:use_cached_config).with(true) + + @client.getconfig + end end - it "should use the cached catalog if the retrieved catalog cannot be converted from YAML" do - @client.stubs(:dostorage) - @client.class.stubs(:facts).returns(@facts) - @master.stubs(:getconfig).returns("myconfig") + describe "from Marshal" do + before do + Puppet.settings.stubs(:value).returns "foo" + Puppet.settings.stubs(:value).with(:pluginsync).returns false + Puppet.settings.stubs(:value).with(:configtimeout).returns 10 + Puppet.settings.stubs(:value).with(:factsync).returns false + Puppet.settings.stubs(:value).with(:catalog_format).returns "marshal" + end - YAML.expects(:load).with("myconfig").raises(ArgumentError) + it "should load the retrieved catalog using Marshal" do + @client.stubs(:dostorage) + @client.class.stubs(:facts).returns(@facts) + @master.stubs(:getconfig).returns("myconfig") - @client.expects(:use_cached_config).with(true) + config = mock 'config' + Marshal.expects(:load).with("myconfig").returns(config) - @client.getconfig + @client.stubs(:setclasses) + + config.stubs(:classes) + config.stubs(:to_catalog).returns(config) + config.stubs(:host_config=) + config.stubs(:from_cache).returns(true) + + @client.getconfig + end + + it "should use the cached catalog if the retrieved catalog cannot be converted from Marshal" do + @client.stubs(:dostorage) + @client.class.stubs(:facts).returns(@facts) + @master.stubs(:getconfig).returns("myconfig") + + Marshal.expects(:load).with("myconfig").raises(ArgumentError) + + @client.expects(:use_cached_config).with(true) + + @client.getconfig + end end it "should set the classes.txt file with the classes listed in the retrieved catalog" do diff --git a/test/network/handler/master.rb b/test/network/handler/master.rb index 448667b73..d342af88c 100755 --- a/test/network/handler/master.rb +++ b/test/network/handler/master.rb @@ -56,3 +56,37 @@ class TestMaster < Test::Unit::TestCase @master.getconfig("facts", "yaml", "foo.com") end end + +class TestMasterFormats < Test::Unit::TestCase + def setup + @facts = stub('facts', :save => nil) + Puppet::Node::Facts.stubs(:new).returns(@facts) + + @master = Puppet::Network::Handler.master.new(:Code => "") + @master.stubs(:decode_facts) + + @catalog = stub 'catalog', :extract => "" + Puppet::Node::Catalog.stubs(:find).returns(@catalog) + end + + def test_marshal_can_be_used + @catalog.expects(:extract).returns "myextract" + + Marshal.expects(:dump).with("myextract").returns "eh" + + @master.getconfig("facts", "marshal", "foo.com") + end + + def test_yaml_can_be_used + extract = mock 'extract' + @catalog.expects(:extract).returns extract + + extract.expects(:to_yaml).returns "myaml" + + @master.getconfig("facts", "yaml", "foo.com") + end + + def test_failure_when_non_yaml_or_marshal_is_used + assert_raise(RuntimeError) { @master.getconfig("facts", "blah", "foo.com") } + end +end -- cgit From ebb219e496682862ac98d382afe014cf1c763f2f Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Fri, 18 Jul 2008 17:51:25 -0500 Subject: Fixed all of the fileserving termini so they use indirection requests. This looks like a much larger commit than it is -- it doesn't change any behaviour at all, it just adds some integration tests (which expose the problem) and then switches from an ad-hoc api to a request-based api. Signed-off-by: Luke Kanies --- lib/puppet/file_serving/terminus_helper.rb | 8 +- lib/puppet/indirector/direct_file_server.rb | 2 +- lib/puppet/indirector/file_server.rb | 28 +++---- lib/puppet/indirector/module_files.rb | 28 +++---- spec/integration/file_serving/metadata.rb | 1 - spec/integration/indirector/module_files.rb | 8 +- spec/shared_behaviours/file_server_terminus.rb | 4 +- spec/shared_behaviours/file_serving.rb | 22 ++++-- spec/unit/file_serving/terminus_helper.rb | 94 +++++++++++----------- spec/unit/indirector/direct_file_server.rb | 13 +--- spec/unit/indirector/file_metadata/modules.rb | 6 +- spec/unit/indirector/file_server.rb | 104 ++++++++++++++----------- spec/unit/indirector/module_files.rb | 86 +++++++++++--------- 13 files changed, 221 insertions(+), 183 deletions(-) diff --git a/lib/puppet/file_serving/terminus_helper.rb b/lib/puppet/file_serving/terminus_helper.rb index d465aa493..e5da0e29f 100644 --- a/lib/puppet/file_serving/terminus_helper.rb +++ b/lib/puppet/file_serving/terminus_helper.rb @@ -8,11 +8,11 @@ require 'puppet/file_serving/fileset' # Define some common methods for FileServing termini. module Puppet::FileServing::TerminusHelper # Create model instances for all files in a fileset. - def path2instances(key, path, options = {}) - args = [:links, :ignore, :recurse].inject({}) { |hash, param| hash[param] = options[param] if options[param]; hash } + def path2instances(request, path) + args = [:links, :ignore, :recurse].inject({}) { |hash, param| hash[param] = request.options[param] if request.options[param]; hash } Puppet::FileServing::Fileset.new(path, args).files.collect do |file| - inst = model.new(File.join(key, file), :path => path, :relative_path => file) - inst.links = options[:links] if options[:links] + inst = model.new(File.join(request.key, file), :path => path, :relative_path => file) + inst.links = request.options[:links] if request.options[:links] inst end end diff --git a/lib/puppet/indirector/direct_file_server.rb b/lib/puppet/indirector/direct_file_server.rb index 1711356f9..b3b4886f3 100644 --- a/lib/puppet/indirector/direct_file_server.rb +++ b/lib/puppet/indirector/direct_file_server.rb @@ -22,6 +22,6 @@ class Puppet::Indirector::DirectFileServer < Puppet::Indirector::Terminus def search(request) uri = key2uri(request.key) return nil unless FileTest.exists?(uri.path) - path2instances(request.key, uri.path, request.options) + path2instances(request, uri.path) end end diff --git a/lib/puppet/indirector/file_server.rb b/lib/puppet/indirector/file_server.rb index 2eb323d46..b0df7ff5d 100644 --- a/lib/puppet/indirector/file_server.rb +++ b/lib/puppet/indirector/file_server.rb @@ -14,28 +14,28 @@ class Puppet::Indirector::FileServer < Puppet::Indirector::Terminus include Puppet::FileServing::TerminusHelper # Is the client authorized to perform this action? - def authorized?(method, key, options = {}) - return false unless [:find, :search].include?(method) + def authorized?(request) + return false unless [:find, :search].include?(request.method) - uri = key2uri(key) + uri = key2uri(request.key) - configuration.authorized?(uri.path, :node => options[:node], :ipaddress => options[:ipaddress]) + configuration.authorized?(uri.path, :node => request.node, :ipaddress => request.ip) end # Find our key using the fileserver. - def find(key, options = {}) - return nil unless path = find_path(key, options) - result = model.new(key, :path => path) - result.links = options[:links] if options[:links] + def find(request) + return nil unless path = find_path(request) + result = model.new(request.key, :path => path) + result.links = request.options[:links] if request.options[:links] return result end # Search for files. This returns an array rather than a single # file. - def search(key, options = {}) - return nil unless path = find_path(key, options) + def search(request) + return nil unless path = find_path(request) - path2instances(key, path, options) + path2instances(request, path) end private @@ -46,10 +46,10 @@ class Puppet::Indirector::FileServer < Puppet::Indirector::Terminus end # Find our path; used by :find and :search. - def find_path(key, options) - uri = key2uri(key) + def find_path(request) + uri = key2uri(request.key) - return nil unless path = configuration.file_path(uri.path, :node => options[:node]) + return nil unless path = configuration.file_path(uri.path, :node => request.node) return path end diff --git a/lib/puppet/indirector/module_files.rb b/lib/puppet/indirector/module_files.rb index 84286d8a5..cf5c29cab 100644 --- a/lib/puppet/indirector/module_files.rb +++ b/lib/puppet/indirector/module_files.rb @@ -14,24 +14,24 @@ class Puppet::Indirector::ModuleFiles < Puppet::Indirector::Terminus include Puppet::FileServing::TerminusHelper # Is the client allowed access to this key with this method? - def authorized?(method, key, options = {}) - return false unless [:find, :search].include?(method) + def authorized?(request) + return false unless [:find, :search].include?(request.method) - uri = key2uri(key) + uri = key2uri(request.key) # Make sure our file path starts with /modules, so that we authorize # against the 'modules' mount. path = uri.path =~ /^\/modules/ ? uri.path : "/modules" + uri.path - configuration.authorized?(path, :node => options[:node], :ipaddress => options[:ipaddress]) + configuration.authorized?(path, :node => request.node, :ipaddress => request.ip) end # Find our key in a module. - def find(key, options = {}) - return nil unless path = find_path(key, options) + def find(request) + return nil unless path = find_path(request) - result = model.new(key, :path => path) - result.links = options[:links] if options[:links] + result = model.new(request.key, :path => path) + result.links = request.options[:links] if request.options[:links] return result end @@ -41,9 +41,9 @@ class Puppet::Indirector::ModuleFiles < Puppet::Indirector::Terminus end # Search for a list of files. - def search(key, options = {}) - return nil unless path = find_path(key, options) - path2instances(key, path, options) + def search(request) + return nil unless path = find_path(request) + path2instances(request, path) end private @@ -63,15 +63,15 @@ class Puppet::Indirector::ModuleFiles < Puppet::Indirector::Terminus end # The abstracted method for turning a key into a path; used by both :find and :search. - def find_path(key, options) - uri = key2uri(key) + def find_path(request) + uri = key2uri(request.key) # Strip off /modules if it's there -- that's how requests get routed to this terminus. # Also, strip off the leading slash if present. module_name, relative_path = uri.path.sub(/^\/modules\b/, '').sub(%r{^/}, '').split(File::Separator, 2) # And use the environment to look up the module. - return nil unless mod = find_module(module_name, options[:node]) + return nil unless mod = find_module(module_name, request.node) path = File.join(mod.files, relative_path) diff --git a/spec/integration/file_serving/metadata.rb b/spec/integration/file_serving/metadata.rb index 5600365f1..067cb566a 100755 --- a/spec/integration/file_serving/metadata.rb +++ b/spec/integration/file_serving/metadata.rb @@ -16,4 +16,3 @@ describe Puppet::FileServing::Metadata, " when finding files" do @indirection = Puppet::FileServing::Metadata.indirection end end - diff --git a/spec/integration/indirector/module_files.rb b/spec/integration/indirector/module_files.rb index 1831bffbc..ae14aa5a7 100755 --- a/spec/integration/indirector/module_files.rb +++ b/spec/integration/indirector/module_files.rb @@ -20,7 +20,9 @@ describe Puppet::Indirector::ModuleFiles, " when interacting with Puppet::Module FileTest.expects(:exists?).with(filepath).returns(true) - @terminus.find("puppetmounts://host/modules/mymod/myfile").should be_instance_of(Puppet::FileServing::Content) + @request = Puppet::Indirector::Request.new(:content, :find, "puppetmounts://host/modules/mymod/myfile") + + @terminus.find(@request).should be_instance_of(Puppet::FileServing::Content) end end @@ -45,7 +47,9 @@ describe Puppet::Indirector::ModuleFiles, " when interacting with FileServing::F Dir.expects(:entries).with(filepath).returns(%w{one two}) - result = @terminus.search("puppetmounts://host/modules/mymod/myfile", :recurse => true) + @request = Puppet::Indirector::Request.new(:content, :search, "puppetmounts://host/modules/mymod/myfile", :recurse => true) + + result = @terminus.search(@request) result.should be_instance_of(Array) result.length.should == 3 result.each { |r| r.should be_instance_of(Puppet::FileServing::Content) } diff --git a/spec/shared_behaviours/file_server_terminus.rb b/spec/shared_behaviours/file_server_terminus.rb index de08f29fc..bb6b67132 100644 --- a/spec/shared_behaviours/file_server_terminus.rb +++ b/spec/shared_behaviours/file_server_terminus.rb @@ -24,6 +24,8 @@ describe "Puppet::Indirector::FileServerTerminus", :shared => true do # Stub out the modules terminus @modules = mock 'modules terminus' + + @request = Puppet::Indirector::Request.new(:indirection, :method, "puppetmounts://myhost/one/my/file") end it "should use the file server configuration to find files" do @@ -35,6 +37,6 @@ describe "Puppet::Indirector::FileServerTerminus", :shared => true do FileTest.stubs(:exists?).with("/my/mount/path").returns(true) @mount1.expects(:file).with("my/file", :node => nil).returns(path) - @terminus.find("puppetmounts://myhost/one/my/file").should be_instance_of(@test_class) + @terminus.find(@request).should be_instance_of(@test_class) end end diff --git a/spec/shared_behaviours/file_serving.rb b/spec/shared_behaviours/file_serving.rb index 82f207243..ba01f75a1 100644 --- a/spec/shared_behaviours/file_serving.rb +++ b/spec/shared_behaviours/file_serving.rb @@ -5,13 +5,13 @@ describe "Puppet::FileServing::Files", :shared => true do it "should use the rest terminus when the 'puppet' URI scheme is used and a host name is present" do - uri = "puppet://myhost/mymod/my/file" + uri = "puppet://myhost/fakemod/my/file" @indirection.terminus(:rest).expects(:find) @test_class.find(uri) end it "should use the rest terminus when the 'puppet' URI scheme is used, no host name is present, and the process name is not 'puppet'" do - uri = "puppet:///mymod/my/file" + uri = "puppet:///fakemod/my/file" Puppet.settings.stubs(:value).with(:name).returns("puppetd") Puppet.settings.stubs(:value).with(:modulepath).returns("") @indirection.terminus(:rest).expects(:find) @@ -19,7 +19,7 @@ describe "Puppet::FileServing::Files", :shared => true do end it "should use the file_server terminus when the 'puppet' URI scheme is used, no host name is present, and the process name is 'puppet'" do - uri = "puppet:///mymod/my/file" + uri = "puppet:///fakemod/my/file" Puppet::Node::Environment.stubs(:new).returns(stub("env", :name => "testing")) Puppet.settings.stubs(:value).with(:name).returns("puppet") Puppet.settings.stubs(:value).with(:modulepath, "testing").returns("") @@ -33,22 +33,32 @@ describe "Puppet::FileServing::Files", :shared => true do end it "should use the file_server terminus when the 'puppetmounts' URI scheme is used" do - uri = "puppetmounts:///mymod/my/file" + uri = "puppetmounts:///fakemod/my/file" @indirection.terminus(:file_server).expects(:find) @indirection.terminus(:file_server).stubs(:authorized?).returns(true) @test_class.find(uri) end it "should use the file terminus when the 'file' URI scheme is used" do - uri = "file:///mymod/my/file" + uri = "file:///fakemod/my/file" @indirection.terminus(:file).expects(:find) @test_class.find(uri) end it "should use the file terminus when a fully qualified path is provided" do - uri = "/mymod/my/file" + uri = "/fakemod/my/file" @indirection.terminus(:file).expects(:find) @test_class.find(uri) end + + it "should use the configuration to test whether the request is allowed" do + uri = "puppetmounts:///fakemod/my/file" + config = mock 'configuration' + @indirection.terminus(:file_server).stubs(:configuration).returns config + + @indirection.terminus(:file_server).expects(:find) + config.expects(:authorized?).returns(true) + @test_class.find(uri, :node => "foo", :ip => "bar") + end end diff --git a/spec/unit/file_serving/terminus_helper.rb b/spec/unit/file_serving/terminus_helper.rb index b919469a2..763ce9eb0 100755 --- a/spec/unit/file_serving/terminus_helper.rb +++ b/spec/unit/file_serving/terminus_helper.rb @@ -14,65 +14,63 @@ describe Puppet::FileServing::TerminusHelper do @model = mock 'model' @helper.stubs(:model).returns(@model) + + @request = stub 'request', :key => "url", :options => {} end it "should use a fileset to find paths" do fileset = mock 'fileset', :files => [] Puppet::FileServing::Fileset.expects(:new).with("/my/file", {}).returns(fileset) - @helper.path2instances("url", "/my/file") + @helper.path2instances(@request, "/my/file") end it "should pass :recurse, :ignore, and :links settings on to the fileset if present" do fileset = mock 'fileset', :files => [] Puppet::FileServing::Fileset.expects(:new).with("/my/file", :links => :a, :ignore => :b, :recurse => :c).returns(fileset) - @helper.path2instances("url", "/my/file", :links => :a, :ignore => :b, :recurse => :c) - end -end - - -describe Puppet::FileServing::TerminusHelper, " when creating instances" do - before do - @helper = Object.new - @helper.extend(Puppet::FileServing::TerminusHelper) - - @model = mock 'model' - @helper.stubs(:model).returns(@model) - - @key = "puppet://host/mount/dir" - - @fileset = mock 'fileset', :files => %w{one two} - Puppet::FileServing::Fileset.expects(:new).returns(@fileset) - end - - it "should create an instance of the model for each path returned by the fileset" do - @model.expects(:new).returns(:one) - @model.expects(:new).returns(:two) - @helper.path2instances(@key, "/my/file").length.should == 2 - end - - it "should set each instance's key to be the original key plus the file-specific path" do - @model.expects(:new).with { |key, options| key == @key + "/one" }.returns(:one) - @model.expects(:new).with { |key, options| key == @key + "/two" }.returns(:two) - @helper.path2instances(@key, "/my/file") - end - - it "should set each returned instance's path to the original path" do - @model.expects(:new).with { |key, options| options[:path] == "/my/file" }.returns(:one) - @model.expects(:new).with { |key, options| options[:path] == "/my/file" }.returns(:two) - @helper.path2instances(@key, "/my/file") - end - - it "should set each returned instance's relative path to the file-specific path" do - @model.expects(:new).with { |key, options| options[:relative_path] == "one" }.returns(:one) - @model.expects(:new).with { |key, options| options[:relative_path] == "two" }.returns(:two) - @helper.path2instances(@key, "/my/file") + @request.stubs(:options).returns(:links => :a, :ignore => :b, :recurse => :c) + @helper.path2instances(@request, "/my/file") end - it "should set the links value on each instance if one is provided" do - one = mock 'one', :links= => :manage - two = mock 'two', :links= => :manage - @model.expects(:new).returns(one) - @model.expects(:new).returns(two) - @helper.path2instances(@key, "/my/file", :links => :manage) + describe "when creating instances" do + before do + @request.stubs(:key).returns "puppet://host/mount/dir" + + @fileset = mock 'fileset', :files => %w{one two} + Puppet::FileServing::Fileset.expects(:new).returns(@fileset) + end + + it "should create an instance of the model for each path returned by the fileset" do + @model.expects(:new).returns(:one) + @model.expects(:new).returns(:two) + @helper.path2instances(@request, "/my/file").length.should == 2 + end + + it "should set each instance's key to be the original key plus the file-specific path" do + @model.expects(:new).with { |key, options| key == @request.key + "/one" }.returns(:one) + @model.expects(:new).with { |key, options| key == @request.key + "/two" }.returns(:two) + @helper.path2instances(@request, "/my/file") + end + + it "should set each returned instance's path to the original path" do + @model.expects(:new).with { |key, options| options[:path] == "/my/file" }.returns(:one) + @model.expects(:new).with { |key, options| options[:path] == "/my/file" }.returns(:two) + @helper.path2instances(@request, "/my/file") + end + + it "should set each returned instance's relative path to the file-specific path" do + @model.expects(:new).with { |key, options| options[:relative_path] == "one" }.returns(:one) + @model.expects(:new).with { |key, options| options[:relative_path] == "two" }.returns(:two) + @helper.path2instances(@request, "/my/file") + end + + it "should set the links value on each instance if one is provided" do + one = mock 'one', :links= => :manage + two = mock 'two', :links= => :manage + @model.expects(:new).returns(one) + @model.expects(:new).returns(two) + + @request.options[:links] = :manage + @helper.path2instances(@request, "/my/file") + end end end diff --git a/spec/unit/indirector/direct_file_server.rb b/spec/unit/indirector/direct_file_server.rb index a8583716a..0753f1bbe 100755 --- a/spec/unit/indirector/direct_file_server.rb +++ b/spec/unit/indirector/direct_file_server.rb @@ -69,29 +69,20 @@ describe Puppet::Indirector::DirectFileServer do end describe Puppet::Indirector::DirectFileServer, "when searching for multiple files" do - it "should return nil if the file does not exist" do FileTest.expects(:exists?).with("/my/local").returns false @server.find(@request).should be_nil end - it "should pass the original key to :path2instances" do - FileTest.expects(:exists?).with("/my/local").returns true - @server.expects(:path2instances).with { |uri, path, options| uri == @uri } - @server.search(@request) - end - it "should use :path2instances from the terminus_helper to return instances if the file exists" do FileTest.expects(:exists?).with("/my/local").returns true @server.expects(:path2instances) @server.search(@request) end - it "should pass any options on to :path2instances" do + it "should pass the original request to :path2instances" do FileTest.expects(:exists?).with("/my/local").returns true - @server.expects(:path2instances).with { |uri, path, options| options == {:testing => :one, :other => :two}} - - @request.stubs(:options).returns(:testing => :one, :other => :two) + @server.expects(:path2instances).with(@request, "/my/local") @server.search(@request) end end diff --git a/spec/unit/indirector/file_metadata/modules.rb b/spec/unit/indirector/file_metadata/modules.rb index 62f01832c..3905a49ad 100755 --- a/spec/unit/indirector/file_metadata/modules.rb +++ b/spec/unit/indirector/file_metadata/modules.rb @@ -23,11 +23,13 @@ describe Puppet::Indirector::FileMetadata::Modules, " when finding metadata" do @finder.stubs(:environment).returns(nil) @module = Puppet::Module.new("mymod", "/path/to") @finder.stubs(:find_module).returns(@module) + + @request = Puppet::Indirector::Request.new(:metadata, :find, "puppetmounts://hostname/modules/mymod/my/file") end it "should return nil if the file is not found" do FileTest.expects(:exists?).with("/path/to/files/my/file").returns false - @finder.find("puppetmounts://hostname/modules/mymod/my/file").should be_nil + @finder.find(@request).should be_nil end it "should retrieve the instance's attributes if the file is found" do @@ -35,6 +37,6 @@ describe Puppet::Indirector::FileMetadata::Modules, " when finding metadata" do instance = mock 'metadta' Puppet::FileServing::Metadata.expects(:new).returns instance instance.expects :collect_attributes - @finder.find("puppetmounts://hostname/modules/mymod/my/file") + @finder.find(@request) end end diff --git a/spec/unit/indirector/file_server.rb b/spec/unit/indirector/file_server.rb index 79be8cc29..ba951737a 100755 --- a/spec/unit/indirector/file_server.rb +++ b/spec/unit/indirector/file_server.rb @@ -27,34 +27,37 @@ describe Puppet::Indirector::FileServer do @uri = "puppetmounts://host/my/local/file" @configuration = mock 'configuration' Puppet::FileServing::Configuration.stubs(:create).returns(@configuration) + + @request = Puppet::Indirector::Request.new(:myind, :mymethod, @uri) end describe Puppet::Indirector::FileServer, " when finding files" do it "should use the path portion of the URI as the file name" do @configuration.expects(:file_path).with("/my/local/file", :node => nil) - @file_server.find(@uri) + @file_server.find(@request) end it "should use the FileServing configuration to convert the file name to a fully qualified path" do @configuration.expects(:file_path).with("/my/local/file", :node => nil) - @file_server.find(@uri) + @file_server.find(@request) end it "should pass the node name to the FileServing configuration if one is provided" do @configuration.expects(:file_path).with("/my/local/file", :node => "testing") - @file_server.find(@uri, :node => "testing") + @request.node = "testing" + @file_server.find(@request) end it "should return nil if no fully qualified path is found" do @configuration.expects(:file_path).with("/my/local/file", :node => nil).returns(nil) - @file_server.find(@uri).should be_nil + @file_server.find(@request).should be_nil end it "should return an instance of the model created with the full path if a file is found" do @configuration.expects(:file_path).with("/my/local/file", :node => nil).returns("/some/file") @model.expects(:new).returns(:myinstance) - @file_server.find(@uri).should == :myinstance + @file_server.find(@request).should == :myinstance end end @@ -66,23 +69,24 @@ describe Puppet::Indirector::FileServer do it "should create the instance with the key used to find the instance" do @model.expects(:new).with { |key, *options| key == @uri } - @file_server.find(@uri) + @file_server.find(@request) end it "should create the instance with the path at which the instance was found" do @model.expects(:new).with { |key, options| options[:path] == "/some/file" } - @file_server.find(@uri) + @file_server.find(@request) end it "should set the provided :links setting on to the instance if one is provided" do @model.expects(:new).returns(@instance) @instance.expects(:links=).with(:mytest) - @file_server.find(@uri, :links => :mytest) + @request.options[:links] = :mytest + @file_server.find(@request) end it "should not set a :links value if no :links parameter is provided" do @model.expects(:new).returns(@instance) - @file_server.find(@uri) + @file_server.find(@request) end end @@ -93,41 +97,52 @@ describe Puppet::Indirector::FileServer do end it "should deny the :destroy method" do - @file_server.authorized?(:destroy, "whatever").should be_false + @request.method = :destroy + @file_server.authorized?(@request).should be_false end it "should deny the :save method" do - @file_server.authorized?(:save, "whatever").should be_false - end + @request.method = :save + @file_server.authorized?(@request).should be_false + end + + describe "and finding file information" do + before do + @request.key = "puppetmounts://host/my/file" + @request.method = :find + end - it "should use the file server configuration to determine authorization" do - @configuration.expects(:authorized?) - @file_server.authorized?(:find, "puppetmounts://host/my/file") - end + it "should use the file server configuration to determine authorization" do + @configuration.expects(:authorized?) + @file_server.authorized?(@request) + end - it "should pass the file path from the URI to the file server configuration" do - @configuration.expects(:authorized?).with { |uri, *args| uri == "/my/file" } - @file_server.authorized?(:find, "puppetmounts://host/my/file") - end + it "should pass the file path from the URI to the file server configuration" do + @configuration.expects(:authorized?).with { |uri, *args| uri == "/my/file" } + @file_server.authorized?(@request) + end - it "should pass the node name to the file server configuration" do - @configuration.expects(:authorized?).with { |key, options| options[:node] == "mynode" } - @file_server.authorized?(:find, "puppetmounts://host/my/file", :node => "mynode") - end + it "should pass the node name to the file server configuration" do + @configuration.expects(:authorized?).with { |key, options| options[:node] == "mynode" } + @request.node = "mynode" + @file_server.authorized?(@request) + end - it "should pass the IP address to the file server configuration" do - @configuration.expects(:authorized?).with { |key, options| options[:ipaddress] == "myip" } - @file_server.authorized?(:find, "puppetmounts://host/my/file", :ipaddress => "myip") - end + it "should pass the IP address to the file server configuration" do + @configuration.expects(:authorized?).with { |key, options| options[:ipaddress] == "myip" } + @request.ip = "myip" + @file_server.authorized?(@request) + end - it "should return false if the file server configuration denies authorization" do - @configuration.expects(:authorized?).returns(false) - @file_server.authorized?(:find, "puppetmounts://host/my/file").should be_false - end + it "should return false if the file server configuration denies authorization" do + @configuration.expects(:authorized?).returns(false) + @file_server.authorized?(@request) + end - it "should return true if the file server configuration approves authorization" do - @configuration.expects(:authorized?).returns(true) - @file_server.authorized?(:find, "puppetmounts://host/my/file").should be_true + it "should return true if the file server configuration approves authorization" do + @configuration.expects(:authorized?).returns(true) + @file_server.authorized?(@request) + end end end @@ -135,34 +150,35 @@ describe Puppet::Indirector::FileServer do it "should use the path portion of the URI as the file name" do @configuration.expects(:file_path).with("/my/local/file", :node => nil) - @file_server.search(@uri) + @file_server.search(@request) end it "should use the FileServing configuration to convert the file name to a fully qualified path" do @configuration.expects(:file_path).with("/my/local/file", :node => nil) - @file_server.search(@uri) + @file_server.search(@request) end it "should pass the node name to the FileServing configuration if one is provided" do @configuration.expects(:file_path).with("/my/local/file", :node => "testing") - @file_server.search(@uri, :node => "testing") + @request.node = "testing" + @file_server.search(@request) end it "should return nil if no fully qualified path is found" do @configuration.expects(:file_path).with("/my/local/file", :node => nil).returns(nil) - @file_server.search(@uri).should be_nil + @file_server.search(@request).should be_nil end it "should use :path2instances from the terminus_helper to return instances if a module is found and the file exists" do @configuration.expects(:file_path).with("/my/local/file", :node => nil).returns("/my/file") - @file_server.expects(:path2instances).with(@uri, "/my/file", {}) - @file_server.search(@uri) + @file_server.expects(:path2instances) + @file_server.search(@request) end - it "should pass any options on to :path2instances" do + it "should pass the request on to :path2instances" do @configuration.expects(:file_path).with("/my/local/file", :node => nil).returns("/my/file") - @file_server.expects(:path2instances).with(@uri, "/my/file", :testing => :one, :other => :two) - @file_server.search(@uri, :testing => :one, :other => :two) + @file_server.expects(:path2instances).with(@request, "/my/file") + @file_server.search(@request) end end end diff --git a/spec/unit/indirector/module_files.rb b/spec/unit/indirector/module_files.rb index f5b92e1fd..32dedd4f1 100755 --- a/spec/unit/indirector/module_files.rb +++ b/spec/unit/indirector/module_files.rb @@ -27,61 +27,66 @@ describe Puppet::Indirector::ModuleFiles do @uri = "puppetmounts://host/modules/my/local/file" @module = Puppet::Module.new("mymod", "/module/path") + + @request = stub 'request', :key => @uri, :options => {}, :node => nil, :ip => nil, :method => :find end describe Puppet::Indirector::ModuleFiles, " when finding files" do it "should strip off the leading '/modules' mount name" do Puppet::Module.expects(:find).with('my', "myenv").returns @module - @module_files.find(@uri) + @module_files.find(@request) end it "should not strip off leading terms that start with '/modules' but are longer words" do + @request.stubs(:key).returns "puppetmounts://host/modulestart/my/local/file" Puppet::Module.expects(:find).with('modulestart', "myenv").returns nil - @module_files.find("puppetmounts://host/modulestart/my/local/file") + @module_files.find(@request) end it "should search for a module whose name is the first term in the remaining file path" do Puppet::Module.expects(:find).with('my', "myenv").returns @module - @module_files.find(@uri) + @module_files.find(@request) end it "should search for a file relative to the module's files directory" do Puppet::Module.expects(:find).with('my', "myenv").returns @module FileTest.expects(:exists?).with("/module/path/files/local/file") - @module_files.find(@uri) + @module_files.find(@request) end it "should return nil if the module does not exist" do Puppet::Module.expects(:find).with('my', "myenv").returns nil - @module_files.find(@uri).should be_nil + @module_files.find(@request).should be_nil end it "should return nil if the module exists but the file does not" do Puppet::Module.expects(:find).with('my', "myenv").returns @module FileTest.expects(:exists?).with("/module/path/files/local/file").returns(false) - @module_files.find(@uri).should be_nil + @module_files.find(@request).should be_nil end it "should return an instance of the model if a module is found and the file exists" do Puppet::Module.expects(:find).with('my', "myenv").returns @module FileTest.expects(:exists?).with("/module/path/files/local/file").returns(true) @model.expects(:new).returns(:myinstance) - @module_files.find(@uri).should == :myinstance + @module_files.find(@request).should == :myinstance end it "should use the node's environment to look up the module if the node name is provided" do node = stub "node", :environment => "testing" Puppet::Node.expects(:find).with("mynode").returns(node) Puppet::Module.expects(:find).with('my', "testing") - @module_files.find(@uri, :node => "mynode") + + @request.stubs(:node).returns "mynode" + @module_files.find(@request) end it "should use the default environment setting to look up the module if the node name is not provided" do env = stub "environment", :name => "testing" Puppet::Node::Environment.stubs(:new).returns(env) Puppet::Module.expects(:find).with('my', "testing") - @module_files.find(@uri) + @module_files.find(@request) end end @@ -95,23 +100,25 @@ describe Puppet::Indirector::ModuleFiles do it "should create the instance with the key used to find the instance" do @model.expects(:new).with { |key, *options| key == @uri } - @module_files.find(@uri) + @module_files.find(@request) end it "should create the instance with the path at which the instance was found" do @model.expects(:new).with { |key, options| options[:path] == "/module/path/files/local/file" } - @module_files.find(@uri) + @module_files.find(@request) end it "should set the provided :links setting on to the instance if one is provided" do @model.expects(:new).returns(@instance) @instance.expects(:links=).with(:mytest) - @module_files.find(@uri, :links => :mytest) + + @request.options[:links] = :mytest + @module_files.find(@request) end it "should not set a :links value if no :links parameter is provided" do @model.expects(:new).returns(@instance) - @module_files.find(@uri) + @module_files.find(@request) end end @@ -127,46 +134,53 @@ describe Puppet::Indirector::ModuleFiles do end it "should deny the :destroy method" do - @module_files.authorized?(:destroy, "whatever").should be_false + @request.expects(:method).returns :destroy + @module_files.authorized?(@request).should be_false end it "should deny the :save method" do - @module_files.authorized?(:save, "whatever").should be_false + @request.expects(:method).returns :save + @module_files.authorized?(@request).should be_false end it "should use the file server configuration to determine authorization" do @configuration.expects(:authorized?) - @module_files.authorized?(:find, "puppetmounts://host/my/file") + @module_files.authorized?(@request) end it "should use the path directly from the URI if it already includes /modules" do + @request.expects(:key).returns "puppetmounts://host/modules/my/file" @configuration.expects(:authorized?).with { |uri, *args| uri == "/modules/my/file" } - @module_files.authorized?(:find, "puppetmounts://host/modules/my/file") + @module_files.authorized?(@request) end it "should add /modules to the file path if it's not included in the URI" do + @request.expects(:key).returns "puppetmounts://host/my/file" @configuration.expects(:authorized?).with { |uri, *args| uri == "/modules/my/file" } - @module_files.authorized?(:find, "puppetmounts://host/my/file") + @module_files.authorized?(@request) end it "should pass the node name to the file server configuration" do + @request.expects(:key).returns "puppetmounts://host/my/file" @configuration.expects(:authorized?).with { |key, options| options[:node] == "mynode" } - @module_files.authorized?(:find, "puppetmounts://host/my/file", :node => "mynode") + @request.stubs(:node).returns "mynode" + @module_files.authorized?(@request) end it "should pass the IP address to the file server configuration" do + @request.expects(:ip).returns "myip" @configuration.expects(:authorized?).with { |key, options| options[:ipaddress] == "myip" } - @module_files.authorized?(:find, "puppetmounts://host/my/file", :ipaddress => "myip") + @module_files.authorized?(@request) end it "should return false if the file server configuration denies authorization" do @configuration.expects(:authorized?).returns(false) - @module_files.authorized?(:find, "puppetmounts://host/my/file").should be_false + @module_files.authorized?(@request).should be_false end it "should return true if the file server configuration approves authorization" do @configuration.expects(:authorized?).returns(true) - @module_files.authorized?(:find, "puppetmounts://host/my/file").should be_true + @module_files.authorized?(@request).should be_true end end @@ -175,69 +189,71 @@ describe Puppet::Indirector::ModuleFiles do it "should strip off the leading '/modules' mount name" do Puppet::Node::Environment.stubs(:new).returns(stub('env', :name => "myenv")) Puppet::Module.expects(:find).with('my', "myenv").returns @module - @module_files.search(@uri) + @module_files.search(@request) end it "should not strip off leading terms that start with '/modules' but are longer words" do Puppet::Node::Environment.stubs(:new).returns(stub('env', :name => "myenv")) Puppet::Module.expects(:find).with('modulestart', "myenv").returns nil - @module_files.search("puppetmounts://host/modulestart/my/local/file") + @request.stubs(:key).returns "puppetmounts://host/modulestart/my/local/file" + @module_files.search @request end it "should search for a module whose name is the first term in the remaining file path" do Puppet::Node::Environment.stubs(:new).returns(stub('env', :name => "myenv")) Puppet::Module.expects(:find).with('my', "myenv").returns @module - @module_files.search(@uri) + @module_files.search(@request) end it "should search for a file relative to the module's files directory" do Puppet::Node::Environment.stubs(:new).returns(stub('env', :name => "myenv")) Puppet::Module.expects(:find).with('my', "myenv").returns @module FileTest.expects(:exists?).with("/module/path/files/local/file") - @module_files.search(@uri) + @module_files.search(@request) end it "should return nil if the module does not exist" do Puppet::Node::Environment.stubs(:new).returns(stub('env', :name => "myenv")) Puppet::Module.expects(:find).with('my', "myenv").returns nil - @module_files.search(@uri).should be_nil + @module_files.search(@request).should be_nil end it "should return nil if the module exists but the file does not" do Puppet::Node::Environment.stubs(:new).returns(stub('env', :name => "myenv")) Puppet::Module.expects(:find).with('my', "myenv").returns @module FileTest.expects(:exists?).with("/module/path/files/local/file").returns(false) - @module_files.search(@uri).should be_nil + @module_files.search(@request).should be_nil end it "should use the node's environment to look up the module if the node name is provided" do node = stub "node", :environment => "testing" Puppet::Node.expects(:find).with("mynode").returns(node) Puppet::Module.expects(:find).with('my', "testing") - @module_files.search(@uri, :node => "mynode") + @request.stubs(:node).returns "mynode" + @module_files.search(@request) end it "should use the default environment setting to look up the module if the node name is not provided and the environment is not set to ''" do env = stub 'env', :name => "testing" Puppet::Node::Environment.stubs(:new).returns(env) Puppet::Module.expects(:find).with('my', "testing") - @module_files.search(@uri) + @module_files.search(@request) end it "should use :path2instances from the terminus_helper to return instances if a module is found and the file exists" do Puppet::Node::Environment.stubs(:new).returns(stub('env', :name => "myenv")) Puppet::Module.expects(:find).with('my', "myenv").returns @module FileTest.expects(:exists?).with("/module/path/files/local/file").returns(true) - @module_files.expects(:path2instances).with(@uri, "/module/path/files/local/file", {}) - @module_files.search(@uri) + @module_files.expects(:path2instances).with(@request, "/module/path/files/local/file") + @module_files.search(@request) end - it "should pass any options on to :path2instances" do + it "should pass the request directly to :path2instances" do Puppet::Node::Environment.stubs(:new).returns(stub('env', :name => "myenv")) Puppet::Module.expects(:find).with('my', "myenv").returns @module FileTest.expects(:exists?).with("/module/path/files/local/file").returns(true) - @module_files.expects(:path2instances).with(@uri, "/module/path/files/local/file", :testing => :one, :other => :two) - @module_files.search(@uri, :testing => :one, :other => :two) + @module_files.expects(:path2instances).with(@request, "/module/path/files/local/file") + @module_files.search(@request) end end end -- cgit From 238b8d7f0a16eda971409d7423dc1f04cf0e2a34 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Fri, 18 Jul 2008 15:30:42 -0500 Subject: Fixing #1438 -- mongrel and module tests now pass. Signed-off-by: Luke Kanies --- spec/unit/module.rb | 4 ++-- spec/unit/network/http/mongrel.rb | 4 ++++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/spec/unit/module.rb b/spec/unit/module.rb index 2dadaa501..e79001ae1 100755 --- a/spec/unit/module.rb +++ b/spec/unit/module.rb @@ -143,8 +143,8 @@ describe Puppet::Module, " when searching for manifests when no module is found" it "should look for files relative to the current directory" do cwd = Dir.getwd - Dir.expects(:glob).with("#{cwd}/mymod/init.pp").returns(["#{cwd}/mymod/init.pp"]) - Puppet::Module.find_manifests("mymod/init.pp").should == ["#{cwd}/mymod/init.pp"] + Dir.expects(:glob).with("#{cwd}/foobar/init.pp").returns(["#{cwd}/foobar/init.pp"]) + Puppet::Module.find_manifests("foobar/init.pp").should == ["#{cwd}/foobar/init.pp"] end it "should only return files, not directories" do diff --git a/spec/unit/network/http/mongrel.rb b/spec/unit/network/http/mongrel.rb index 3a9cfb52f..1732009a8 100755 --- a/spec/unit/network/http/mongrel.rb +++ b/spec/unit/network/http/mongrel.rb @@ -10,6 +10,8 @@ describe "Puppet::Network::HTTP::Mongrel", "after initializing" do confine "Mongrel is not available" => Puppet.features.mongrel? it "should not be listening" do + require 'puppet/network/http/mongrel' + Puppet::Network::HTTP::Mongrel.new.should_not be_listening end end @@ -18,6 +20,8 @@ describe "Puppet::Network::HTTP::Mongrel", "when turning on listening" do confine "Mongrel is not available" => Puppet.features.mongrel? before do + require 'puppet/network/http/mongrel' + @server = Puppet::Network::HTTP::Mongrel.new @mock_mongrel = mock('mongrel') @mock_mongrel.stubs(:run) -- cgit From a47fed41562443bb124ce64513208f49b67654d4 Mon Sep 17 00:00:00 2001 From: Andrew Shafer Date: Fri, 18 Jul 2008 10:55:03 -0600 Subject: 'Fix' broken tests related to missing source raising Issue 1437 In two cases, I removed the assertion that caused the failure. In one case, I changed the assertion to expect an exception. --- test/ral/type/filesources.rb | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/test/ral/type/filesources.rb b/test/ral/type/filesources.rb index a7bb6fefa..77b598187 100755 --- a/test/ral/type/filesources.rb +++ b/test/ral/type/filesources.rb @@ -145,16 +145,7 @@ class TestFileSources < Test::Unit::TestCase # Make sure the munge didn't actually change the source assert_equal([source], property.should, "munging changed the source") - # First try it with a missing source currentvalue = nil - assert_nothing_raised do - currentvalue = property.retrieve - end - - # And make sure the property considers itself in sync, since there's nothing - # to do - assert(property.insync?(currentvalue), "source thinks there's work to do with no file or dest") - # Now make the dest a directory, and make sure the object sets :ensure # up to create a directory Dir.mkdir(source) @@ -170,9 +161,6 @@ class TestFileSources < Test::Unit::TestCase # Now remove the source, and make sure :ensure was not modified Dir.rmdir(source) - assert_nothing_raised do - property.retrieve - end assert_equal(:directory, file.should(:ensure), "Did not keep :ensure setting") @@ -208,10 +196,6 @@ class TestFileSources < Test::Unit::TestCase property = file.property(:source) assert(property, "did not get source property") - # Try it with no source at all - currentvalues = file.retrieve - assert(property.insync?(currentvalues[property]), "source property not in sync with missing source") - # with a directory Dir.mkdir(source) currentvalues = file.retrieve @@ -623,9 +607,9 @@ class TestFileSources < Test::Unit::TestCase :name => name ) - assert_nothing_raised { + assert_raise Puppet::Error do file.retrieve - } + end comp = mk_catalog(file) comp.apply -- cgit From f16da4250c16aeab932a81a349df059c69d7ee23 Mon Sep 17 00:00:00 2001 From: Brett Lentz Date: Fri, 18 Jul 2008 10:05:02 -0700 Subject: Merging fsweetser's selinux patch against 0.24.4 --- lib/puppet/provider/selboolean/getsetsebool.rb | 47 ++++++++ lib/puppet/provider/selmodule/semodule.rb | 143 +++++++++++++++++++++++++ lib/puppet/type/file.rb | 1 + lib/puppet/type/file/selcontext.rb | 96 +++++++++++++++++ lib/puppet/type/selboolean.rb | 29 +++++ lib/puppet/type/selmodule.rb | 50 +++++++++ spec/unit/other/selinux.rb | 78 ++++++++++++++ 7 files changed, 444 insertions(+) create mode 100644 lib/puppet/provider/selboolean/getsetsebool.rb create mode 100644 lib/puppet/provider/selmodule/semodule.rb create mode 100644 lib/puppet/type/file/selcontext.rb create mode 100644 lib/puppet/type/selboolean.rb create mode 100644 lib/puppet/type/selmodule.rb create mode 100644 spec/unit/other/selinux.rb diff --git a/lib/puppet/provider/selboolean/getsetsebool.rb b/lib/puppet/provider/selboolean/getsetsebool.rb new file mode 100644 index 000000000..4614c6c38 --- /dev/null +++ b/lib/puppet/provider/selboolean/getsetsebool.rb @@ -0,0 +1,47 @@ +Puppet::Type.type(:selboolean).provide(:getsetsebool) do + desc "Manage SELinux booleans using the getsebool and setsebool binaries." + + commands :getsebool => "/usr/sbin/getsebool" + commands :setsebool => "/usr/sbin/setsebool" + + def value + self.debug "Retrieving value of selboolean #{@resource[:name]}" + + status = getsebool(@resource[:name]) + + if status =~ / off$/ then + return :off + elsif status =~ / on$/ then + return :on + else + status.chomp! + raise Puppet::Error, "Invalid response '%s' returned from getsebool" % [status] + end + end + + def value=(new) + persist = "" + if @resource[:persistent] == :true + self.debug "Enabling persistence" + persist = "-P" + end + execoutput("#{command(:setsebool)} #{persist} #{@resource[:name]} #{new}") + return :file_changed + end + + # Required workaround, since SELinux policy prevents setsebool + # from writing to any files, even tmp, preventing the standard + # 'setsebool("...")' construct from working. + + def execoutput (cmd) + output = '' + begin + execpipe(cmd) do |out| + output = out.readlines.join('').chomp! + end + rescue Puppet::ExecutionFailure + raise Puppet::ExecutionFailure, output.split("\n")[0] + end + return output + end +end diff --git a/lib/puppet/provider/selmodule/semodule.rb b/lib/puppet/provider/selmodule/semodule.rb new file mode 100644 index 000000000..498136691 --- /dev/null +++ b/lib/puppet/provider/selmodule/semodule.rb @@ -0,0 +1,143 @@ +Puppet::Type.type(:selmodule).provide(:semodule) do + desc "Manage SELinux policy modules using the semodule binary." + + commands :semodule => "/usr/sbin/semodule" + + def create + begin + execoutput("#{command(:semodule)} --install #{selmod_name_to_filename}") + rescue Puppet::ExecutionFailure => detail + raise Puppet::Error, "Could not load policy module: %s" % [detail]; + end + return :true + end + + def destroy + begin + execoutput("#{command(:semodule)} --remove #{@resource[:name]}") + rescue Puppet::ExecutionFailure => detail + raise Puppet::Error, "Could not remove policy module: %s" % [detail]; + end + end + + def exists? + self.debug "Checking for module #{@resource[:name]}" + execpipe("#{command(:semodule)} --list") do |out| + out.each do |line| + if line =~ /#{@resource[:name]}\b/ + return :true + end + end + end + return nil + end + + def syncversion + self.debug "Checking syncversion on #{@resource[:name]}" + + loadver = selmodversion_loaded + + if(loadver) then + filever = selmodversion_file + if (filever == loadver) then + return :true + end + end + return :false + end + + def syncversion= (dosync) + begin + execoutput("#{command(:semodule)} --upgrade #{selmod_name_to_filename}") + rescue Puppet::ExecutionFailure => detail + raise Puppet::Error, "Could not upgrade policy module: %s" % [detail]; + end + end + + # Helper functions + + def execoutput (cmd) + output = '' + begin + execpipe(cmd) do |out| + output = out.readlines.join('').chomp! + end + rescue Puppet::ExecutionFailure + raise Puppet::ExecutionFailure, output.split("\n")[0] + end + return output + end + + def selmod_name_to_filename + if @resource[:selmodulepath] + return @resource[:selmodulepath] + else + return "#{@resource[:selmoduledir]}/#{@resource[:name]}.pp" + end + end + + def selmod_readnext (handle) + len = handle.read(4).unpack('L')[0] + return handle.read(len) + end + + def selmodversion_file + magic = 0xF97CFF8F + + filename = selmod_name_to_filename + mod = File.new(filename, "r") + + (hdr, ver, numsec) = mod.read(12).unpack('LLL') + + if hdr != magic + raise Puppet::Error, "Found #{hdr} instead of magic #{magic} in #{filename}" + end + + if ver != 1 + raise Puppet::Error, "Unknown policy file version #{ver} in #{filename}" + end + + # Read through (and throw away) the file section offsets, and also + # the magic header for the first section. + + mod.read((numsec + 1) * 4) + + ## Section 1 should be "SE Linux Module" + + selmod_readnext(mod) + selmod_readnext(mod) + + # Skip past the section headers + mod.read(14) + + # Module name + selmod_readnext(mod) + + # At last! the version + + v = selmod_readnext(mod) + + self.debug "file version #{v}" + return v + end + + def selmodversion_loaded + lines = () + begin + execpipe("#{command(:semodule)} --list") do |output| + lines = output.readlines + lines.each do |line| + line.chomp! + bits = line.split + if bits[0] == @resource[:name] then + self.debug "load version #{bits[1]}" + return bits[1] + end + end + end + rescue Puppet::ExecutionFailure + raise Puppet::ExecutionFailure, "Could not list policy modules: %s" % [lines.join(' ').chomp!] + end + return nil + end +end diff --git a/lib/puppet/type/file.rb b/lib/puppet/type/file.rb index 3518e8bb3..cd1528e73 100644 --- a/lib/puppet/type/file.rb +++ b/lib/puppet/type/file.rb @@ -1148,4 +1148,5 @@ module Puppet require 'puppet/type/file/group' require 'puppet/type/file/mode' require 'puppet/type/file/type' + require 'puppet/type/file/selcontext' # SELinux file context end diff --git a/lib/puppet/type/file/selcontext.rb b/lib/puppet/type/file/selcontext.rb new file mode 100644 index 000000000..f36695075 --- /dev/null +++ b/lib/puppet/type/file/selcontext.rb @@ -0,0 +1,96 @@ +# Manage SELinux context of files. +# +# This code actually manages three pieces of data in the context. +# +# [root@delenn files]# ls -dZ / +# drwxr-xr-x root root system_u:object_r:root_t / +# +# The context of '/' here is 'system_u:object_r:root_t'. This is +# three seperate fields: +# +# system_u is the user context +# object_r is the role context +# root_t is the type context +# +# All three of these fields are returned in a single string by the +# output of the stat command, but set individually with the chcon +# command. This allows the user to specify a subset of the three +# values while leaving the others alone. +# +# See http://www.nsa.gov/selinux/ for complete docs on SELinux. + +module Puppet + class SELFileContext < Puppet::Property + + def retrieve + unless @resource.stat(false) + return :absent + end + context = `stat -c %C #{@resource[:path]}` + context.chomp! + if context == "unlabeled" + return nil + end + unless context =~ /^[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/ + raise Puppet::Error, "Invalid output from stat: #{context}" + end + bits = context.split(':') + ret = { + :seluser => bits[0], + :selrole => bits[1], + :seltype => bits[2] + } + return ret[name] + end + + def sync + unless @resource.stat(false) + stat = @resource.stat(true) + unless stat + return nil + end + end + + flag = '' + + case name + when :seluser + flag = "-u" + when :selrole + flag = "-r" + when :seltype + flag = "-t" + else + raise Puppet::Error, "Invalid SELinux file context component: #{name}" + end + + self.debug "Running chcon #{flag} #{@should} #{@resource[:path]}" + retval = system("chcon #{flag} #{@should} #{@resource[:path]}") + unless retval + error = Puppet::Error.new("failed to chcon %s" % [@resource[:path]]) + raise error + end + return :file_changed + end + end + + Puppet.type(:file).newproperty(:seluser, :parent => Puppet::SELFileContext) do + desc "What the SELinux User context of the file should be." + + @event = :file_changed + end + + Puppet.type(:file).newproperty(:selrole, :parent => Puppet::SELFileContext) do + desc "What the SELinux Role context of the file should be." + + @event = :file_changed + end + + Puppet.type(:file).newproperty(:seltype, :parent => Puppet::SELFileContext) do + desc "What the SELinux Type context of the file should be." + + @event = :file_changed + end + +end + diff --git a/lib/puppet/type/selboolean.rb b/lib/puppet/type/selboolean.rb new file mode 100644 index 000000000..d12dd3bcb --- /dev/null +++ b/lib/puppet/type/selboolean.rb @@ -0,0 +1,29 @@ +# +# Simple module for manageing SELinux booleans +# + +module Puppet + newtype(:selboolean) do + @doc = "Enable or disable SELinux booleans." + + newparam(:name) do + desc "The name of the SELinux boolean to be managed." + isnamevar + end + + newproperty(:value) do + desc "Whether the the SELinux boolean should be enabled or disabled. Possible values are ``on`` or ``off``." + newvalue(:on) + newvalue(:off) + end + + newparam(:persistent) do + desc "If set true, SELinux booleans will be written to disk and persist accross reboots." + + defaultto :false + newvalues(:true, :false) + end + + end +end + diff --git a/lib/puppet/type/selmodule.rb b/lib/puppet/type/selmodule.rb new file mode 100644 index 000000000..1f02912ad --- /dev/null +++ b/lib/puppet/type/selmodule.rb @@ -0,0 +1,50 @@ +# +# Simple module for manageing SELinux policy modules +# + +Puppet::Type.newtype(:selmodule) do + @doc = "Enable or disable SELinux policy modules." + + ensurable + + newparam(:name) do + desc "The name of the SELinux policy to be managed." + isnamevar + end + + newparam(:selmoduledir) do + + desc "The directory to look for the compiled pp module file in. + Currently defaults to /usr/share/selinux/targeted" + + defaultto "/usr/share/selinux/targeted" + end + + newparam(:selmodulepath) do + + desc "The full path in which to look for the compiled pp + module file in. You only need to use this if the module file + is not in the directory pointed at by selmoduledir." + + end + + newproperty(:syncversion) do + + desc "If set to 'true', the policy will be reloaded if the + version found in the on-disk file differs from the loaded + version. If set to 'false' (the default) the the only check + that will be made is if the policy is loaded at all or not." + + newvalue(:true) + newvalue(:false) + end + + autorequire(:file) do + if self[:selmodulepath] + [self[:selmodulepath]] + else + ["#{self[:selmoduledir]}/#{self[:name]}.pp"] + end + end +end + diff --git a/spec/unit/other/selinux.rb b/spec/unit/other/selinux.rb new file mode 100644 index 000000000..0974b71c3 --- /dev/null +++ b/spec/unit/other/selinux.rb @@ -0,0 +1,78 @@ +#!/usr/bin/env ruby + +require File.dirname(__FILE__) + '/../../spec_helper' + +require 'puppet/type/selboolean' +require 'puppet/type/selmodule' + +describe Puppet::Type::File, " when manipulating file contexts" do + before :each do + @file = Puppet.type(:file).create( + :path => "/tmp/foo", + :ensure => "file", + :seluser => "user_u", + :selrole => "role_r", + :seltype => "type_t") + end + it "should use :seluser to get/set an SELinux user file context attribute" do + @file[:seluser].should == "user_u" + end + it "should use :selrole to get/set an SELinux role file context attribute" do + @file[:selrole].should == "role_r" + end + it "should use :seltype to get/set an SELinux user file context attribute" do + @file[:seltype].should == "type_t" + end +end + +describe Puppet::Type::Selboolean, " when manipulating booleans" do + before :each do + @bool = Puppet.type(:selboolean).create( + :name => "foo", + :value => "on", + :persistent => true) + end + it "should be able to access :name" do + @bool[:name].should == "foo" + end + it "should be able to access :value" do + @bool[:value].should == :on + end + it "should set :value to off" do + @bool[:value] = :off + @bool[:value].should == :off + end + it "should be able to access :persistent" do + @bool[:persistent].should == :true + end + it "should set :persistent to false" do + @bool[:persistent] = false + @bool[:persistent].should == :false + end +end + +describe Puppet::Type::Selmodule, " when checking policy modules" do + before :each do + @module = Puppet.type(:selmodule).create( + :name => "foo", + :selmoduledir => "/some/path", + :selmodulepath => "/some/path/foo.pp", + :syncversion => true) + end + it "should be able to access :name" do + @module[:name].should == "foo" + end + it "should be able to access :selmoduledir" do + @module[:selmoduledir].should == "/some/path" + end + it "should be able to access :selmodulepath" do + @module[:selmodulepath].should == "/some/path/foo.pp" + end + it "should be able to access :syncversion" do + @module[:syncversion].should == :true + end + it "should set the syncversion value to false" do + @module[:syncversion] = :false + @module[:syncversion].should == :false + end +end -- cgit From 686ba4d4c21f6f1e073bd845492f2fe3cb4837a2 Mon Sep 17 00:00:00 2001 From: James Turnbull Date: Sun, 20 Jul 2008 16:11:56 +1000 Subject: Revert "Merging fsweetser's selinux patch against 0.24.4" This reverts commit f16da4250c16aeab932a81a349df059c69d7ee23. --- lib/puppet/provider/selboolean/getsetsebool.rb | 47 -------- lib/puppet/provider/selmodule/semodule.rb | 143 ------------------------- lib/puppet/type/file.rb | 1 - lib/puppet/type/file/selcontext.rb | 96 ----------------- lib/puppet/type/selboolean.rb | 29 ----- lib/puppet/type/selmodule.rb | 50 --------- spec/unit/other/selinux.rb | 78 -------------- 7 files changed, 444 deletions(-) delete mode 100644 lib/puppet/provider/selboolean/getsetsebool.rb delete mode 100644 lib/puppet/provider/selmodule/semodule.rb delete mode 100644 lib/puppet/type/file/selcontext.rb delete mode 100644 lib/puppet/type/selboolean.rb delete mode 100644 lib/puppet/type/selmodule.rb delete mode 100644 spec/unit/other/selinux.rb diff --git a/lib/puppet/provider/selboolean/getsetsebool.rb b/lib/puppet/provider/selboolean/getsetsebool.rb deleted file mode 100644 index 4614c6c38..000000000 --- a/lib/puppet/provider/selboolean/getsetsebool.rb +++ /dev/null @@ -1,47 +0,0 @@ -Puppet::Type.type(:selboolean).provide(:getsetsebool) do - desc "Manage SELinux booleans using the getsebool and setsebool binaries." - - commands :getsebool => "/usr/sbin/getsebool" - commands :setsebool => "/usr/sbin/setsebool" - - def value - self.debug "Retrieving value of selboolean #{@resource[:name]}" - - status = getsebool(@resource[:name]) - - if status =~ / off$/ then - return :off - elsif status =~ / on$/ then - return :on - else - status.chomp! - raise Puppet::Error, "Invalid response '%s' returned from getsebool" % [status] - end - end - - def value=(new) - persist = "" - if @resource[:persistent] == :true - self.debug "Enabling persistence" - persist = "-P" - end - execoutput("#{command(:setsebool)} #{persist} #{@resource[:name]} #{new}") - return :file_changed - end - - # Required workaround, since SELinux policy prevents setsebool - # from writing to any files, even tmp, preventing the standard - # 'setsebool("...")' construct from working. - - def execoutput (cmd) - output = '' - begin - execpipe(cmd) do |out| - output = out.readlines.join('').chomp! - end - rescue Puppet::ExecutionFailure - raise Puppet::ExecutionFailure, output.split("\n")[0] - end - return output - end -end diff --git a/lib/puppet/provider/selmodule/semodule.rb b/lib/puppet/provider/selmodule/semodule.rb deleted file mode 100644 index 498136691..000000000 --- a/lib/puppet/provider/selmodule/semodule.rb +++ /dev/null @@ -1,143 +0,0 @@ -Puppet::Type.type(:selmodule).provide(:semodule) do - desc "Manage SELinux policy modules using the semodule binary." - - commands :semodule => "/usr/sbin/semodule" - - def create - begin - execoutput("#{command(:semodule)} --install #{selmod_name_to_filename}") - rescue Puppet::ExecutionFailure => detail - raise Puppet::Error, "Could not load policy module: %s" % [detail]; - end - return :true - end - - def destroy - begin - execoutput("#{command(:semodule)} --remove #{@resource[:name]}") - rescue Puppet::ExecutionFailure => detail - raise Puppet::Error, "Could not remove policy module: %s" % [detail]; - end - end - - def exists? - self.debug "Checking for module #{@resource[:name]}" - execpipe("#{command(:semodule)} --list") do |out| - out.each do |line| - if line =~ /#{@resource[:name]}\b/ - return :true - end - end - end - return nil - end - - def syncversion - self.debug "Checking syncversion on #{@resource[:name]}" - - loadver = selmodversion_loaded - - if(loadver) then - filever = selmodversion_file - if (filever == loadver) then - return :true - end - end - return :false - end - - def syncversion= (dosync) - begin - execoutput("#{command(:semodule)} --upgrade #{selmod_name_to_filename}") - rescue Puppet::ExecutionFailure => detail - raise Puppet::Error, "Could not upgrade policy module: %s" % [detail]; - end - end - - # Helper functions - - def execoutput (cmd) - output = '' - begin - execpipe(cmd) do |out| - output = out.readlines.join('').chomp! - end - rescue Puppet::ExecutionFailure - raise Puppet::ExecutionFailure, output.split("\n")[0] - end - return output - end - - def selmod_name_to_filename - if @resource[:selmodulepath] - return @resource[:selmodulepath] - else - return "#{@resource[:selmoduledir]}/#{@resource[:name]}.pp" - end - end - - def selmod_readnext (handle) - len = handle.read(4).unpack('L')[0] - return handle.read(len) - end - - def selmodversion_file - magic = 0xF97CFF8F - - filename = selmod_name_to_filename - mod = File.new(filename, "r") - - (hdr, ver, numsec) = mod.read(12).unpack('LLL') - - if hdr != magic - raise Puppet::Error, "Found #{hdr} instead of magic #{magic} in #{filename}" - end - - if ver != 1 - raise Puppet::Error, "Unknown policy file version #{ver} in #{filename}" - end - - # Read through (and throw away) the file section offsets, and also - # the magic header for the first section. - - mod.read((numsec + 1) * 4) - - ## Section 1 should be "SE Linux Module" - - selmod_readnext(mod) - selmod_readnext(mod) - - # Skip past the section headers - mod.read(14) - - # Module name - selmod_readnext(mod) - - # At last! the version - - v = selmod_readnext(mod) - - self.debug "file version #{v}" - return v - end - - def selmodversion_loaded - lines = () - begin - execpipe("#{command(:semodule)} --list") do |output| - lines = output.readlines - lines.each do |line| - line.chomp! - bits = line.split - if bits[0] == @resource[:name] then - self.debug "load version #{bits[1]}" - return bits[1] - end - end - end - rescue Puppet::ExecutionFailure - raise Puppet::ExecutionFailure, "Could not list policy modules: %s" % [lines.join(' ').chomp!] - end - return nil - end -end diff --git a/lib/puppet/type/file.rb b/lib/puppet/type/file.rb index cd1528e73..3518e8bb3 100644 --- a/lib/puppet/type/file.rb +++ b/lib/puppet/type/file.rb @@ -1148,5 +1148,4 @@ module Puppet require 'puppet/type/file/group' require 'puppet/type/file/mode' require 'puppet/type/file/type' - require 'puppet/type/file/selcontext' # SELinux file context end diff --git a/lib/puppet/type/file/selcontext.rb b/lib/puppet/type/file/selcontext.rb deleted file mode 100644 index f36695075..000000000 --- a/lib/puppet/type/file/selcontext.rb +++ /dev/null @@ -1,96 +0,0 @@ -# Manage SELinux context of files. -# -# This code actually manages three pieces of data in the context. -# -# [root@delenn files]# ls -dZ / -# drwxr-xr-x root root system_u:object_r:root_t / -# -# The context of '/' here is 'system_u:object_r:root_t'. This is -# three seperate fields: -# -# system_u is the user context -# object_r is the role context -# root_t is the type context -# -# All three of these fields are returned in a single string by the -# output of the stat command, but set individually with the chcon -# command. This allows the user to specify a subset of the three -# values while leaving the others alone. -# -# See http://www.nsa.gov/selinux/ for complete docs on SELinux. - -module Puppet - class SELFileContext < Puppet::Property - - def retrieve - unless @resource.stat(false) - return :absent - end - context = `stat -c %C #{@resource[:path]}` - context.chomp! - if context == "unlabeled" - return nil - end - unless context =~ /^[a-z0-9_]+:[a-z0-9_]+:[a-z0-9_]+/ - raise Puppet::Error, "Invalid output from stat: #{context}" - end - bits = context.split(':') - ret = { - :seluser => bits[0], - :selrole => bits[1], - :seltype => bits[2] - } - return ret[name] - end - - def sync - unless @resource.stat(false) - stat = @resource.stat(true) - unless stat - return nil - end - end - - flag = '' - - case name - when :seluser - flag = "-u" - when :selrole - flag = "-r" - when :seltype - flag = "-t" - else - raise Puppet::Error, "Invalid SELinux file context component: #{name}" - end - - self.debug "Running chcon #{flag} #{@should} #{@resource[:path]}" - retval = system("chcon #{flag} #{@should} #{@resource[:path]}") - unless retval - error = Puppet::Error.new("failed to chcon %s" % [@resource[:path]]) - raise error - end - return :file_changed - end - end - - Puppet.type(:file).newproperty(:seluser, :parent => Puppet::SELFileContext) do - desc "What the SELinux User context of the file should be." - - @event = :file_changed - end - - Puppet.type(:file).newproperty(:selrole, :parent => Puppet::SELFileContext) do - desc "What the SELinux Role context of the file should be." - - @event = :file_changed - end - - Puppet.type(:file).newproperty(:seltype, :parent => Puppet::SELFileContext) do - desc "What the SELinux Type context of the file should be." - - @event = :file_changed - end - -end - diff --git a/lib/puppet/type/selboolean.rb b/lib/puppet/type/selboolean.rb deleted file mode 100644 index d12dd3bcb..000000000 --- a/lib/puppet/type/selboolean.rb +++ /dev/null @@ -1,29 +0,0 @@ -# -# Simple module for manageing SELinux booleans -# - -module Puppet - newtype(:selboolean) do - @doc = "Enable or disable SELinux booleans." - - newparam(:name) do - desc "The name of the SELinux boolean to be managed." - isnamevar - end - - newproperty(:value) do - desc "Whether the the SELinux boolean should be enabled or disabled. Possible values are ``on`` or ``off``." - newvalue(:on) - newvalue(:off) - end - - newparam(:persistent) do - desc "If set true, SELinux booleans will be written to disk and persist accross reboots." - - defaultto :false - newvalues(:true, :false) - end - - end -end - diff --git a/lib/puppet/type/selmodule.rb b/lib/puppet/type/selmodule.rb deleted file mode 100644 index 1f02912ad..000000000 --- a/lib/puppet/type/selmodule.rb +++ /dev/null @@ -1,50 +0,0 @@ -# -# Simple module for manageing SELinux policy modules -# - -Puppet::Type.newtype(:selmodule) do - @doc = "Enable or disable SELinux policy modules." - - ensurable - - newparam(:name) do - desc "The name of the SELinux policy to be managed." - isnamevar - end - - newparam(:selmoduledir) do - - desc "The directory to look for the compiled pp module file in. - Currently defaults to /usr/share/selinux/targeted" - - defaultto "/usr/share/selinux/targeted" - end - - newparam(:selmodulepath) do - - desc "The full path in which to look for the compiled pp - module file in. You only need to use this if the module file - is not in the directory pointed at by selmoduledir." - - end - - newproperty(:syncversion) do - - desc "If set to 'true', the policy will be reloaded if the - version found in the on-disk file differs from the loaded - version. If set to 'false' (the default) the the only check - that will be made is if the policy is loaded at all or not." - - newvalue(:true) - newvalue(:false) - end - - autorequire(:file) do - if self[:selmodulepath] - [self[:selmodulepath]] - else - ["#{self[:selmoduledir]}/#{self[:name]}.pp"] - end - end -end - diff --git a/spec/unit/other/selinux.rb b/spec/unit/other/selinux.rb deleted file mode 100644 index 0974b71c3..000000000 --- a/spec/unit/other/selinux.rb +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/env ruby - -require File.dirname(__FILE__) + '/../../spec_helper' - -require 'puppet/type/selboolean' -require 'puppet/type/selmodule' - -describe Puppet::Type::File, " when manipulating file contexts" do - before :each do - @file = Puppet.type(:file).create( - :path => "/tmp/foo", - :ensure => "file", - :seluser => "user_u", - :selrole => "role_r", - :seltype => "type_t") - end - it "should use :seluser to get/set an SELinux user file context attribute" do - @file[:seluser].should == "user_u" - end - it "should use :selrole to get/set an SELinux role file context attribute" do - @file[:selrole].should == "role_r" - end - it "should use :seltype to get/set an SELinux user file context attribute" do - @file[:seltype].should == "type_t" - end -end - -describe Puppet::Type::Selboolean, " when manipulating booleans" do - before :each do - @bool = Puppet.type(:selboolean).create( - :name => "foo", - :value => "on", - :persistent => true) - end - it "should be able to access :name" do - @bool[:name].should == "foo" - end - it "should be able to access :value" do - @bool[:value].should == :on - end - it "should set :value to off" do - @bool[:value] = :off - @bool[:value].should == :off - end - it "should be able to access :persistent" do - @bool[:persistent].should == :true - end - it "should set :persistent to false" do - @bool[:persistent] = false - @bool[:persistent].should == :false - end -end - -describe Puppet::Type::Selmodule, " when checking policy modules" do - before :each do - @module = Puppet.type(:selmodule).create( - :name => "foo", - :selmoduledir => "/some/path", - :selmodulepath => "/some/path/foo.pp", - :syncversion => true) - end - it "should be able to access :name" do - @module[:name].should == "foo" - end - it "should be able to access :selmoduledir" do - @module[:selmoduledir].should == "/some/path" - end - it "should be able to access :selmodulepath" do - @module[:selmodulepath].should == "/some/path/foo.pp" - end - it "should be able to access :syncversion" do - @module[:syncversion].should == :true - end - it "should set the syncversion value to false" do - @module[:syncversion] = :false - @module[:syncversion].should == :false - end -end -- cgit From d9aa5ab68fb3196f5db526050c440c470b55a5f6 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Mon, 21 Jul 2008 13:16:08 -0500 Subject: Fixing a cert test to pass on Darwin. Darwin has a case-insensitive FS, so the test was failing because it was specifically testing case sensitivity. Signed-off-by: Luke Kanies --- lib/puppet/sslcertificates/support.rb | 1 + test/certmgr/support.rb | 43 +++++++++++++++++++++-------------- 2 files changed, 27 insertions(+), 17 deletions(-) diff --git a/lib/puppet/sslcertificates/support.rb b/lib/puppet/sslcertificates/support.rb index 95f15f0a8..bab250d47 100644 --- a/lib/puppet/sslcertificates/support.rb +++ b/lib/puppet/sslcertificates/support.rb @@ -28,6 +28,7 @@ module Puppet::SSLCertificates::Support # Define the reading method. define_method(reader) do + p Puppet[param] return nil unless FileTest.exists?(Puppet[param]) or rename_files_with_uppercase(Puppet[param]) begin diff --git a/test/certmgr/support.rb b/test/certmgr/support.rb index c055cbca1..10d431939 100755 --- a/test/certmgr/support.rb +++ b/test/certmgr/support.rb @@ -79,22 +79,31 @@ class TestCertSupport < Test::Unit::TestCase end end - # Fixing #1382. - def test_uppercase_files_are_renamed_and_read - # Write a key out to disk in a file containing upper-case. - key = OpenSSL::PKey::RSA.new(32) - should_path = Puppet[:hostprivkey] - - dir, file = File.split(should_path) - newfile = file.sub(/^([a-z.]+)\./) { $1.upcase + "."} - upper_path = File.join(dir, newfile) - File.open(upper_path, "w") { |f| f.print key.to_s } - - user = CertUser.new - - assert_equal(key.to_s, user.read_key.to_s, "Did not read key in from disk") - assert(! FileTest.exist?(upper_path), "Upper case file was not removed") - assert(FileTest.exist?(should_path), "File was not renamed to lower-case file") - assert_equal(key.to_s, user.read_key.to_s, "Did not read key in from disk") + # Fixing #1382. This test will always fail on Darwin, because its + # FS is case-insensitive. + unless Facter.value(:operatingsystem) == "Darwin" + def test_uppercase_files_are_renamed_and_read + # 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 + + assert_equal(key.to_s, user.read_key.to_s, "Did not read key in from disk") + assert(! FileTest.exist?(upper_path), "Upper case file was not removed") + assert(FileTest.exist?(should_path), "File was not renamed to lower-case file") + assert_equal(key.to_s, user.read_key.to_s, "Did not read key in from disk") + end end end -- cgit From 8c2478b08a2cc196668cbadf8a4840a24fc61488 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Mon, 21 Jul 2008 13:20:47 -0500 Subject: Fixing puppet_module -- it needed the same node interface change. I wonder if anyone's actually using this... Signed-off-by: Luke Kanies --- ext/module_puppet | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/module_puppet b/ext/module_puppet index 978d660cc..8609e4411 100755 --- a/ext/module_puppet +++ b/ext/module_puppet @@ -180,7 +180,7 @@ node.classes = classes begin # Compile our configuration - catalog = Puppet::Node::Catalog.find(node.name, :node => node) + catalog = Puppet::Node::Catalog.find(node.name, :use_node => node) rescue => detail if Puppet[:trace] puts detail.backtrace -- cgit From ff36832ec1837f300e57bfd37ca877c356e24a8b Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Mon, 21 Jul 2008 13:58:33 -0500 Subject: Fixing the renaming code to skip missing directories. I couldn't get this to fail in a targeted regression test, but if it's not working, it causes a failure in the webrick tests. Signed-off-by: Luke Kanies --- lib/puppet/sslcertificates/support.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/puppet/sslcertificates/support.rb b/lib/puppet/sslcertificates/support.rb index bab250d47..d95944adc 100644 --- a/lib/puppet/sslcertificates/support.rb +++ b/lib/puppet/sslcertificates/support.rb @@ -28,7 +28,6 @@ module Puppet::SSLCertificates::Support # Define the reading method. define_method(reader) do - p Puppet[param] return nil unless FileTest.exists?(Puppet[param]) or rename_files_with_uppercase(Puppet[param]) begin @@ -129,6 +128,10 @@ module Puppet::SSLCertificates::Support def rename_files_with_uppercase(file) dir = File.dirname(file) short = File.basename(file) + + # If the dir isn't present, we clearly don't have the file. + #return nil unless FileTest.directory?(dir) + raise ArgumentError, "Tried to fix SSL files to a file containing uppercase" unless short.downcase == short real_file = Dir.entries(dir).reject { |f| f =~ /^\./ }.find do |other| other.downcase == short -- cgit From 8f5800f0608dff46407cb5f23ee73f314fe051e8 Mon Sep 17 00:00:00 2001 From: James Turnbull Date: Tue, 22 Jul 2008 16:00:54 +1000 Subject: Fixes #1445 and #1426 --- lib/puppet/provider/service/redhat.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/puppet/provider/service/redhat.rb b/lib/puppet/provider/service/redhat.rb index 48da577ec..3fad8bcfe 100755 --- a/lib/puppet/provider/service/redhat.rb +++ b/lib/puppet/provider/service/redhat.rb @@ -59,7 +59,11 @@ Puppet::Type.type(:service).provide :redhat, :parent => :init do def status if @resource[:hasstatus] == :true - service(@resource[:name], "status") + begin + service(@resource[:name], "status") + rescue + return :stopped + end else super end -- cgit