Ask Your Question
0

Broken dependency ordering?

asked 2014-11-12 18:25:11 -0500

Naftuli Tzvi Kay gravatar image

I have a pretty simple case where I have a Vagrant box for running a Grunt web application. Here's my dependency chain:

manifests/vagrant.pp

node "vagrant-trusty64" {
    require app::node,
        app::npm,
        app::buildessential,
        app::git
}

modules/app/manifests/npm.pp

class app::npm {
    contain app::npm::install, app::npm::packages

    Class["App::Npm::Install"] ->
    Class["App::Npm::Packages"]
}

modules/app/manifests/npm/install.pp

class app::npm::install {
    package { "npm":
        ensure => present,
        require => Class["App::Node"]
    }
}

modules/app/manifests/npm/packages.pp

class app::npm::packages {
    require app::npm::install

    contain app::npm::packages::generator_angular,
        app::npm::packages::grunt,
        app::npm::packages::yo

    Class["App::Npm::Install"] ->
    Class["App::Npm::Packages::Grunt"] ->
    Class["App::Npm::Packages::Yo"] ->
    Class["App::Npm::Packages::Generator_angular"]
}

modules/app/manifests/npm/packages/generator_angular.pp

class app::npm::packages::generator_angular {
    package { "generator-angular":
        ensure => present,
        provider => "npm"
    }
}

The rest have been omitted for brevity. This fails with the following error:

Error: Parameter provider failed on Package[generator-angular]: Invalid package provider 'npm' at /tmp/vagrant-puppet-1/modules-0/app/manifests/npm/packages/generator_angular.pp:5
Wrapped exception:
Invalid package provider 'npm'

Why is this failing? I have specified clearly in app::npm::packages that the order is that app::npm::install should be run in its entirety before any NPM packages should be installed, yet it still fails.

I'm really confused as to how Puppet handles dependency ordering and I can't seem to get things right when using classes.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2014-11-12 19:10:25 -0500

DJB gravatar image

Maybe try using staging resource.

class app::npm {
  class { 'app::npm::stages': }
}

Then have the stages defined within the called class

class app::npm::stages {
  stage { 'setup': before => Stage['main'] }
  stage { 'runtime': require => Stage['main'] }
  -> stage { 'setup_app': }
  -> stage { 'deploy_app': }

  class { 'app::npm::install': stage => setup}
  class { 'app:npm::packages::grunt': => main}
  class { 'app:npm::packaages::yo': => runtime}
  class { 'app:npm::packages::generator_angula': => setup_app}
}

Hopefully this makes sense?

edit flag offensive delete link more

Comments

Sure, I can try it. Can you link me to docs on the staging resource? I've never used it before.

Naftuli Tzvi Kay gravatar imageNaftuli Tzvi Kay ( 2014-11-13 12:08:17 -0500 )edit

I'm still getting `Invalid package provider 'npm' ` with this code.

Naftuli Tzvi Kay gravatar imageNaftuli Tzvi Kay ( 2014-11-13 15:02:31 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-11-12 18:25:11 -0500

Seen: 334 times

Last updated: Nov 12 '14