How is define the maisl subject of cf_execd

"'Nick Anderson' via help-cfengine" <[email protected]> Wed, 22 Oct 2025 13:17:12 -0500
Newsgroups gmane.comp.sysutils.cfengine.general
Message-ID <[email protected]>
--=-=-=
Content-Type: multipart/alternative; boundary="==-=-="

--==-=-=
Content-Type: text/plain; charset="UTF-8"

        It is a way to define some proper subjet? The
        documentation about that is not very clear to me:

        body executor control { mailsubject => "CFEngine report
        ($(sys.fqhost))"; }

        Where should i write this code?

  Hi Jerome,

  TL;DR

  Create a `def.json' at the root of your policy set and define
  `default:def.control_executor_mailsubject'.

  <https://docs.cfengine.com/docs/3.24/reference-masterfiles-policy-framework.html#configure-subject-for-emails-sent-by-cf-execd>

  ,----
  | {
  |   "variables": {
  |     "default:def.control_executor_mailsubject": {
  |         "value": "CFEngine output from $(sys.fqhost)"
  |     }
  |   }
  | }
  `----

  The rest of the story:

  When a cfengine agent runs, it is going to do some system discovery to
  understand the environment (basically sys vars and hard classes). Then
  it's going to process Augments
  (<https://docs.cfengine.com/docs/3.24/reference-language-concepts-augments.html>).
  First, `$(sys.workdir)/data/host_specific.json' if it exists, then
  `$(sys.policy_entry_dirname)/def_preferred.json' or
  `$(sys.policy_entry_dirname)/def.json' if they exist and then other
  supplemental augments as specified by the `augments' key.

  Then it's going to start parsing policy starting with the first policy
  file read `$(sys.policy_entry_filename)' which defaults to
  `promises.cf' and other policy files are parsed as they are discovered
  based on the presence of the inputs defined (which may have been
  extended by Augments via the `inputs' key).

  The setting you are talking about, for `mailsubject' lives in `body
  executor control', you will find it within the policy framework in
  `controls/cf_execd.cf'

  Looking at this file you will find it looks like this:

  ,----
  | cfengine_internal_agent_email.!cfengine_internal_disable_agent_email::
  |   mailto       => "$(def.mailto)";
  |   mailfrom     => "$(def.mailfrom)";
  |   smtpserver   => "$(def.smtpserver)";
  |   mailmaxlines => "$(default:def.control_executor_mailmaxlines)";
  | 
  | control_executor_mailsubject_configured.cfengine_internal_agent_email.!cfengine_internal_disable_agent_email::
  |   mailsubject => "$(default:def.control_executor_mailsubject)";
  | 
  | control_executor_mailfilter_exclude_configured.cfengine_internal_agent_email.!cfengine_internal_disable_agent_email::
  |   mailfilter_exclude => { "@(default:def.control_executor_mailfilter_exclude)" };
  | 
  | control_executor_mailfilter_include_configured.cfengine_internal_agent_email.!cfengine_internal_disable_agent_email::
  |   mailfilter_include => { "@(default:def.control_executor_mailfilter_include)" };
  `----
  Notice that `mailsubject' here has a value of
  `$(default:def.control_executor_mailsubject)'. This tells us that the
  value is defined in the `default' namespace (see more about namespaces
  here
  <https://docs.cfengine.com/docs/3.24/reference-language-concepts-namespaces.html>),
  in the `def' bundle scope, in the variable
  `control_executor_mailsubject'.

  We can leverage Augments to define that variable, as mentioned in the
  docs for configuring the subject for emails sent by cf-execd
  (<https://docs.cfengine.com/docs/3.24/reference-masterfiles-policy-framework.html#configure-subject-for-emails-sent-by-cf-execd>).

  ,----
  | {
  |   "variables": {
  |     "default:def.control_executor_mailsubject": {
  |         "value": "CFEngine output from $(sys.fqhost)"
  |     }
  |   }
  | }
  `----

-- 
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/87tszqer7p.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>
It is a way to define some proper subjet? The documentation about that is n=
ot very clear to me:
</p>

<p>
body executor control { mailsubject =3D&gt; "CFEngine report ($(sys.fqhost)=
)"; }
</p>

<p>
Where should i write this code?
</p>
</blockquote>

<p>
Hi Jerome,
</p>

<p>
TL;DR
</p>

<p>
Create a <code>def.json</code> at the root of your policy set and define <c=
ode>default:def.control_executor_mailsubject</code>.
</p>

<p>
<a href=3D"https://docs.cfengine.com/docs/3.24/reference-masterfiles-policy=
-framework.html#configure-subject-for-emails-sent-by-cf-execd">https://docs=
.cfengine.com/docs/3.24/reference-masterfiles-policy-framework.html#configu=
re-subject-for-emails-sent-by-cf-execd</a>
</p>

<div class=3D"org-src-container">
<pre class=3D"src src-json"><span style=3D"color: #689d6a;">{</span>
  <span style=3D"color: #98971a; font-weight: bold;">"variables"</span>: <s=
pan style=3D"color: #d79921;">{</span>
    <span style=3D"color: #98971a; font-weight: bold;">"default:def.control=
_executor_mailsubject"</span>: <span style=3D"color: #458588;">{</span>
        <span style=3D"color: #98971a; font-weight: bold;">"value"</span>: =
<span style=3D"color: #689d6a;">"CFEngine output from $(sys.fqhost)"</span>
    <span style=3D"color: #458588;">}</span>
  <span style=3D"color: #d79921;">}</span>
<span style=3D"color: #689d6a;">}</span>
</pre>
</div>

<p>
The rest of the story:
</p>

<p>
When a cfengine agent runs, it is going to do some system discovery to unde=
rstand the environment (basically sys vars and hard classes). Then it's goi=
ng to process Augments (<a href=3D"https://docs.cfengine.com/docs/3.24/refe=
rence-language-concepts-augments.html">https://docs.cfengine.com/docs/3.24/=
reference-language-concepts-augments.html</a>). First, <code>$(sys.workdir)=
/data/host_specific.json</code> if it exists, then <code>$(sys.policy_entry=
_dirname)/def_preferred.json</code> or <code>$(sys.policy_entry_dirname)/de=
f.json</code> if they exist and then other supplemental augments as specifi=
ed by the <code>augments</code> key.
</p>

<p>
Then it's going to start parsing policy starting with the first policy file=
 read <code>$(sys.policy_entry_filename)</code> which defaults to <code>pro=
mises.cf</code> and other policy files are parsed as they are discovered ba=
sed on the presence of the inputs defined (which may have been extended by =
Augments via the <code>inputs</code> key).
</p>

<p>
The setting you are talking about, for <code>mailsubject</code> lives in <c=
ode>body executor control</code>, you will find it within the policy framew=
ork in <code>controls/cf_execd.cf</code>
</p>

<p>
Looking at this file you will find it looks like this:
</p>

<div class=3D"org-src-container">
<pre class=3D"src src-cfengine3"><span style=3D"color: #98971a; font-weight=
: bold;">cfengine_internal_agent_email.!cfengine_internal_disable_agent_ema=
il</span>::
  mailto       =3D&gt; <span style=3D"color: #689d6a;">"$(def.mailto)"</spa=
n>;
  mailfrom     =3D&gt; <span style=3D"color: #689d6a;">"$(def.mailfrom)"</s=
pan>;
  smtpserver   =3D&gt; <span style=3D"color: #689d6a;">"$(def.smtpserver)"<=
/span>;
  mailmaxlines =3D&gt; <span style=3D"color: #689d6a;">"$(default:def.contr=
ol_executor_mailmaxlines)"</span>;

<span style=3D"color: #98971a; font-weight: bold;">control_executor_mailsub=
ject_configured.cfengine_internal_agent_email.!cfengine_internal_disable_ag=
ent_email</span>::
  mailsubject =3D&gt; <span style=3D"color: #689d6a;">"$(default:def.contro=
l_executor_mailsubject)"</span>;

<span style=3D"color: #98971a; font-weight: bold;">control_executor_mailfil=
ter_exclude_configured.cfengine_internal_agent_email.!cfengine_internal_dis=
able_agent_email</span>::
  mailfilter_exclude =3D&gt; <span style=3D"color: #689d6a;">{</span> <span=
 style=3D"color: #689d6a;">"@(default:def.control_executor_mailfilter_exclu=
de)"</span> <span style=3D"color: #689d6a;">}</span>;

<span style=3D"color: #98971a; font-weight: bold;">control_executor_mailfil=
ter_include_configured.cfengine_internal_agent_email.!cfengine_internal_dis=
able_agent_email</span>::
  mailfilter_include =3D&gt; <span style=3D"color: #689d6a;">{</span> <span=
 style=3D"color: #689d6a;">"@(default:def.control_executor_mailfilter_inclu=
de)"</span> <span style=3D"color: #689d6a;">}</span>;
</pre>
</div>
<p>
Notice that <code>mailsubject</code> here has a value of <code>$(default:de=
f.control_executor_mailsubject)</code>. This tells us that the value is def=
ined in the <code>default</code> namespace (see more about namespaces here =
<a href=3D"https://docs.cfengine.com/docs/3.24/reference-language-concepts-=
namespaces.html">https://docs.cfengine.com/docs/3.24/reference-language-con=
cepts-namespaces.html</a>), in the <code>def</code> bundle scope, in the va=
riable <code>control_executor_mailsubject</code>.
</p>

<p>
We can leverage Augments to define that variable, as mentioned in the docs =
for configuring the subject for emails sent by cf-execd (<a href=3D"https:/=
/docs.cfengine.com/docs/3.24/reference-masterfiles-policy-framework.html#co=
nfigure-subject-for-emails-sent-by-cf-execd">https://docs.cfengine.com/docs=
/3.24/reference-masterfiles-policy-framework.html#configure-subject-for-ema=
ils-sent-by-cf-execd</a>).
</p>

<div class=3D"org-src-container">
<pre class=3D"src src-json"><span style=3D"color: #689d6a;">{</span>
  <span style=3D"color: #98971a; font-weight: bold;">"variables"</span>: <s=
pan style=3D"color: #d79921;">{</span>
    <span style=3D"color: #98971a; font-weight: bold;">"default:def.control=
_executor_mailsubject"</span>: <span style=3D"color: #458588;">{</span>
        <span style=3D"color: #98971a; font-weight: bold;">"value"</span>: =
<span style=3D"color: #689d6a;">"CFEngine output from $(sys.fqhost)"</span>
    <span style=3D"color: #458588;">}</span>
  <span style=3D"color: #d79921;">}</span>
<span style=3D"color: #689d6a;">}</span>
</pre>
</div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;help-cfengine&quot; 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/87tszqer7p.fsf%40northern.tech?utm_medium=3Demail&utm_source=
=3Dfooter">https://groups.google.com/d/msgid/help-cfengine/87tszqer7p.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/87tszqer7p.fsf%40northern.tech.

--=-=-=--