---
LICENSE | 2 +-
dist/secstate.spec | 2 +
remediation/puppet-modules/ifdefined/LICENSE | 10 +++++++
remediation/puppet-modules/ifdefined/README | 26 ++++++++++++++++++++
.../plugins/puppet/parser/functions/ifdefined.rb | 21 ++++++++++++++++
5 files changed, 60 insertions(+), 1 deletions(-)
create mode 100644 remediation/puppet-modules/ifdefined/LICENSE
create mode 100644 remediation/puppet-modules/ifdefined/README
create mode 100644
remediation/puppet-modules/ifdefined/plugins/puppet/parser/functions/ifdefined.rb
diff --git a/LICENSE b/LICENSE
index 1dd738f..16dd111 100644
--- a/LICENSE
+++ b/LICENSE
@@ -20,4 +20,4 @@ The pam puppet module:
BSD:
The OVAL to XHTML transform:
/etc/secstate/results_to_html.xsl
-
+ /usr/share/puppet/modules/ifdefined/*
diff --git a/dist/secstate.spec b/dist/secstate.spec
index 0ab9240..bf24209 100644
--- a/dist/secstate.spec
+++ b/dist/secstate.spec
@@ -68,6 +68,8 @@ rm -rf $RPM_BUILD_ROOT
# BSD
%config(noreplace) %{_sysconfdir}/secstate/results_to_html.xsl
+%dir /usr/share/puppet/modules/ifdefined
+/usr/share/puppet/modules/ifdefined/*
%changelog
* Fri Jul 16 2010 Marshall Miller <mmiller(a)tresys.com> 0.3-8
diff --git a/remediation/puppet-modules/ifdefined/LICENSE
b/remediation/puppet-modules/ifdefined/LICENSE
new file mode 100644
index 0000000..d170e97
--- /dev/null
+++ b/remediation/puppet-modules/ifdefined/LICENSE
@@ -0,0 +1,10 @@
+Copyright (c) 2010, Michael DeHaan, Puppet Labs
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are
permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice, this list of
conditions and the following disclaimer.
+ * 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.
+ * Neither the name of the Organization 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 COPYRIGHT HOLDERS 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 COPYRIGHT HOLDER 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.
diff --git a/remediation/puppet-modules/ifdefined/README
b/remediation/puppet-modules/ifdefined/README
new file mode 100644
index 0000000..6946e32
--- /dev/null
+++ b/remediation/puppet-modules/ifdefined/README
@@ -0,0 +1,26 @@
+This is a puppet module for using a variable if it is defined, and otherwise not
+doing anything with the variable.
+
+Example:
+
+file { "/path/to/foo.txt":
+ mode => ifdefined('mode')
+}
+
+This will do nothing if an external nodes tool does not set $mode, and if it is
+set, will use the mode, exactly as specified.
+
+This is a shortcut around this syntax:
+
+file { "/path/to/foo.txt":
+ mode ? {
+ '' : undef,
+ default : $mode
+ }
+}
+
+This will allow the file to stay as set on the system unless explicitly set,
+in other words.
+
+Michael DeHaan <michael(a)puppetlabs.com>
+
diff --git
a/remediation/puppet-modules/ifdefined/plugins/puppet/parser/functions/ifdefined.rb
b/remediation/puppet-modules/ifdefined/plugins/puppet/parser/functions/ifdefined.rb
new file mode 100644
index 0000000..2facc22
--- /dev/null
+++ b/remediation/puppet-modules/ifdefined/plugins/puppet/parser/functions/ifdefined.rb
@@ -0,0 +1,21 @@
+# ifdefined -- if a variable is defined, use it, otherwise use undef
+#
+# which means, for instance, "if this variable is defined, set the mode to it,
+# otherwise do nothing"
+#
+# allows:
+# $x = ifdefined('foo')
+#
+# Michael DeHaan <michael(a)puppetlabs.com>
+
+module Puppet::Parser::Functions
+ newfunction(:ifdefined, :type => :rvalue) do |args|
+ key = args[0]
+ value = lookupvar(key)
+ if value == ''
+ value = :undef # not nil
+ end
+ value
+ end
+end
+
--
1.7.2