1 # define and enable (or disable) a .socket activated .service
3 define dsa_systemd::socket_service(
4 Enum['present','absent'] $ensure = 'present',
5 String $service_content,
6 String $socket_content,
8 $ensure_service = $ensure ? {
13 $ensure_enable = $ensure ? {
18 $systemd_service = "${name}.socket"
19 $service_file = "/etc/systemd/system/${name}@.service"
20 $socket_file = "/etc/systemd/system/${systemd_service}"
22 # if we enable the service, we want the files before the service, so we
23 # subscribe the service to the files.
24 # if we remove the service, we want the service disabled before the files
25 # go away, so we say the service needs the files to be handled before.
26 $service_before = $ensure ? {
33 $service_subscribe = $ensure ? {
44 content => $service_content,
45 notify => Exec['systemctl daemon-reload'],
50 content => $socket_content,
51 notify => Exec['systemctl daemon-reload'],
54 service { $systemd_service:
55 ensure => $ensure_service,
56 enable => $ensure_enable,
57 notify => Exec['systemctl daemon-reload'],
59 before => $service_before,
60 subscribe => $service_subscribe,