Sooo i have this hash in app1's puppet manifest
$applicaton = 'app1'
daemontools::build {
$application:
path => "/opt/supervise/${application}"
envvars => {
'ENVIRONMENT' => $location,
'SERVICE_USER' => $application_user,
'SERVICE_PORT' => $gunicorn_port,
'SERVICE_IP' => $gunicorn_ip,
'ADDITIONAL_PARAMS' => "--workers $processorcount",
'DJANGO_SETTINGS_MODULE' => "${application}.settings",
}
}
and this hash in my app2's puppet manifest
$applicaton = 'app2'
daemontools::build {
$application:
path => "/opt/supervise/${application}"
envvars => {
'ENVIRONMENT' => $location,
'SERVICE_USER' => $application_user,
'SERVICE_PORT' => $gunicorn_port,
'SERVICE_IP' => $gunicorn_ip,
'ADDITIONAL_PARAMS' => "--workers $processorcount",
'DJANGO_SETTINGS_MODULE' => "${application}.settings",
}
}
which are both passed to daemontools::build ( along with a path )
define daemontools::build (
$envvars = {},
$path
){
$env_names = keys($envvars)
daemontools::envfile { $env_names:
path => $path,
value => $envvars
}
}
define daemontools::envfile($path, $value) {
file { "/${path}/envdir/${name}" :
mode => 0644,
content => "${value[$name]}";
}
}
which results in
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Duplicate declaration: Daemontools::Envfile[SERVICE_IP] is already declared in file daemontools/manifests/build.pp:53; cannot redeclare at daemontools/manifests/build.pp:53
How can i make it so that i wont get duplicate resource declarations?
In the creation of your
daemontools::envfile
object, you should add a unique identifier to the$name
of the object.By default,
$name
is each of your$env_names
. When you create the second object with the same set of keys, it causes many duplicates. FQDN or something equally unique could be useful for lookup.Right, you're using
$env_names
(you may also want to look at consistent use of underscores there) as the$name
fordaemontools::envfile
for semi-hacky iteration - I assume you don't want to use thefuture
parser (quite reasonably). Note that also what you're trying to do withvalue => $envvars
probably won't work either.So,
prefix
frompuppetlabs/stdlib
is your friend for the duplicate issue, ensuring you get unique$name
s by preconstructing the path:However, this will probably just reveal that
value => $envvars
doesn't work, and seems to only lead to the conclusion that you need thefuture
parser for now, andeach()
It seems this worked :) Although messy with that inline template...