Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
erb logic with a hiera value
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  3 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Wolf Noble  
View profile  
 More options May 19 2012, 12:57 pm
From: Wolf Noble <wno...@datapipe.com>
Date: Sat, 19 May 2012 16:57:14 +0000
Local: Sat, May 19 2012 12:57 pm
Subject: erb logic with a hiera value

so I've set a  hiera key, and trying to display some different data in motd depending on if the value of said key is true or false… it gets set accordingly.. but my motd template doesn't seem to be properly reacting when the value of it changes..

it's as if the variable never matches "true"
not sure what I'm doing wrong here…. I SUSPECT 'true' isn't being perceived as such somehow…

Can anyone spot what I'm missing?

bash-3.2$ cat /etc/puppetlabs/puppet/modules/core/manifests/values.pp
#
# core::values
# a class for namespaceing variables not specifically linked to any other module.
class core::values {
       $foostatus = hiera('core_values_foo')

}

bash-3.2$ cat hieradata/(extraneous tree pruned)/Prod/common.yaml
core_values_foo: - true

bash-3.2$ cat hieradata//common.yaml
core_values_foo: - false

bash-3.2$ cat core/motd/templates/motd.erb
<% foostatus = scope.lookupvar('core::values::foostatus') -%>
## Configuration Notice ##----------------------------------
The configuration of <%= hostname -%> is managed by Puppet.
### QuickStats from last puppetrun
  RAM: <%= memorysize -%> ::
  <%= lsbdistdescription %>
  Kernel: <%= kernelrelease %>
  Internal IP: <%= ipaddress %>
###########################################################
<% if foostatus  == "true"  -%>
 |   foo is true  |
 `****************************************************'
<% else -%>
 |   foo is not true   |
 `****************************************************'
<% end-%>
<%= foostatus %>
bash-3.2$

[root@bookworm ~]# cat /etc/motd
## Configuration Notice ##----------------------------------
The configuration of bookworm is managed by Puppet.
### QuickStats from last puppetrun
  RAM: 512.18 MB ::
  CentOS release 5.8 (Final)
  Kernel: 2.6.18-308.4.1.el5xen
  Internal IP: 123.123.123.123
###########################################################
 |   foo is not true   |
 `****************************************************'
true

if I remove the entry which is setting it to true in hieradata/(pruned)Prod/common.yaml:

[root@bookworm ~]# cat /etc/motd
## Configuration Notice ##----------------------------------
The configuration of bookworm is managed by Puppet.
### QuickStats from last puppetrun
  RAM: 512.18 MB ::
  CentOS release 5.8 (Final)
  Kernel: 2.6.18-308.4.1.el5xen
  Internal IP: 123.123.123.123
###########################################################
 |   foo is not true    |
 `****************************************************'
false

________________________________

This message may contain confidential or privileged information. If you are not the intended recipient, please advise us immediately and delete this message. See http://www.datapipe.com/legal/email_disclaimer/ for further information on confidentiality and the risks of non-secure electronic communication. If you cannot access these links, please notify us by reply message and we will send the contents to you.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gary Larizza  
View profile  
 More options May 19 2012, 12:59 pm
From: Gary Larizza <g...@puppetlabs.com>
Date: Sat, 19 May 2012 09:59:09 -0700
Local: Sat, May 19 2012 12:59 pm
Subject: Re: [Puppet Users] erb logic with a hiera value

This is the problem - you're trying to compare a boolean value of true to a
string value of 'true'.  Just do something like:

<% if foostatus -%>

That should work for you :)

--

Gary Larizza
Professional Services Engineer
Puppet Labs


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Wolf Noble  
View profile  
 More options May 19 2012, 1:11 pm
From: Wolf Noble <wno...@datapipe.com>
Date: Sat, 19 May 2012 17:11:49 +0000
Local: Sat, May 19 2012 1:11 pm
Subject: Re: [Puppet Users] erb logic with a hiera value
Thanks Gary,

I knew it was something simple.

Appreciate the help

<% if foostatus  == "true"  -%>

This is the problem - you're trying to compare a boolean value of true to a string value of 'true'.  Just do something like:

<% if foostatus -%>

That should work for you :)

________________________________

This message may contain confidential or privileged information. If you are not the intended recipient, please advise us immediately and delete this message. See http://www.datapipe.com/legal/email_disclaimer/ for further information on confidentiality and the risks of non-secure electronic communication. If you cannot access these links, please notify us by reply message and we will send the contents to you.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »