puppet条件语句语法错误

时间:2017-07-11 10:29:37

标签: puppet

我已经检查了官方木偶documentation并且语法看起来很好,但我仍然遇到语法错误。 有人可以检查问题是什么吗?

我正在使用puppet server 3.8。

class puppet {
  if $puppet_conf == 'default' {
  }
  elseif $puppet_conf == undef {
    file { '/etc/puppet/puppet.conf':
      ensure => present,
      owner  => "root",
      group  => "root",
      mode   => "644",
      source => "puppet:///modules/puppet/puppet.conf}",
      notify => Exec['puppet-restart'],
    }

    exec { 'puppet-restart':
      command     => '/usr/bin/touch /tmp/.puppet-restart',
      refreshonly => true,
    }
  }
  else {
    file { '/etc/puppet/puppet.conf':
      ensure => present,
      owner  => "root",
      group  => "root",
      mode   => "644",
      source => "puppet:///modules/puppet/${puppet_conf}",
      notify => Exec['puppet-restart'],
    }

    exec { 'puppet-restart':
      command     => '/usr/bin/touch /tmp/.puppet-restart',
      refreshonly => true,
    }
  }
}
  

错误:无法从远程服务器检索目录:SERVER上的错误400:'=='处的语法错误;在节点上的/etc/puppet/modules/puppet/manifests/init.pp:6预期'}'

1 个答案:

答案 0 :(得分:2)

Puppet DSL中没有elseif条件。您需要改为elsif。有关详细信息,请查看此处的文档:https://docs.puppet.com/puppet/3.8/lang_conditional.html#syntax