I have a shell script to install nodejs module packages which should be execute after all packages are installed. I defined a stage 'last' after the Stage[main] here is my code

stage { 'last': }
Stage[main] -> Stage[last]
class npm {
        stage => last,
        file { '/tmp/nodejs.sh':
                 source => 'puppet:///modules/npm/nodejs.sh',
                 ensure => present,                
        exec { 'install web development nodejs packages':
               command => '/tmp/nodejs.sh',
               user => "root",
               require => Package['nodejs', 'npm']

However, it return an error

==> default: Error: Could not parse for environment production: Syntax error at '=>'; expected '}' at /tmp/vagrant-puppet-/manifests/init.pp:90 on node local.d ev

the line 90 is pointed at "stage => last,"


You are confusing two concepts that sadly share very similar syntax.

Class definition

class <name> {
    # includes of other classes ...
    # resource declarations ...

Class declaration

# usually
include <name>
# ...but if you need stages
class {
        stage => 'last'

The latter is known as resource-like class declaration (and it has some caveats).

Also note that stages are somewhat frowned upon in the community.

If you don't use virtual package resources, you can avoid the use of stages.

Package<| |> -> Exec['install web development nodejs packages']

This establishes a before relation from all package resources to your exec.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.