Page MenuHomePhabricator

role/phabricator.pp include a password class in the global puppet scope
Closed, ResolvedPublic

Description

When writing a basic RSpec test for puppet (T78342) I ended up with an error not being able to load passwords::mysql::phabricator

The root cause is manifests/role/phabricator.pp which: include passwords::mysql::phabricator
in the global puppet scope. That class is in labs/private.git repo, thus when RSpec loads the manifests it attempts to include it and fails.

The problem is worked around by providing a stub class, but we want to move that include down in the roles scope.

Event Timeline

hashar raised the priority of this task from to Needs Triage.
hashar updated the task description. (Show Details)
hashar changed Security from none to None.
hashar added subscribers: hashar, dduvall, Andrew and 2 others.

I thought that was kinda odd myself. But how does moving the include resolve the issue? Wouldn't the stub still be needed in either case?

Indeed that include should not be outside a class. Best way to do this is to put all that it in a ::config class and include it in any other role class that needs it. Otherwise it is polluting the global scope. Finally, I am not sure why RSpec is complaining about this. Why is it parsing that role anyway ?

Best way to do this is to put all that it in a ::config class and include it in any other role class that needs it.

+1 that was my thought when I saw this.

Indeed that include should not be outside a class. Best way to do this is to put all that it in a ::config class and include it in any other role class that needs it. Otherwise it is polluting the global scope. Finally, I am not sure why RSpec is complaining about this. Why is it parsing that role anyway ?

rspec puppet include manifests/site.pp which has:

import 'role/*.pp'

And thus include the rspec test ends up loading the phabricator role and ultimately the non existing password class :-)

Ah, OK, cause in my RSpec tests I test per module, avoiding this issue entirely. Granted I haven't gotten around to testing roles but moving all those role manifests to a module should not be too hard (famous last words)

Change 179930 had a related patch set uploaded (by Alexandros Kosiaris):
Move the top level variables in phabricator role in a class

https://gerrit.wikimedia.org/r/179930

Patch-For-Review

Change 179930 merged by Alexandros Kosiaris:
Move the top level variables in phabricator role in a class

https://gerrit.wikimedia.org/r/179930

mmodell mentioned this in Unknown Object (Diffusion Commit).Dec 16 2014, 11:25 AM
akosiaris claimed this task.

After I ran a (noop) catalog compiling test, I merged and ran puppet on iridium. No changes as expected, resolving this