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 `"auto= -upgrade"` to use underscore instead. I.e., `"auto_upgrade"`= . 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 "prerequis_update_secu" =C2=A0 =C2=A0 =C2=A0slist = =3D> {"unattended-upgrades", "apt-listchanges"};<br>= #"fichier_reboot_necessaire" string =3D> "/var/run/reboot= -required";<br><br>####### Configuration des sources de mise a jour<br= >=C2=A0 =C2=A0 =C2=A0 =C2=A0 "conf_unattentedupgrades[upgrades_pc_dev]= " =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 string =3D> "/etc/= apt/apt.conf.d/50unattended-upgrades";<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 = "upgrades_pc_dev[Unattended-Upgrade::Allowed-Origins]" string =3D= > "{<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\"origin=3DDebian,codename=3D\${dist= ro_codename}-updates\";<br>// =C2=A0 =C2=A0 =C2=A0\"origin=3DDebi= an,codename=3D\${distro_codename}-proposed-updates\";<br>=C2=A0 =C2=A0= =C2=A0 =C2=A0 \"origin=3DDebian,codename=3D\${distro_codename},label= =3DDebian\";<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 \"origin=3DDebian,cod= ename=3D\${distro_codename},label=3DDebian-Security\";<br>=C2=A0 =C2= =A0 =C2=A0 =C2=A0 \"origin=3DDebian,codename=3D\${distro_codename}-sec= urity,label=3DDebian-Security\";<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\";<br>// =C2=A0 =C2=A0 =C2=A0\"o=3DDeb= ian,a=3Dstable-updates\";<br>// =C2=A0 =C2=A0 =C2=A0\"o=3DDebian,= a=3Dproposed-updates\";<br>// =C2=A0 =C2=A0 =C2=A0\"o=3DDebian Ba= ckports,a=3D${distro_codename}-backports,l=3DDebian Backports\";<br>};= "; <br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 "upgrades_pc_dev[Unattended-Up= grade::Automatic-Reboot]" string =3D> "\"false\";&qu= ot;;<br><br>###### Configuration de la frequence de mise a jour<br>=C2=A0 = =C2=A0 =C2=A0 =C2=A0 "conf_conf_frequence_auto" =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0string =3D> "/etc/apt/apt.conf.d/20auto-upg= rades";<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 "auto-upgrade" slist = =3D> {"[APT::Periodic::Update-Package-Lists \"1\";",= "[APT::Periodic::Unattended-Upgrade] \"1\";"};<br><br>#= #### Configuration de l heure des mise a jour<br>=C2=A0 =C2=A0 =C2=A0 =C2= =A0 "repertoire_conf" =C2=A0 =C2=A0string =3D> "/etc/syst= emd/system/apt-daily-upgrade.timer.d";<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 = "repertoire_conf_telechargement" =C2=A0 =C2=A0string =3D> &quo= t;/etc/systemd/system/apt-daily.timer.d";<br>=C2=A0 =C2=A0 =C2=A0 =C2= =A0 "nom_conf_frequence" string =3D> "override.conf"= ;<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 "contenu_conf_freq" =C2=A0string= =3D> "[Timer]<br>OnCalendar=3D<br>OnCalendar=3D03:00<br>Randomized= DelaySec=3D0";<br>"contenu_telecharge" string =3D> "= [Timer]<br>OnCalendar=3D<br>OnCalendar=3D03:00<br>RandomizedDelaySec=3D0&qu= ot;;<br>"contenu_telecharge" string =3D> "[Timer]<br>OnCa= lendar=3D<br>OnCalendar=3D01:05<br>RandomizedDelaySec=3D0";<br><br>=C2= =A0 =C2=A0 =C2=A0 methods:<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 "upgrades_pc= _dev" usebundle =C2=A0 =C2=A0 =C2=A0 =3D> edit_fichier_conf_param(&= quot;$(mise_a_jour_os.conf_unattentedupgrades[upgrades_pc_dev])","= ;mise_a_jour_os.upgrades_pc_dev"," ","//"),<br>=C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 comment =3D> "= /?\---------- Configuration des la methode de mise a jour de securite"= ;<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 "conf_conf_frequence_auto" usebu= ndle =3D> edit_fichier_conf_param("$(mise_a_jour_os.conf_conf_frequ= ence_auto[auto-upgrade])","mise_a_jour_os.auto-upgrade",&quo= t; ","//"),<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 comment =3D> "/?\---------- Configuration frequence de = =C2=A0mise a jour de securite";<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'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 " 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'une ligne ex # OU ; OU // etc...= <br># A noter qu'aucun espace n'est inclu entre le champ, le separa= teur et la valeur si un espace est necessaire l'inclure dans le separat= eur ex " =3D " <br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 vars:<br>=C2=A0 = =C2=A0 =C2=A0 =C2=A0 "c_fichier" string =3D> canonify("$(= fichier)");<br><br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 files:<br>=C2=A0 =C2=A0= =C2=A0 =C2=A0 "$(fichier)"<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 handle =3D> "edit_fichier_conf_param",<b= r>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 comment =3D> &= quot;Mise a jour du fichier ini de $(fichier)",<br>=C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 edit_line =3D> set_line_based(&qu= ot;$(variables)","$(separateur)","\s*$(separateur)\s*&q= uot;, ".*", "\s*$(delimit_comm)\s*"),<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> results("namespace",&= quot;$(c_fichier)");<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 'auto-upgrade[APT::Periodic::Update-Package-Lists]' is not leg= al<br>=C2=A0 =C2=A0error: Promise belongs to bundle 'mise_a_jour_os'= ; in file '/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&q=3Dhttp://sys_maj_secu_debian.cf&source=3Dgm= ail&ust=3D1737465023135000&usg=3DAOvVaw3eyOEPaFhu51eIn9Ia7a36">sys_= maj_secu_debian.cf</a>' near line 61<br>=C2=A0 =C2=A0error: Variable id= entifier 'auto-upgrade[APT::Periodic:::Unattended-Upgrade]' is not = legal<br>=C2=A0 =C2=A0error: Promise belongs to bundle 'mise_a_jour_os&= #39; in file '/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&q=3Dhttp://sys_maj_secu_debian.cf&source= =3Dgmail&ust=3D1737465023135000&usg=3DAOvVaw3eyOEPaFhu51eIn9Ia7a36"= >sys_maj_secu_debian.cf</a>' near line 62<br>......<br><br><br><br><br>= thank'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" 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--