puppet:'target'处的语法错误;期待'}' - 解析错误

时间:2013-08-28 21:16:54

标签: puppet nagios

解析puppet资源时出现语法错误。

    class nagios::export {
      @@nagios_host { $::fqdn:
        address       => $::ipaddress,
        use           => "linux-server",
        check_command => 'check-host-alive!3000.0,80%!5000.0,100%!10',
        hostgroups    => 'all-servers',
        target        => "/etc/nagios/resource.d/host_${::fqdn}.cfg"
      }


    @@nagios_service { "check_ping_${hostname}":
         check_command => "check-host-alive!100.0,20%!500.0,60%",
         use => "generic-service",
         host_name => "$fqdn",
         notification_period => "24x7",
         #target => "/etc/nagios/resource.d/service_${::fqdn}.cfg"
         service_description => "${hostname}_check_ping"
         target => "/etc/nagios/resource.d/service_${::fqdn}.cfg"
  }
}

当我运行木偶申请时,会看到以下错误。

[root @ ip-10-172-161-25所示]#puppet apply export.pp --noop

Could not parse for environment production: Syntax error at 'target'; expected '}' at /etc/puppet/modules/nagios/manifests/export.pp:28 on node ip-10-172-161-25.us-west-1.compute.internal

1 个答案:

答案 0 :(得分:1)

class nagios::export {
  @@nagios_host { $::fqdn:
    address       => $::ipaddress,
    use           => "linux-server",
    check_command => 'check-host-alive!3000.0,80%!5000.0,100%!10',
    hostgroups    => 'all-servers',
    target        => "/etc/nagios/resource.d/host_${::fqdn}.cfg",
  }


@@nagios_service { "check_ping_${hostname}":
     check_command => "check-host-alive!100.0,20%!500.0,60%",
     use => "generic-service",
     host_name => "$fqdn",
     notification_period => "24x7",
     #target => "/etc/nagios/resource.d/service_${::fqdn}.cfg",
     service_description => "${hostname}_check_ping",
     target => "/etc/nagios/resource.d/service_${::fqdn}.cfg",
 }
}

最后只有几个丢失的逗号。

我通常总是在最后一行用逗号结束。它不是必需的,但是当你在末尾添加一条额外的行时会发生陷阱。