EPP template : elseif condition ?

asked 2017-11-10 10:51:47 -0600

craymore gravatar image

updated 2017-11-10 17:17:52 -0600

Hi dear puppeteers !

I was trying to implement some logic lately within an EPP template, and couldn't get an elsif strong textstatement to work

<% if $facts['os']['family'] == 'RedHat' { -%>
    <% if $facts['os']['release']['major'] == '7' { -%>

        <content>

    <% } elsif $facts['os']['release']['major'] == '6' { -%>

        <content>
    <% } -%>
<% } -%>

Does anyone know how to implement it ?

Thanks beforehand

edit retag flag offensive close merge delete

Comments

The keyword “elif”/“elsif” is just syntactic sugar of some languages. Usually the grammar expects `“else” block`, where /block/ can be “of course” another if-statement. So write “else if $facts… {” [or “else { if $facts… {”] https://puppet.com/docs/puppet/latest/lang_conditional.html#if-statements .

Kai Burghardt gravatar imageKai Burghardt ( 2017-11-10 17:16:51 -0600 )edit

Thanks for the advice !

craymore gravatar imagecraymore ( 2017-11-14 08:38:41 -0600 )edit