I'm new to puppet. As such I am trying to work my way around the best way to setup my manifests that make sense. Following the DRY (don't repeat yourself) principle, I am trying to load common directives in one template, then load in environment specific directives from a file matching the environment. Basically like this:
# nodes.pp
node base_dev {
$service_env = 'dev'
}
node 'service1.ownij.lan' inherits base_dev {
include global_env_specific
}
class global_env_specific {
include shell::bash
}
# modules/shell/bash.pp
class shell::bash inherits shell {
notify{"Service env: ${service_env}": }
file { '/etc/profile.d/custom_test.sh':
content => template('_global/prefix.erb', 'shell/bash/global.erb', 'shell/bash/$service_env.erb'),
mode => 644
}
}
But every time I run puppet agent --test puppet complains that it can't find the shell/bash/$service_env.erb file, but I double checked that it exists. I know the var is accessible due to the notify statement outputting the expected value, so I suspect I am doing which is not allowed.
I know I could have a single template.erb and pass variables to the template, which would work in this case because the custom.sh file is small and not many changes across environments, but for more complex configs (httpd, solr, etc) I'd prefer to access environment specific files. I am also aware that I can specify environment specific module paths, but I'd prefer to just handle this behavior at the template level, instead of having several, closely named directories.
Thanks.