https://bugzilla.redhat.com/show_bug.cgi?id=766697
This adds a new parser function to ensure a list of variable names is
defined. This function is in turn used by the rhevm and vsphere
profiles to make sure all required config parameters are set,
otherwise failing with a sane error message.
---
.../lib/puppet/parser/functions/ensure_vardef.rb | 14 ++++++++++++++
recipes/aeolus/manifests/profiles/rhevm.pp | 12 ++++++++++++
recipes/aeolus/manifests/profiles/vsphere.pp | 10 ++++++++++
3 files changed, 36 insertions(+), 0 deletions(-)
create mode 100644 recipes/aeolus/lib/puppet/parser/functions/ensure_vardef.rb
diff --git a/recipes/aeolus/lib/puppet/parser/functions/ensure_vardef.rb
b/recipes/aeolus/lib/puppet/parser/functions/ensure_vardef.rb
new file mode 100644
index 0000000..b72c0f0
--- /dev/null
+++ b/recipes/aeolus/lib/puppet/parser/functions/ensure_vardef.rb
@@ -0,0 +1,14 @@
+Puppet::Parser::Functions::newfunction(:ensure_vardef,
+ :type => :rvalue,
+ :doc => <<ENDDOC
+Validate that one or more variables are defined. Returns the first
+undefined variable name found; if all variables are defined, return
+false.
+ENDDOC
+) do |args|
+ undefined = false
+ args.each do |param|
+ undefined = param if ['', :undefined].include?(lookupvar(param)) and not
undefined
+ end
+ undefined
+end
diff --git a/recipes/aeolus/manifests/profiles/rhevm.pp
b/recipes/aeolus/manifests/profiles/rhevm.pp
index 1d5d73d..942fef1 100644
--- a/recipes/aeolus/manifests/profiles/rhevm.pp
+++ b/recipes/aeolus/manifests/profiles/rhevm.pp
@@ -13,6 +13,18 @@
# limitations under the License.
class aeolus::profiles::rhevm {
+ $missing = ensure_vardef("rhevm_nfs_server",
+ "rhevm_nfs_export",
+ "rhevm_nfs_mount_point",
+ "rhevm_deltacloud_username",
+ "rhevm_deltacloud_password",
+ "rhevm_deltacloud_provider",
+ "rhevm_push_timeout")
+
+ if $missing {
+ fail("Missing required parameter ${missing} in
/etc/aeolus-configure/nodes/rhevm_configure")
+ }
+
file {"/etc/imagefactory/rhevm.json":
content => template("aeolus/rhevm.json"),
mode => 755,
diff --git a/recipes/aeolus/manifests/profiles/vsphere.pp
b/recipes/aeolus/manifests/profiles/vsphere.pp
index 0d511bf..009ca2b 100644
--- a/recipes/aeolus/manifests/profiles/vsphere.pp
+++ b/recipes/aeolus/manifests/profiles/vsphere.pp
@@ -13,6 +13,16 @@
# limitations under the License.
class aeolus::profiles::vsphere {
+ $missing = ensure_vardef("vsphere_deltacloud_provider",
+ "vsphere_username",
+ "vsphere_password",
+ "vsphere_datastore",
+ "vsphere_network_name")
+
+ if $missing {
+ fail("Missing required parameter ${missing} in
/etc/aeolus-configure/nodes/vsphere_configure")
+ }
+
aeolus::create_bucket{"aeolus":}
file {"/etc/imagefactory/vsphere.json":
--
1.7.7.4