Lots of different ways, it might make for lighter defines if you used some tags 
and chaining. Or even use the puppet4 iteration, for some reason defines puzzle 
a number of folks at work here.

class upstart {
  $upstartreload = '/sbin/initctl reload-configuration'
  exec { $upstartreload:
    refreshonly => true,
  }
  File <| tag == 'upstart' |> ~> Exec[$upstartreload]
  Exec[$upstartreload] -> Service <| tag == 'upstart' |>
}

class queues (
  Hash $workers,
)
{
  $workers.each |$name, $details|
    $initfile = "/etc/init/queue-${name}.conf"
    $package = "queue-${name}-files"
    file { $initfile:
      ensure  => $details['file_ensure'],
      content => template('queues/init.conf.erb'),
      tag     => 'upstart',
    }
    package { $package:
      ensure => $details['package_ensure'],
    }
    service { "queue-${name}":
      ensure    => $details['service_ensure'],
      subscribe => [File[$initfile], Package[$package]],
      tag       => 'upstart',
    }
  }
}

If you had non-template'able requirements for the upstart config you'd probably 
tag the package.

On Fri, May 19, 2017 at 05:02:53PM +0200, 'Bas van de Wiel' via Puppet Users 
wrote:
> Hi Martijn,
> 
> Something like this might do it.
> 
> define site::queueworker {
> 
>   file { 'worker-config':
>     ..do your /etc/init/configfile here
>     notify => Exec['kick-upstart'],
>   }
> 
>   exec { 'kick-upstart':
>     ...do your upstart-reload here
>     require => File['worker-config'],
>     refreshonly => true,
>     before => Service['worker'],
>     notify => Service['worker'],
>   }
> 
>   service { 'worker':
>     ..do your service here
>     require => File['worker-config']
>   }
> 
> }
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/puppet-users/4fdd4175-3425-0b0f-479c-83cf3f98c883%40area536.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/20170519160455.GA22193%40iniquitous.heresiarch.ca.
For more options, visit https://groups.google.com/d/optout.

Reply via email to