Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

/usr/bin/npm doesn't exist when setting a nodejs::npm::global_config_entry #214

Closed
dandunckelman opened this issue Apr 12, 2016 · 10 comments
Labels
needs-feedback Further information is requested

Comments

@dandunckelman
Copy link

On a fresh install of an Ubuntu v14.04 node I come across an issue where Puppet fails to set the global_config_entry because /usr/bin/npm doesn't exist.

Here's my manifest:

class ta_linux::ta_nodejs(                                           
  $npm_packages = {},                                                
) {                                                                  
  validate_hash($npm_packages)                                       

  $npm_package_defaults = {                                          
    'require' => Nodejs::Npm::Global_config_entry['strict-ssl'],     
    'target'  => '/usr/lib',                                         
  }                                                                  

  class { '::nodejs':                                                
    manage_package_repo       => false,                              
    nodejs_dev_package_ensure => present,                            
    npm_package_ensure        => present,                            
  }->                                                                

  nodejs::npm::global_config_entry { 'strict-ssl':                   
    ensure  => present,                                              
    value   => false,                                                
  }                                                                  

  create_resources(nodejs::npm, $npm_packages, $npm_package_defaults)
}

When I run my acceptance test for this manifest, it works as expected.

But when I run my acceptance test for another class that loads this ta_linux::ta_nodejs class, it results in this error:

Error: /bin/sh: /usr/bin/npm: No such file or directory

Error: /Stage[main]/Ta_linux::Ta_nodejs/Nodejs::Npm::Global_config_entry[strict-ssl]/Exec[npm_config present strict-ssl]/returns: change from notrun to 0 failed: /bin/sh: /usr/bin/npm: No such file or directory

I have the require relationship between the nodejs class and the global_config_entry define, but that doesn't enforce the installation of npm before trying to set that configuration option.

Obviously, this is pretty obscure and difficult to reproduce (outside of my own environment), but if anyone has any insight here, I'm all ears.

Thanks

@dandunckelman
Copy link
Author

Not sure that it makes a difference, but I've also had the nodejs class like this:

class { '::nodejs': }->

and had the same results

@jyaworski
Copy link
Member

AFAIK, you can't have a require relationship on a define.

However, it does seem like we should add an include ::nodejs to that define.

@rnelson0
Copy link
Member

Maybe split into two subclasses and contain them. Then order the two,
Class[a] -> Class [b]. You could try the spaceship collector but it's
possible a resource in the class will be out orpf order, unless you contain
the whole thing.

Rob Nelson
[email protected]

@juniorsysadmin
Copy link
Member

@dandunckelman Is this still an issue with the latest release?

@dandunckelman
Copy link
Author

@juniorsysadmin yes. On a 2nd puppet run, it is resolved...so it's not a deal breaker

@jyaworski
Copy link
Member

Tagging @ghoneycutt as this looks like the problem that #221 was supposed to solve.

@ghoneycutt
Copy link
Member

You shouldn't need the arrow syntax. The define will include the nodejs class. You are mixing include ::nodejs which happens in the define with the parameterized class syntax. Perhaps that is causing you trouble.

@dandunckelman
Copy link
Author

I've since updated my class to this:

class ta_linux::ta_nodejs(
  $npm_packages = {},
) {
  validate_hash($npm_packages)

  $npm_package_defaults = {
    'provider' => 'npm',
    'require'  => Class['nodejs'],
  }

  class { 'nodejs': }

  nodejs::npm::global_config_entry { 'strict-ssl':
    ensure => present,
    value  => false,
  }

  Class['::nodejs'] -> Package <| provider == 'npm' |>

  create_resources(package, $npm_packages, $npm_package_defaults)
}

and still receive the error on the first run when the ta_linux::ta_nodejs class is loaded by another class like this:

class ta_apps::portal_web() {
  # other stuff to install packages, rvm, apache, and other stuff

  class { 'ta_linux::ta_nodejs':
    npm_packages => {
      'forever' => {
        'ensure' => hiera("pkg_ensure_forever"),
      },
    },
  }
}

@juniorsysadmin juniorsysadmin added the needs-feedback Further information is requested label Aug 31, 2016
@juniorsysadmin
Copy link
Member

Can anyone else report that this is still occurring?

@juniorsysadmin
Copy link
Member

Closing due to no further reports providing confirmation of a bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-feedback Further information is requested
Projects
None yet
Development

No branches or pull requests

5 participants