Can cf-agent easily know about "systemd" state/target, etc.?
"'Nick Anderson' via help-cfengine" <[email protected]> Thu, 05 Dec 2024 12:32:38 -0600
| Newsgroups | gmane.comp.sysutils.cfengine.general |
|---|---|
| Message-ID | <[email protected]> |
--=-=-=
Content-Type: multipart/alternative; boundary="==-=-="
--==-=-=
Content-Type: text/plain; charset="UTF-8"
Context: Linux "systemd" machine; CFE 3.18.
We have an emerging use case to run a specific, minimal
(i.e. fast) subset of our cf-agent policy during machine
shutdown/halt. We are considering a "systemd" service with
something like:
ExecStop=cf-agent....
Is there something already in place which can tell us the
current state (target?) of systemd? Perhaps a "var" (e.g.
"sys.") in CFE? Or perhaps something in "/proc" or similar
that our policy could peek at?
There aren't any system variables that hold states of systemd units
and I am not familiar with anything in proc that indicates a systemd
unit state.
`bundle agent systemd_services' which is used to manage systemd
service state parses information returned by `systemctl
--no-ask-password --global --system
-pLoadState,CanStop,UnitFileState,ActiveState,LoadState,CanStart,CanReload
show <service>'
<https://github.com/cfengine/masterfiles/blob/b91ca88286d8efece4050e9e4811e801b408d034/lib/services.cf#L370-L380>
Failing that, we do could something like:
ExecStop=cf-agent ... -D HALTING
Seems like a reasonable thing to try.
--
You received this message because you are subscribed to the Google Groups "help-cfengine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/help-cfengine/87cyi63rpn.fsf%40northern.tech.
--==-=-=
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<blockquote style=3D"border-left: 2px solid gray; padding-left: 4px;">
<p>
Context: Linux "systemd" machine; CFE 3.18.
</p>
<p>
We have an emerging use case to run a specific, minimal (i.e. fast) subset =
of our cf-agent policy during machine shutdown/halt. We are considering a
"systemd" service with something like:
</p>
<p>
ExecStop=3Dcf-agent….
</p>
<p>
Is there something already in place which can tell us the current state (ta=
rget?) of systemd? Perhaps a "var" (e.g. "sys.") in CFE? Or perhaps
something in "/proc" or similar that our policy could peek at?
</p>
</blockquote>
<p>
There aren't any system variables that hold states of systemd units and I a=
m not familiar with anything in proc that indicates a systemd unit state.
</p>
<p>
<code>bundle agent systemd_services</code> which is used to manage systemd =
service state parses information returned by <code>systemctl --no-ask-passw=
ord --global --system -pLoadState,CanStop,UnitFileState,ActiveState,LoadSta=
te,CanStart,CanReload show <service></code>
</p>
<p>
<a href=3D"https://github.com/cfengine/masterfiles/blob/b91ca88286d8efece40=
50e9e4811e801b408d034/lib/services.cf#L370-L380">https://github.com/cfengin=
e/masterfiles/blob/b91ca88286d8efece4050e9e4811e801b408d034/lib/services.cf=
#L370-L380</a>
</p>
<blockquote style=3D"border-left: 2px solid gray; padding-left: 4px;">
<p>
Failing that, we do could something like:
</p>
<p>
ExecStop=3Dcf-agent … -D HALTING
</p>
</blockquote>
<p>
Seems like a reasonable thing to try.
</p>
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;help-cfengine" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:[email protected]">help-=
[email protected]</a>.<br />
To view this discussion visit <a href=3D"https://groups.google.com/d/msgid/=
help-cfengine/87cyi63rpn.fsf%40northern.tech?utm_medium=3Demail&utm_source=
=3Dfooter">https://groups.google.com/d/msgid/help-cfengine/87cyi63rpn.fsf%4=
0northern.tech</a>.<br />
--==-=-=--
--=-=-=
Content-Type: text/plain; charset="UTF-8"
--
Nick Anderson | Doer of Things | (+1) 785-550-1767 | https://northern.tech
--
You received this message because you are subscribed to the Google Groups "help-cfengine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/help-cfengine/87cyi63rpn.fsf%40northern.tech.
--=-=-=--