Discussion:
[Puppet Users] Exec type and backgrounded processes
Thomas Müller
2018-05-22 06:38:07 UTC
Permalink
Hi

If I define:

exec { '/bin/sleep 300 &':
timeout => 10,
}

and run it with puppet apply: it happily starts the sleep, backgrounds it
and finishes - leaving the sleep in the background alive.

Is this behaviour as expected? I personally expected that puppet would
ensure all started processes are killed if once the exec resource finishes.

- Thomas
--
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 puppet-users+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/61aff915-21a1-4945-b346-dbfbcb699391%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Thomas Müller
2018-05-23 06:24:14 UTC
Permalink
Post by Thomas Müller
Hi
timeout => 10,
}
and run it with puppet apply: it happily starts the sleep, backgrounds it
and finishes - leaving the sleep in the background alive.
Is this behaviour as expected?
It's what *I* would have expected, at any rate.
Post by Thomas Müller
I personally expected that puppet would ensure all started processes are
killed if once the exec resource finishes.
I'm not sure why someone would expect that.
the puppet-agent service runs for longer time in the background. Processes
could leak unintended . It's not only about procesces backgrounded by the
Exec directly but also about subprocesses started by the exec command. Like:

exec { '/bin/bash -c "sleep 300 &"': timeout => 10, }


if this is the expected behaviour then all is fine. I just was suprised one
can start "daemon" processes with puppet exec.

I was already thinking about using systemd oneshot+time units to run puppet
instead of the service because of the SELinux fcontext issue with the
service . Another plus would be that systemd could ensure leftover
processes started in the background will be treated.



- Thomas
--
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 puppet-users+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/472f95ef-6d52-461a-9083-be3d5856203e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
warron.french
2018-05-23 12:54:13 UTC
Permalink
Use an attribute of the Exec resource, such as onlyif to restrict it's
execution if that's what you are trying to do.

\\Warron French from mobile
Post by Thomas Müller
Hi
timeout => 10,
}
and run it with puppet apply: it happily starts the sleep, backgrounds it
and finishes - leaving the sleep in the background alive.
Is this behaviour as expected?
It's what *I* would have expected, at any rate.
Post by Thomas Müller
I personally expected that puppet would ensure all started processes are
killed if once the exec resource finishes.
I'm not sure why someone would expect that.
the puppet-agent service runs for longer time in the background. Processes
could leak unintended . It's not only about procesces backgrounded by the
Exec directly but also about subprocesses started by the exec command. Like:

exec { '/bin/bash -c "sleep 300 &"': timeout => 10, }


if this is the expected behaviour then all is fine. I just was suprised one
can start "daemon" processes with puppet exec.

I was already thinking about using systemd oneshot+time units to run puppet
instead of the service because of the SELinux fcontext issue with the
service . Another plus would be that systemd could ensure leftover
processes started in the background will be treated.



- Thomas
--
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 puppet-users+***@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/puppet-users/472f95ef-6d52-461a-9083-be3d5856203e%40googlegroups.com
<https://groups.google.com/d/msgid/puppet-users/472f95ef-6d52-461a-9083-be3d5856203e%40googlegroups.com?utm_medium=email&utm_source=footer>
.

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 puppet-users+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/CAJdJdQmgK58F2zpFtG8UQ9sX7FHsZahB-f-_6L7P5NiW3vRyVQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Thomas Müller
2018-05-23 13:25:30 UTC
Permalink
Post by warron.french
Use an attribute of the Exec resource, such as onlyif to restrict it's
execution if that's what you are trying to do.
I'm not trying to use backgrounded processes with puppet at all. I'll
actually think that starting processes in the background with puppet exec
an anti-pattern. If something should be run in the background, then it's a
thing for Systemd or whatever your init system uses.

- Thomas
--
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 puppet-users+***@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/0ea6bf61-f2b3-4ae2-b363-84b241d45677%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...