【问题标题】:puppet conditional statement syntax errorpuppet条件语句语法错误
【发布时间】:2017-12-15 08:44:05
【问题描述】:

我已经检查了官方 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,
    }
  }
}

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

【问题讨论】:

    标签: puppet


    【解决方案1】:

    Puppet DSL 中没有 elseif 条件。您需要输入elsif。在此处查看文档以获取更多信息:https://docs.puppet.com/puppet/3.8/lang_conditional.html#syntax

    【讨论】:

    • 天哪!由于忽略了角色而浪费了很多时间,非常感谢! :D
    猜你喜欢
    • 2014-02-11
    • 2012-11-21
    • 1970-01-01
    • 2015-07-21
    • 1970-01-01
    • 2012-11-30
    • 2014-09-12
    • 2023-01-13
    • 2011-09-22
    相关资源
    最近更新 更多