Search code examples
puppet

Class parameter syntax errors


I am trying to learn to write puppet modules in a good way, so I've started looking around for tutorials and howto.

I've seen that users suggest writing the main class in the following way, but It's actually failing for me. I am honestly a bit confused how the 2 blocks between brackets are actually connected, and so I might be not seeing an obvious error or real missing comma.

I am running Puppet 3.8 by the way

class icinga2 {
    $version = 'present'
    $enable = true
    $start = true
} {
    class{'icinga2::install': } ->
    class{'icinga2::config': } ~>
    class{'icinga2::service': } ->
    Class["icinga2"]
}

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Syntax error at '{'; expected '}' at /etc/puppet/modules/icinga2/manifests/init.pp:5


Solution

  • Your problem here is that your parameters must be surrounded by (), not {}. Also, they should be commas separated.

    class icinga2 (
        $version = 'present',
        $enable = true,
        $start = true,
    ) {
        class{'icinga2::install': } ->
        class{'icinga2::config': } ~>
        class{'icinga2::service': } ->
        Class["icinga2"]
    }