1

解析 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"
  }
}

当我运行 puppet apply 时,会看到以下错误..

[root@ip-10-172-161-25 manifests]# 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
4

1 回答 1

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",
 }
}

最后只是少了几个逗号。

我通常总是在最后一行以逗号结束。它不是必需的,但是当您在末尾添加额外的行时会遇到问题。

于 2013-08-29T16:01:01.250 回答