voxpupuli / puppet-nodejs

Puppet module to install nodejs and global npm packages
https://forge.puppet.com/puppet/nodejs
Apache License 2.0
113 stars 248 forks source link

Ubutnu 16.04 second provisioning fails & puts node.js in invalid state #360

Closed MichaelMackus closed 6 years ago

MichaelMackus commented 6 years ago

Affected Puppet, Ruby, OS and module versions/distributions

How to reproduce (e.g Puppet code you use)

class { '::nodejs' }

What are you seeing

First provision, everything works fine. Second time I provision the server (no matter what combination of repo_url_suffix or manage_repo settings), I get a circular symlink error. It seems like /usr/bin/node is symlinked to /etc/alternatives/nodejs which is also symlinked to /usr/bin/node!

What behaviour did you expect instead

Idempotent node.js installation, no matter how many times provision is run.

Output log

Notice: /Stage[main]/Nodejs::Install/File[/usr/bin/node]/ensure: ensure changed 'file' to 'link'
Notice: /Stage[main]/Nodejs::Install/File[/usr/share/man/man1/node.1.gz]/ensure: ensure changed 'file' to 'link'
Error: Execution of '/usr/local/bin/npm install --global bower' returned 126: /usr/bin/env: 'node': Too many levels of symbolic links
Error: /Stage[main]/Base::Provision::Nodejs/Package[bower]/ensure: change from 'absent' to 'present' failed: Execution of '/usr/local/bin/npm install --global bower' returned 126: /usr/bin/env: 'node': Too many levels of symbolic links
Error: Execution of '/usr/local/bin/npm install --global yarn' returned 126: /usr/bin/env: 'node': Too many levels of symbolic links
Error: /Stage[main]/Base::Provision::Nodejs/Package[yarn]/ensure: change from 'absent' to 'present' failed: Execution of '/usr/local/bin/npm install --global yarn' returned 126: /usr/bin/env: 'node': Too many levels of symbolic links
MichaelMackus commented 6 years ago

NOTE: the yarn package I'm installing doesn't seem to matter, it is just showing the underlying issue of the circular symlink created by puppet-nodejs. The relevant lines (that shouldn't be happening) are the first 2 lines in the output log above. Node.js is working before this point, and if puppet-nodejs can be stopped from creating the circular symlink this issue will be solved.

Also note, the first provision installs Node.js & NPM correctly. Here are the relevant output lines after the first provision:

Notice: /Stage[main]/Nodejs::Install/File[/usr/bin/node]/ensure: created
Notice: /Stage[main]/Nodejs::Install/File[/usr/share/man/man1/node.1.gz]/ensure: created
Notice: /Stage[main]/Nodejs::Install/Package[nodejs]/ensure: created

Afterwards, if I run provision again, it puts the system in an invalid state. This is even more so annoying since apt-get remove nodejs doesn't work due to the circular symlinks (which have to be manually removed first).

juniorsysadmin commented 6 years ago

@MichaelMackus We dropped symlink management in #347 , which is in 5.0.0. Can verify the source and version of the module that you are using?

MichaelMackus commented 6 years ago

Hmm. I'm using 5.0.0 of puppet-nodejs, commit SHA c77134280b7e30f3c8a94448e04de5c238e6c89c - looks like that's the latest commit according to Github.

MichaelMackus commented 6 years ago

OK that was weird! Looks like my puppet module inside the container was different than the one on my host (which is 5.0.0). I did a quick update of the module, and everything is working as expected now!

Sorry for the false alarm. In any case, glad this is figured out, was a huge annoyance.