Re: Variables

thierry thunot <[email protected]> Mon, 20 Jan 2025 05:14:19 -0800 (PST)
Newsgroups gmane.comp.sysutils.cfengine.general
Message-ID <[email protected]>
------=_Part_136212_315409162.1737378859802
Content-Type: multipart/alternative; 
	boundary="----=_Part_136213_322319126.1737378859802"

------=_Part_136213_322319126.1737378859802
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

pffffff!!!!  ho thank's i'm so stupid!!=20
I focused on the table variables not the name of the table itself
Thank's again for your help

Le lundi 20 janvier 2025 =C3=A0 13:18:09 UTC+1, [email protected] a =
=C3=A9crit :

> Hi, try changing the name of `"auto-upgrade"` to use underscore instead.=
=20
> I.e., `"auto_upgrade"`. I hope that solves your problem :)
>
> On Monday, January 20, 2025 at 11:41:15=E2=80=AFAM UTC+1 [email protected]=
 wrote:
>
>> Hello everyone, I come to you for a problem with a variable name.=20
>> In fact I use data to edit variable attributes within an=20
>> unattended-update configuration file for debian.=20
>> To do this I use the definition of variables like this then use the=20
>> fields of the file in a method to give the values =E2=80=8B=E2=80=8Bto t=
he attributes. they=20
>> have names such as Unattended-Upgrade::Automatic-Reboot etc...=20
>> I get an error variable is not legal. How can I solve this problem
>>
>> bundle agent    mise_a_jour_os
>> {
>> ###### Mise a jour de securite sur les postes de travail debian linux
>> ###### Pas de reboot automatique a la discretion de l utilisateur voir=
=20
>> bundle avertissement_utilisateur_reboot
>>
>>
>>         vars:
>>         "prerequis_update_secu"      slist =3D> {"unattended-upgrades",=
=20
>> "apt-listchanges"};
>> #"fichier_reboot_necessaire" string =3D> "/var/run/reboot-required";
>>
>> ####### Configuration des sources de mise a jour
>>         "conf_unattentedupgrades[upgrades_pc_dev]"             string =
=3D>=20
>> "/etc/apt/apt.conf.d/50unattended-upgrades";
>>         "upgrades_pc_dev[Unattended-Upgrade::Allowed-Origins]" string =
=3D>=20
>> "{
>>         // Codename based matching:
>>         // This will follow the migration of a release through different
>>         // archives (e.g. from testing to stable and later oldstable).
>>         // Software will be the latest available for the named release,
>>         // but the Debian release itself will not be automatically=20
>> upgraded.
>> //      \"origin=3DDebian,codename=3D\${distro_codename}-updates\";
>> //      \"origin=3DDebian,codename=3D\${distro_codename}-proposed-update=
s\";
>>         \"origin=3DDebian,codename=3D\${distro_codename},label=3DDebian\=
";
>>        =20
>> \"origin=3DDebian,codename=3D\${distro_codename},label=3DDebian-Security=
\";
>>        =20
>> \"origin=3DDebian,codename=3D\${distro_codename}-security,label=3DDebian=
-Security\";
>>
>>         // Archive or Suite based matching:
>>         // Note that this will silently match a different release after
>>         // migration to the specified archive (e.g. testing becomes the
>>         // new stable).
>> //      \"o=3DDebian,a=3Dstable\";
>> //      \"o=3DDebian,a=3Dstable-updates\";
>> //      \"o=3DDebian,a=3Dproposed-updates\";
>> //      \"o=3DDebian Backports,a=3D${distro_codename}-backports,l=3DDebi=
an=20
>> Backports\";
>> };";=20
>>         "upgrades_pc_dev[Unattended-Upgrade::Automatic-Reboot]" string =
=3D>=20
>> "\"false\";";
>>
>> ###### Configuration de la frequence de mise a jour
>>         "conf_conf_frequence_auto"            string =3D>=20
>> "/etc/apt/apt.conf.d/20auto-upgrades";
>>         "auto-upgrade" slist =3D> {"[APT::Periodic::Update-Package-Lists=
=20
>> \"1\";","[APT::Periodic::Unattended-Upgrade] \"1\";"};
>>
>> ##### Configuration de l heure des mise a jour
>>         "repertoire_conf"    string =3D>=20
>> "/etc/systemd/system/apt-daily-upgrade.timer.d";
>>         "repertoire_conf_telechargement"    string =3D>=20
>> "/etc/systemd/system/apt-daily.timer.d";
>>         "nom_conf_frequence" string =3D> "override.conf";
>>         "contenu_conf_freq"  string =3D> "[Timer]
>> OnCalendar=3D
>> OnCalendar=3D03:00
>> RandomizedDelaySec=3D0";
>> "contenu_telecharge" string =3D> "[Timer]
>> OnCalendar=3D
>> OnCalendar=3D03:00
>> RandomizedDelaySec=3D0";
>> "contenu_telecharge" string =3D> "[Timer]
>> OnCalendar=3D
>> OnCalendar=3D01:05
>> RandomizedDelaySec=3D0";
>>
>>       methods:
>>         "upgrades_pc_dev" usebundle       =3D>=20
>> edit_fichier_conf_param("$(mise_a_jour_os.conf_unattentedupgrades[upgrad=
es_pc_dev])","mise_a_jour_os.upgrades_pc_dev","=20
>> ","//"),
>>                 comment =3D> "/?\---------- Configuration des la methode=
 de=20
>> mise a jour de securite";
>>         "conf_conf_frequence_auto" usebundle =3D>=20
>> edit_fichier_conf_param("$(mise_a_jour_os.conf_conf_frequence_auto[auto-=
upgrade])","mise_a_jour_os.auto-upgrade","=20
>> ","//"),
>>                 comment =3D> "/?\---------- Configuration frequence de=
=20
>>  mise a jour de securite";
>>
>>
>> }
>> bundle agent=20
>> edit_fichier_conf_param(fichier,variables,separateur,delimit_comm)=20
>> {
>> # Bundle permettant les fonctions suivantes:
>> # Modifier une valeur d'un attribu dans un fichier de configuration
>> # Le s=C3=A9parateur est le caractere qui s=C3=A9pare le champ de sa val=
eur ex "=20
>> champ =3D valeur OU champ : valeur OU champ valeur)
>> # Le delimit_comm est le caract=C3=A8re  li=C3=A9 a la mise en commentai=
re d'une=20
>> ligne ex # OU ; OU // etc...
>> # A noter qu'aucun espace n'est inclu entre le champ, le separateur et l=
a=20
>> valeur si un espace est necessaire l'inclure dans le separateur ex " =3D=
 "=20
>>         vars:
>>         "c_fichier" string =3D> canonify("$(fichier)");
>>
>>         files:
>>         "$(fichier)"
>>                 handle =3D> "edit_fichier_conf_param",
>>                 comment =3D> "Mise a jour du fichier ini de $(fichier)",
>>                 edit_line =3D>=20
>> set_line_based("$(variables)","$(separateur)","\s*$(separateur)\s*", ".*=
",=20
>> "\s*$(delimit_comm)\s*"),
>>                 #cr=C3=A9e une classe $fichier_ok, $fichier_kept,=20
>> $fichier_reached, $fichier_denied, $fichier_repaired, $fichier_failed,=
=20
>> $fichier_timout selon les cas
>>                 classes =3D> results("namespace","$(c_fichier)");
>> }
>>
>> the error :
>> ...
>> verbose: B: BEGIN bundle mise_a_jour_os
>>  verbose: B:=20
>> *****************************************************************
>>    error: Variable identifier=20
>> 'auto-upgrade[APT::Periodic::Update-Package-Lists]' is not legal
>>    error: Promise belongs to bundle 'mise_a_jour_os' in file=20
>> '/var/cfengine/inputs/sys_maj_secu_debian.cf' near line 61
>>    error: Variable identifier=20
>> 'auto-upgrade[APT::Periodic:::Unattended-Upgrade]' is not legal
>>    error: Promise belongs to bundle 'mise_a_jour_os' in file=20
>> '/var/cfengine/inputs/sys_maj_secu_debian.cf' near line 62
>> ......
>>
>>
>>
>>
>> thank's again for your help!
>>
>>
>>
>>
>>
>>

--=20
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 e=
mail to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/help-cfengi=
ne/53784964-91c8-4810-bc9f-a8da506e1c5dn%40googlegroups.com.

------=_Part_136213_322319126.1737378859802
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

pffffff!!!!=C2=A0 ho thank's i'm so stupid!!=20
<div tabindex=3D"0" role=3D"text"><span style=3D"text-align: left;" dir=3D"=
ltr"><span lang=3D"en">I focused on the table variables not the name of the=
 table itself</span></span></div><div tabindex=3D"0" role=3D"text"><span st=
yle=3D"text-align: left;" dir=3D"ltr"><span></span></span></div>

Thank's again for your help<br /><br /><div class=3D"gmail_quote"><div dir=
=3D"auto" class=3D"gmail_attr">Le lundi 20 janvier 2025 =C3=A0 13:18:09 UTC=
+1, [email protected] a =C3=A9crit=C2=A0:<br/></div><blockquote class=
=3D"gmail_quote" style=3D"margin: 0 0 0 0.8ex; border-left: 1px solid rgb(2=
04, 204, 204); padding-left: 1ex;">Hi, try changing the name of `&quot;auto=
-upgrade&quot;` to use underscore instead. I.e., `&quot;auto_upgrade&quot;`=
. I hope that solves your problem :)<br><br><div class=3D"gmail_quote"><div=
 dir=3D"auto" class=3D"gmail_attr">On Monday, January 20, 2025 at 11:41:15=
=E2=80=AFAM UTC+1 <a href data-email-masked rel=3D"nofollow">[email protected]=
om</a> wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0 =
0 0 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div><div></div></div><div><div><div><div role=3D"text"><span style=3D"text=
-align:left" dir=3D"ltr"><span lang=3D"en">Hello everyone,
I come to you for a problem with a variable name. <br>In fact I use data to=
 edit variable attributes within an unattended-update configuration file fo=
r debian.
<br>To do this I use the definition of variables like this then use the fie=
lds of the file in a method to give the values =E2=80=8B=E2=80=8Bto the att=
ributes. they have names such as Unattended-Upgrade::Automatic-Reboot etc..=
. <br>I get an error variable is not legal. How can I solve this problem<br=
><br>bundle agent =C2=A0 =C2=A0mise_a_jour_os<br>{<br>###### Mise a jour de=
 securite sur les postes de travail debian linux<br>###### Pas de reboot au=
tomatique a la discretion de l utilisateur voir bundle avertissement_utilis=
ateur_reboot<br><br><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 vars:<br>=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 &quot;prerequis_update_secu&quot; =C2=A0 =C2=A0 =C2=A0slist =
=3D&gt; {&quot;unattended-upgrades&quot;, &quot;apt-listchanges&quot;};<br>=
#&quot;fichier_reboot_necessaire&quot; string =3D&gt; &quot;/var/run/reboot=
-required&quot;;<br><br>####### Configuration des sources de mise a jour<br=
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 &quot;conf_unattentedupgrades[upgrades_pc_dev]=
&quot; =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 string =3D&gt; &quot;/etc/=
apt/apt.conf.d/50unattended-upgrades&quot;;<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =
&quot;upgrades_pc_dev[Unattended-Upgrade::Allowed-Origins]&quot; string =3D=
&gt; &quot;{<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 // Codename based matching:<br>=
=C2=A0 =C2=A0 =C2=A0 =C2=A0 // This will follow the migration of a release =
through different<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 // archives (e.g. from tes=
ting to stable and later oldstable).<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 // Soft=
ware will be the latest available for the named release,<br>=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 // but the Debian release itself will not be automatically up=
graded.<br>// =C2=A0 =C2=A0 =C2=A0\&quot;origin=3DDebian,codename=3D\${dist=
ro_codename}-updates\&quot;;<br>// =C2=A0 =C2=A0 =C2=A0\&quot;origin=3DDebi=
an,codename=3D\${distro_codename}-proposed-updates\&quot;;<br>=C2=A0 =C2=A0=
 =C2=A0 =C2=A0 \&quot;origin=3DDebian,codename=3D\${distro_codename},label=
=3DDebian\&quot;;<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 \&quot;origin=3DDebian,cod=
ename=3D\${distro_codename},label=3DDebian-Security\&quot;;<br>=C2=A0 =C2=
=A0 =C2=A0 =C2=A0 \&quot;origin=3DDebian,codename=3D\${distro_codename}-sec=
urity,label=3DDebian-Security\&quot;;<br><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 //=
 Archive or Suite based matching:<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 // Note th=
at this will silently match a different release after<br>=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 // migration to the specified archive (e.g. testing becomes the<=
br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 // new stable).<br>// =C2=A0 =C2=A0 =C2=A0\&=
quot;o=3DDebian,a=3Dstable\&quot;;<br>// =C2=A0 =C2=A0 =C2=A0\&quot;o=3DDeb=
ian,a=3Dstable-updates\&quot;;<br>// =C2=A0 =C2=A0 =C2=A0\&quot;o=3DDebian,=
a=3Dproposed-updates\&quot;;<br>// =C2=A0 =C2=A0 =C2=A0\&quot;o=3DDebian Ba=
ckports,a=3D${distro_codename}-backports,l=3DDebian Backports\&quot;;<br>};=
&quot;; <br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 &quot;upgrades_pc_dev[Unattended-Up=
grade::Automatic-Reboot]&quot; string =3D&gt; &quot;\&quot;false\&quot;;&qu=
ot;;<br><br>###### Configuration de la frequence de mise a jour<br>=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 &quot;conf_conf_frequence_auto&quot; =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0string =3D&gt; &quot;/etc/apt/apt.conf.d/20auto-upg=
rades&quot;;<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 &quot;auto-upgrade&quot; slist =
=3D&gt; {&quot;[APT::Periodic::Update-Package-Lists \&quot;1\&quot;;&quot;,=
&quot;[APT::Periodic::Unattended-Upgrade] \&quot;1\&quot;;&quot;};<br><br>#=
#### Configuration de l heure des mise a jour<br>=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 &quot;repertoire_conf&quot; =C2=A0 =C2=A0string =3D&gt; &quot;/etc/syst=
emd/system/apt-daily-upgrade.timer.d&quot;;<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =
&quot;repertoire_conf_telechargement&quot; =C2=A0 =C2=A0string =3D&gt; &quo=
t;/etc/systemd/system/apt-daily.timer.d&quot;;<br>=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 &quot;nom_conf_frequence&quot; string =3D&gt; &quot;override.conf&quot;=
;<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 &quot;contenu_conf_freq&quot; =C2=A0string=
 =3D&gt; &quot;[Timer]<br>OnCalendar=3D<br>OnCalendar=3D03:00<br>Randomized=
DelaySec=3D0&quot;;<br>&quot;contenu_telecharge&quot; string =3D&gt; &quot;=
[Timer]<br>OnCalendar=3D<br>OnCalendar=3D03:00<br>RandomizedDelaySec=3D0&qu=
ot;;<br>&quot;contenu_telecharge&quot; string =3D&gt; &quot;[Timer]<br>OnCa=
lendar=3D<br>OnCalendar=3D01:05<br>RandomizedDelaySec=3D0&quot;;<br><br>=C2=
=A0 =C2=A0 =C2=A0 methods:<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 &quot;upgrades_pc=
_dev&quot; usebundle =C2=A0 =C2=A0 =C2=A0 =3D&gt; edit_fichier_conf_param(&=
quot;$(mise_a_jour_os.conf_unattentedupgrades[upgrades_pc_dev])&quot;,&quot=
;mise_a_jour_os.upgrades_pc_dev&quot;,&quot; &quot;,&quot;//&quot;),<br>=C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 comment =3D&gt; &quot;=
/?\---------- Configuration des la methode de mise a jour de securite&quot;=
;<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 &quot;conf_conf_frequence_auto&quot; usebu=
ndle =3D&gt; edit_fichier_conf_param(&quot;$(mise_a_jour_os.conf_conf_frequ=
ence_auto[auto-upgrade])&quot;,&quot;mise_a_jour_os.auto-upgrade&quot;,&quo=
t; &quot;,&quot;//&quot;),<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 comment =3D&gt; &quot;/?\---------- Configuration frequence de =
=C2=A0mise a jour de securite&quot;;<br><br><br>}<br>bundle agent edit_fich=
ier_conf_param(fichier,variables,separateur,delimit_comm) <br>{<br># Bundle=
 permettant les fonctions suivantes:<br># Modifier une valeur d&#39;un attr=
ibu dans un fichier de configuration<br># Le s=C3=A9parateur est le caracte=
re qui s=C3=A9pare le champ de sa valeur ex &quot; champ =3D valeur OU cham=
p : valeur OU champ valeur)<br># Le delimit_comm est le caract=C3=A8re =C2=
=A0li=C3=A9 a la mise en commentaire d&#39;une ligne ex # OU ; OU // etc...=
<br># A noter qu&#39;aucun espace n&#39;est inclu entre le champ, le separa=
teur et la valeur si un espace est necessaire l&#39;inclure dans le separat=
eur ex &quot; =3D &quot; <br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 vars:<br>=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 &quot;c_fichier&quot; string =3D&gt; canonify(&quot;$(=
fichier)&quot;);<br><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 files:<br>=C2=A0 =C2=A0=
 =C2=A0 =C2=A0 &quot;$(fichier)&quot;<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 handle =3D&gt; &quot;edit_fichier_conf_param&quot;,<b=
r>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 comment =3D&gt; &=
quot;Mise a jour du fichier ini de $(fichier)&quot;,<br>=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 edit_line =3D&gt; set_line_based(&qu=
ot;$(variables)&quot;,&quot;$(separateur)&quot;,&quot;\s*$(separateur)\s*&q=
uot;, &quot;.*&quot;, &quot;\s*$(delimit_comm)\s*&quot;),<br>=C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 #cr=C3=A9e une classe $fichier_ok=
, $fichier_kept, $fichier_reached, $fichier_denied, $fichier_repaired, $fic=
hier_failed, $fichier_timout selon les cas<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 classes =3D&gt; results(&quot;namespace&quot;,&=
quot;$(c_fichier)&quot;);<br>}<br><br>the error :<br>...<br>verbose: B: BEG=
IN bundle mise_a_jour_os<br>=C2=A0verbose: B: *****************************=
************************************<br>=C2=A0 =C2=A0error: Variable identi=
fier &#39;auto-upgrade[APT::Periodic::Update-Package-Lists]&#39; is not leg=
al<br>=C2=A0 =C2=A0error: Promise belongs to bundle &#39;mise_a_jour_os&#39=
; in file &#39;/var/cfengine/inputs/<a href=3D"http://sys_maj_secu_debian.c=
f" rel=3D"nofollow" target=3D"_blank" data-saferedirecturl=3D"https://www.g=
oogle.com/url?hl=3Dfr&amp;q=3Dhttp://sys_maj_secu_debian.cf&amp;source=3Dgm=
ail&amp;ust=3D1737465023135000&amp;usg=3DAOvVaw3eyOEPaFhu51eIn9Ia7a36">sys_=
maj_secu_debian.cf</a>&#39; near line 61<br>=C2=A0 =C2=A0error: Variable id=
entifier &#39;auto-upgrade[APT::Periodic:::Unattended-Upgrade]&#39; is not =
legal<br>=C2=A0 =C2=A0error: Promise belongs to bundle &#39;mise_a_jour_os&=
#39; in file &#39;/var/cfengine/inputs/<a href=3D"http://sys_maj_secu_debia=
n.cf" rel=3D"nofollow" target=3D"_blank" data-saferedirecturl=3D"https://ww=
w.google.com/url?hl=3Dfr&amp;q=3Dhttp://sys_maj_secu_debian.cf&amp;source=
=3Dgmail&amp;ust=3D1737465023135000&amp;usg=3DAOvVaw3eyOEPaFhu51eIn9Ia7a36"=
>sys_maj_secu_debian.cf</a>&#39; near line 62<br>......<br><br><br><br><br>=
thank&#39;s again for your help!<br><br><br><br><br><br></span></span></div=
></div></div></div>

</blockquote></div></blockquote></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/53784964-91c8-4810-bc9f-a8da506e1c5dn%40googlegroups.com?utm_=
medium=3Demail&utm_source=3Dfooter">https://groups.google.com/d/msgid/help-=
cfengine/53784964-91c8-4810-bc9f-a8da506e1c5dn%40googlegroups.com</a>.<br /=
>

------=_Part_136213_322319126.1737378859802--

------=_Part_136212_315409162.1737378859802--