0

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

Zoredache
  • 130,897
  • 41
  • 276
  • 420
Adrian
  • 45
  • 1
  • 2
  • 6

1 Answers1

0

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 {
    '<name>':
        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.

Felix Frank
  • 3,093
  • 1
  • 16
  • 22