voxpupuli / puppet-nodejs

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

Cyclic dependency with Puppet 5 and recent versions of module #329

Closed rcousens closed 7 years ago

rcousens commented 7 years ago

Affected Puppet, Ruby, OS and module versions/distributions

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

  class { 'nodejs':
    repo_url_suffix => '4.x',
  }

What are you seeing

Error: Found 1 dependency cycle:
(Anchor[apt_key 9FD3B784BC1C6FC31A8A0A1C1655A0AB68576280 present] => Apt::Key[Add key: 9FD3B784BC1C6FC31A8A0A1C1655A0AB68576280 from Apt::Source nodesource] => Apt::Source[nodesource] => Package[apt-transport-https] => Apt::Source[nodesource] => Apt::Key[Add key: 9FD3B784BC1C6FC31A8A0A1C1655A0AB68576280 from Apt::Source nodesource] => Anchor[apt_key 9FD3B784BC1C6FC31A8A0A1C1655A0AB68576280 present])

What behaviour did you expect instead

NodeJS installed

Output log

Any additional information you'd like to impart

This is absolutely related to the require Package statements in the apt::source resource from repo/nodesource/apt.pp. I understand the necessity for the require as apt-transport-https must be present for apt-get update to work with the nodesource repo, but I am unsure how this creates a cyclic dependency.

rcousens commented 7 years ago

site.pp manifest

node default {

  Apt::Pin <| |> -> Package <| |>
  Apt::Source <| |> -> Package <| |>

  difference(lookup('classes', Array[String], 'unique'), lookup('rejected_classes', Array[String],'unique',[])).include
}

Removing the Apt::Source collector for packages fixes the problem. I feel like a dolt, however I also actually want Apt::Source to be applied before all packages are installed. Egg/chicken!

rcousens commented 7 years ago

I think this can be closed. I apologise for the fuss. I saw it was a previous problem with Puppet 3 and thought it was rearing its ugly head again. For me, the issue came solely because I had a site manifest using an Apt::Source resource collector to express a dependency on processing packages afterwards.

I've heard resource collectors are hacky and unwieldy and will bite you in the ass, I guess I just found out why! They override a lot of internal logic expressed in modules themselves. Thanks!