Jagga, It’s a simple error. You need to remove the square brackets from around your conditional test. Puppet is evaluating it as an array, and since puppet treats all non-boolean values (other than undef) as true, you will never get to the else block.
— Peter > On Apr 3, 2018, at 10:13 PM, Jagga Soorma <jagg...@gmail.com> wrote: > > Hi Guys, > > I am using foreman and puppet to provision/manage systems. I have a simple > motd module that I was using for all my systems but now have a need to setup > a different motd for a specific hostgroup/type of systems. So, I though I > would use the hostgroup hiera setup from foreman/puppet to decide which motd > to use. I wrote something quickly to test but have unexpected results and > was hoping someone here can help me make sense of this: > > -- > my hostgroup for system 1 is CSOE73_Prod/hpc/misc and for system 2 is > CSOE73_Prod/hpc/compute. So I decided to write the code this way: > > if [$hostgroup == 'CSOE73_Prod/hpc/misc'] { > file { "/etc/motd": > ensure => file, > content => template('clientos/motd.erb') > } > } > else { > file { "/etc/motd": > ensure => file, > source => 'puppet:///modules/clientos/etc/motd > <puppet:///modules/clientos/etc/motd>', > mode => 644, > owner => 'root', > group => 'root', > } > } > -- > > However, for both systems the motd.erb template is being applied. However, > my expectation was that for system 2 it would just use the files/etc/motd > file. Is it maybe the backslash in CSOE73_Prod/hpc/misc that might be > throwing it off? Am I going about this totally the wrong way? > > Any help would be greatly appreciated! > > Thanks, > -J -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/2019AE2E-05AC-4964-AC10-AD3A712ADD49%40gmail.com. For more options, visit https://groups.google.com/d/optout.