2016-08-18 32 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': } 
}