elseIf statement confusion

2,875 views
Skip to first unread message

Aaron Shegrud

unread,
Apr 23, 2014, 4:16:39 PM4/23/14
to puppet...@googlegroups.com
I have a class
 
class whs::auth {
if ($macosx_productversion_major == '10.9'){
        file { 'authorization109':
                path    => '/System/Library/Security/authorization.plist',
                ensure  => file,
                owner   => 'root',
                group   => 'wheel',
                mode    => '0644',
                source  => 'puppet:///modules/whs/authorization-10.9.plist',
        }
        exec { 'auth.db' :
                command     => '/bin/mv /var/db/auth.db /var/db/auth.db.orig',
                subscribe   => File["authorization109"],
                refreshonly => true,
        }
}
elseif ($macosx_productversion_major == '10.8') {
        file { 'authorization108':
                path    => '/etc/authorization',
                ensure  => file,
                owner   => 'root',
                group   => 'wheel',
                mode    => '0644',
                source  => 'puppet:///modules/whs/authorization-10.8',
        }
}
}

This class works fine if I comment out the elseif statement. 
I highlighted the line that corresponds with the errors.

with the elseif statement I get this from my agent:

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Syntax error at '{'; expected '}' at /etc/puppet/modules/whs/manifests/auth.pp:21 on node aaronshegrud.___.___
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

if I remove the Parens I get an error saying:

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Syntax error at '=='; expected '}' at /etc/puppet/modules/whs/manifests/auth.pp:21 on node aaronshegrud.___.___
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

I don't know what I am doing wrong... 

Robin Bowes

unread,
Apr 23, 2014, 5:07:36 PM4/23/14
to puppet...@googlegroups.com
Read here:

http://docs.puppetlabs.com/puppet/latest/reference/lang_conditional.html#if-statements

In particular, note the spelling of elsif. :)

R.

Aaron Shegrud

unread,
Apr 23, 2014, 5:12:42 PM4/23/14
to puppet...@googlegroups.com
ahhhhhh damn it.
haha thanks.

Aaron Shegrud

unread,
Apr 23, 2014, 5:18:59 PM4/23/14
to puppet...@googlegroups.com
I'm serious I think I read that a million times and my dyslexia kicked in until you pointed it out.
thanks.

On Wednesday, April 23, 2014 2:07:36 PM UTC-7, Robin Bowes wrote:
Reply all
Reply to author
Forward
0 new messages