2016-08-18 64 views
0

我有以下条件语句。然而,每次我有一个elseif其次是一些时间我似乎得到一个错误:执行一些Puppet条件代码时出错

Error: Could not parse for environment production: Syntax error at 'in'; expected ')' at /etc/puppet/manifests/hash.pp:78 on node puppetmaster 
Error: Could not parse for environment production: Syntax error at 'in'; expected ')' at /etc/puppet/manifests/hash.pp:78 on node puppetmaster 


76 if $::operatingsystem in [ 'Ubuntu', 'Debian' ] { 
77 notify { 'Debian-type operating system detected': } 
78 } elseif $::operatingsystem in [ 'RedHat', 'Fedora', 'SuSE', 'CentOS' ] { 
79 notify { 'RedHat-type operating system detected': } 
80 } else { 
81 notify { 'Some other operating system detected': } 
82 } 
+0

。 –

+1

另外,它是'elsif',而不是'elseif'。 –

+0

你需要在整个'if'结尾处加上'end'。 –

回答

0

使用elsif,而不是elseif。使用elseif相当于"elseif",有没有办法让木偶知道你的意图:你不需要周围的花括号的if/else代码块

if $::operatingsystem in [ 'Ubuntu', 'Debian' ] { 
    notify{ 'Debian-type operating system detected': } 
} elsif $::operatingsystem in [ 'RedHat', 'Fedora', 'SuSE', 'CentOS' ] { 
    notify{'RedHat-type operating system detected': } 
} else { 
    notify{'Some other operating system detected': } 
}