You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description of problem
tl;dr
puppet and octocatalog diff don't read things the same way.
in puppet I have module (foo) which calls a template in another module (bar)
a var declared in module bar is not accessible to the template with @ in octocalog-diff but in puppet it is accessible.
in puppet this works fine but in octocatalog-diff
"cluster_name" : "<%= @cluster_name.downcase %>",
If I change it to scope['bar::cluster_name'].downcase it works in octocalog-diff
In puppet when I give it service bar it works fine,
but in your tool I get:
Error: Failed to compile catalog for node bas Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Error while evaluating a Function Call, Failed to parse template bar/bar.json.erb:
Filepath: /var/folders/sp/r687p5j51y106yn0gb4vynwm0000gn/T/d20170811-19384-1ldupto/environments/production/modules/ibar/templates/bar.json.erb
Line: 7
Detail: undefined method `downcase' for nil:NilClass
at /var/folders/sp/r687p5j51y106yn0gb4vynwm0000gn/T/d20170811-19384-1ldupto/environments/production/modules/foo/manifests/init.pp:77:18 at /var/folders/sp/r687p5j51y106yn0gb4vynwm0000gn/T/d20170811-19384-1ldupto/environments/production/modules/bar/manifests/init.pp:59 on node bas
Line: 7 is
"cluster_name" : "<%= @cluster_name.downcase %>",
If I change it to scope['bar::cluster_name'].downcase it works fine for octocatalog--diff.
What happened?
octocalog-diff did not work like puppet
What did you expect to happen?
octocalog-diff should work like puppet
How can someone reproduce the problem?
any time one module calls another modules, template, and that template uses vars define in the second module
Command used and debugging output
If you feel this will help I will add it.
Platform and version information
Your OS:
mac 10.12.5 (16F73) for octocatalog-diff
16.6.0 Darwin puppet master
Your Ruby version:
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16] ( on octocatalog-diff host
Your version of Puppet:
puppet --version
3.8.6
ruby --version
ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux ( on puppet master)
Your version of octocatalog-diff:
Do the tests pass from a clean checkout?
yes
Anything else to add that you think will be helpful?
is this expected/etc ?
The text was updated successfully, but these errors were encountered:
his actually looks to me like maybe you're encountering a bug with Puppet 3.x that happens to be working the way you want. Unless @cluster_name is being set at the top level (e.g. in a parameter or fact), I don't think that a template should recognize variables from a module you haven't explicitly included, and even then I think you'd need to re-declare that variable in the current manifest to make that work.
All variables in the current scope (including global variables) are passed to templates as Ruby instance variables, which begin with “at” signs (@). If you can access a variable by its short name in the surrounding manifest, you can access it in the template by replacing its $ sign with an @. So $os becomes @os, $trusted becomes @trusted, etc.
This is the most legible way to access variables, but it doesn’t support variables from other scopes. For that, you need to use the scope object.
Fully qualifying your variables with the scope is probably the best idea here, definitely for forward compatibility.
@markdanko I don't think octocatalog-diff resolves anything other than "puppet" - as it calls puppet to compile. There were bugs in Puppet 3 which allowed to resolve variables that actually shouldn't be available.
Anyway I would recommend you to use the new EPP instead of the (deprecated and not well specified) ERB.
in puppet I have module (foo) which calls a template in another module (bar)
a var declared in module bar is not accessible to the template with @ in octocalog-diff but in puppet it is accessible.
in puppet this works fine but in octocatalog-diff
"cluster_name" : "<%= @cluster_name.downcase %>",
If I change it to scope['bar::cluster_name'].downcase it works in octocalog-diff
I have a module
foo:
which has:
define service_definition (
$template = "$ {service}/${service}.json.erb",
$service_def_path = "/etc/somepath/servicedefs/$ {service}.json"$enabled and ($ ::foo::version != 'absent') {
$service = $title,
$enabled = true,
$watch_config = '',
) {
if
file { $service_def_path:
ensure => present,
content => inline_template($template),
}
In puppet when I give it service bar it works fine,
but in your tool I get:
Error: Failed to compile catalog for node bas Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Error while evaluating a Function Call, Failed to parse template bar/bar.json.erb:
Filepath: /var/folders/sp/r687p5j51y106yn0gb4vynwm0000gn/T/d20170811-19384-1ldupto/environments/production/modules/ibar/templates/bar.json.erb
Line: 7
Detail: undefined method `downcase' for nil:NilClass
at /var/folders/sp/r687p5j51y106yn0gb4vynwm0000gn/T/d20170811-19384-1ldupto/environments/production/modules/foo/manifests/init.pp:77:18 at /var/folders/sp/r687p5j51y106yn0gb4vynwm0000gn/T/d20170811-19384-1ldupto/environments/production/modules/bar/manifests/init.pp:59 on node bas
Line: 7 is
"cluster_name" : "<%= @cluster_name.downcase %>",
If I change it to scope['bar::cluster_name'].downcase it works fine for octocatalog--diff.
What happened?
octocalog-diff did not work like puppet
What did you expect to happen?
octocalog-diff should work like puppet
any time one module calls another modules, template, and that template uses vars define in the second module
mac 10.12.5 (16F73) for octocatalog-diff
16.6.0 Darwin puppet master
Your Ruby version:
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16] ( on octocatalog-diff host
Your version of Puppet:
puppet --version
3.8.6
ruby --version
ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux ( on puppet master)
Your version of octocatalog-diff:
yes
The text was updated successfully, but these errors were encountered: