Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

puppet hash iterate create file

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?