简体   繁体   中英

puppet: Syntax error at 'target'; expected '}' - parsing error

Syntax error while parsing puppet resource.

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

When I run puppet apply , following error is seen..

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

Was just a few missing commas at the end.

I generally always finish with a comma on the last line. It's not needed, but catches gotcha's that happen when you add an extra line to the end.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM