-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Using custom_fragment template with variables from apache::vhost (logroot, servername, ...)? #450
Comments
Sorry, misclicked. |
The problem with this is that parser functions, such as template() are not only evaluated on the server, but they are evaluated very early in the run. As such the template calls upon variables that are outside of it's scope. |
Or worse, it seems, as the called upon variables may contain values from earlier in the run. This is probably why It seems I can work around this by explicitly setting local-scope variables that are then used in the template: $servername = $::fqdn
$logroot = $::apache::logroot # or a custom path
apache::vhost { "worker_app.example.com_{::fqdn}":
servername => $servername,
logroot => $logroot,
access_log => false,
ssl => false,
custom_fragment => template('themodule/vhost_settings.erb')
} Not pretty, though. |
Do you think you could turn this information into a pull request for the README? |
Hello! We are doing some house keeping and noticed that this issue has been open for a long time. We're going to close it but please do raise another issue if the issue still persists. 😄 |
…bs#450) Allows attaching the service to one or multiple networks
I'm afraid my Puppet/Ruby-foo is not strong enough to understand how variable scoping works in case of the
custom_fragment
parameter inapache::vhost
. Using puppetlabs-apache 0.9.0 (plus fix for issue #358, so ceb37bb) on Ubuntu 12.04 with Puppet 3.3.1 and Ruby 1.9.3p429.It seems the template specified in
custom_fragment
has no access to variables like@servername
or@logroot
, set by theapache::vhost
defined type. Is this correct, or am I doing it wrong?Consider this example:
With
vhost_settings.erb
containing:In this case the
vhost_settings.erb
template, when applied, looks like this, which is obviously no good:CustomLog /bar.example.com_access.log combined env=!from_proxy
As you can see the
@logroot
variable is completely undefined (null, nil, empty, or whatever applies here), while@servername
is set to something I don't quite understand, but it is not the servername set in theapache::vhost
declaration above. It's probably set to a value from another@servername
variable in a previous scope/context, but I have no idea how or why.So my questions are essentially:
apache::vhost
type from the suppliedcustom_fragment
template?The text was updated successfully, but these errors were encountered: