Bug #811

Moving class from manifest to module causes odd breakage

Added by Thom May over 4 years ago. Updated over 4 years ago.

Status:Closed Start date:
Priority:Normal Due date:
Assignee:Luke Kanies % Done:

0%

Category:language
Target version:-
Affected Puppet version:0.25.4 Branch:
Keywords:
Votes: 0

Description

I recently moved my apache2 class (lightly modified version of RecipesDebianApache2Recipe) from a plain manifest into a module. This is the result

info: Caching configuration at /var/lib/puppet/state/localconfig.yaml
err: Could not create -available/backend-proxy-public: Parameter path failed: File paths must be fully qualified
err: Parameter path failed: File paths must be fully qualified
notice: Starting configuration run
err: Could not apply complete configuration: Could not retrieve dependency 'File[-available/backend-proxy-public]' at /srv/modules/apache2/manifests/init.pp:86
info: Sent transaction report in 0.27 seconds
notice: Finished configuration run in 0.48 seconds

doing:

root@lid-backstage-10:~# rm /var/lib/puppet/state/localconfig.yaml

fixes the problem…

init.pp (4.3 kB) Thom May, 09/11/2007 11:41 am

nodes.pp (1.2 kB) Thom May, 09/11/2007 11:41 am

History

Updated by Anonymous over 4 years ago

Could we see your code, so we can better assess what is going on? Also, any other information you could send us would be great.

Updated by David Schmitt over 4 years ago

That is probably caused by the $sites and $mods variables which are used in the example to shorten/configure the paths of the apache config. Probably something went wrong when migrating those to the module.

Take a look at my git repository at http://git.black.co.at/?p=manifests.git;a=shortlog;h=apache for an updated and modularised version of the apache class. You can get it as described in http://git.black.co.at/?p=manifests.git;a=blob;f=aux/README.split-modules;hb=HEAD

Updated by Thom May over 4 years ago

Michael: see above; only real modification is to protect hostnames and IPs.

Updated by Thom May over 4 years ago

Just tried renaming the apache2_mods and apache2_sites variables but no change.

Updated by Luke Kanies over 4 years ago

Going to a much simpler example, the following code does not work:

# test.pp
include mymod

# ~/tmp/modules/mymod/manifests/init.pp
$test_variable = funtest

class mymod {
    notify { "testing $test_variable yay": }
}

# Running it:
luke@phage(0) $ test.pp --modulepath ~/tmp/modules/
notice: testing  yay
luke@phage(0) $

If I just include the class directly and run that file separately, it works fine.

The problem is that we’re evaluating ‘main’ before we evaluate anything else, and generally we’ve evaluated main before we get to the point where we’ve imported the module.

I’m not sure there really is a good solution to this. It might make sense to auto-evaluate any code that would otherwise get added to main if main is already evaluated, but… Man, that’s scary.

In the meantime, there’s a trivial workaround: Just manually import the module. This will add the variable-setting code to main at parse-time, rather than at evaluation time:

# test.pp
import 'mymod'

include mymod

# Running it:
luke@phage(0) $ test.pp --modulepath ~/tmp/modules/
notice: testing funtest yay
luke@phage(0) $

There’s a very good chance I may just call this workaround sufficient and not fix this bug.

Updated by Luke Kanies over 4 years ago

  • Status changed from 1 to Closed
  • 7 set to wontfix

After discussing and thinking about this, I’ve decided not to try to fix this bug. It’s got a trivial workaround, and I think any fixes would end up being more complicated than we want.

Also available in: Atom PDF