Collecting all declared instances of a defined type locally

asked 2015-06-30 16:29:10 -0500

Naftuli Tzvi Kay gravatar image

I'm manually provisioning instances using puppet apply. I have types of instances which need multiple procesess running, so I'm using the supervisord module to manage their processes.

I have a defined type called logstash::process which internally manages the supervisor process type:

define logstash::process (
        # ...
    ) {
    supervisord::program { "logstash_${title}":
         ensure          => $ensure,
         command         => "${logstash::install_dir}/bin/logstash -f ${logstash::config_dir}/${title}.conf",
         directory       => $logstash::install_dir,
         autostart       => true,
         autorestart     => true,
         user            => $logstash::user,
         stdout_logfile  => "/var/log/logstash/${title}.log",
         redirect_stderr => true,
         environment     => {
             'USER'         => $logstash::user,
             'USERNAME'     => $logstash::user,
             'HOME'         => $logstash::home,
             'SHELL'        => '/bin/bash',
             'MAIL'         => "/var/mail/${logstash::user}",
             'LOGNAME'      => $logstash::user,
             'PATH'         => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
             'PWD'          => $logstash::install_dir,
             'LANG'         => 'en_US.UTF-8',
             'LS_HEAP_SIZE' => '1024m',

My logstash::process defined type obviously does more than this, but this is the main thing.

Supervisor has a concept of process groups, ie grouping a number of processes into one group so you can easily manage all of them at once. This is what that looks like:

supervisord::group { 'indexers':
    programs => [
         # ...

Instead of declaring this manually, I'd like to do a resource collection on all instances of logstash::process defined on the host which is currently running the Puppet apply. If I could collect all of their names and inject them into the supervisor::group => programs array, that would be awesome.

Is there a way to do this?

edit retag flag offensive close merge delete