You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to help-cfengine
Hello everyone,
I come to you for a problem with a variable name. In fact I use data to edit variable attributes within an unattended-update configuration file for debian.
To do this I use the definition of variables like this then use the fields of the file in a method to give the values to the attributes. they have names such as Unattended-Upgrade::Automatic-Reboot etc... 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 bundle avertissement_utilisateur_reboot
####### Configuration des sources de mise a jour "conf_unattentedupgrades[upgrades_pc_dev]" string => "/etc/apt/apt.conf.d/50unattended-upgrades"; "upgrades_pc_dev[Unattended-Upgrade::Allowed-Origins]" string => "{ // 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 upgraded. // \"origin=Debian,codename=\${distro_codename}-updates\"; // \"origin=Debian,codename=\${distro_codename}-proposed-updates\"; \"origin=Debian,codename=\${distro_codename},label=Debian\"; \"origin=Debian,codename=\${distro_codename},label=Debian-Security\"; \"origin=Debian,codename=\${distro_codename}-security,label=Debian-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=Debian,a=stable\"; // \"o=Debian,a=stable-updates\"; // \"o=Debian,a=proposed-updates\"; // \"o=Debian Backports,a=${distro_codename}-backports,l=Debian Backports\"; };"; "upgrades_pc_dev[Unattended-Upgrade::Automatic-Reboot]" string => "\"false\";";
###### Configuration de la frequence de mise a jour "conf_conf_frequence_auto" string => "/etc/apt/apt.conf.d/20auto-upgrades"; "auto-upgrade" slist => {"[APT::Periodic::Update-Package-Lists \"1\";","[APT::Periodic::Unattended-Upgrade] \"1\";"};
##### Configuration de l heure des mise a jour "repertoire_conf" string => "/etc/systemd/system/apt-daily-upgrade.timer.d"; "repertoire_conf_telechargement" string => "/etc/systemd/system/apt-daily.timer.d"; "nom_conf_frequence" string => "override.conf"; "contenu_conf_freq" string => "[Timer] OnCalendar= OnCalendar=03:00 RandomizedDelaySec=0"; "contenu_telecharge" string => "[Timer] OnCalendar= OnCalendar=03:00 RandomizedDelaySec=0"; "contenu_telecharge" string => "[Timer] OnCalendar= OnCalendar=01:05 RandomizedDelaySec=0";
methods: "upgrades_pc_dev" usebundle => edit_fichier_conf_param("$(mise_a_jour_os.conf_unattentedupgrades[upgrades_pc_dev])","mise_a_jour_os.upgrades_pc_dev"," ","//"), comment => "/?\---------- Configuration des la methode de mise a jour de securite"; "conf_conf_frequence_auto" usebundle => edit_fichier_conf_param("$(mise_a_jour_os.conf_conf_frequence_auto[auto-upgrade])","mise_a_jour_os.auto-upgrade"," ","//"), comment => "/?\---------- Configuration frequence de mise a jour de securite";
} bundle agent edit_fichier_conf_param(fichier,variables,separateur,delimit_comm) { # Bundle permettant les fonctions suivantes: # Modifier une valeur d'un attribu dans un fichier de configuration # Le séparateur est le caractere qui sépare le champ de sa valeur ex " champ = valeur OU champ : valeur OU champ valeur) # Le delimit_comm est le caractère lié a la mise en commentaire d'une ligne ex # OU ; OU // etc... # A noter qu'aucun espace n'est inclu entre le champ, le separateur et la valeur si un espace est necessaire l'inclure dans le separateur ex " = " vars: "c_fichier" string => canonify("$(fichier)");
files: "$(fichier)" handle => "edit_fichier_conf_param", comment => "Mise a jour du fichier ini de $(fichier)", edit_line => set_line_based("$(variables)","$(separateur)","\s*$(separateur)\s*", ".*", "\s*$(delimit_comm)\s*"), #crée une classe $fichier_ok, $fichier_kept, $fichier_reached, $fichier_denied, $fichier_repaired, $fichier_failed, $fichier_timout selon les cas classes => results("namespace","$(c_fichier)"); }
the error : ... verbose: B: BEGIN bundle mise_a_jour_os verbose: B: ***************************************************************** error: Variable identifier 'auto-upgrade[APT::Periodic::Update-Package-Lists]' is not legal error: Promise belongs to bundle 'mise_a_jour_os' in file '/var/cfengine/inputs/sys_maj_secu_debian.cf' near line 61 error: Variable identifier 'auto-upgrade[APT::Periodic:::Unattended-Upgrade]' is not legal error: Promise belongs to bundle 'mise_a_jour_os' in file '/var/cfengine/inputs/sys_maj_secu_debian.cf' near line 62 ......
thank's again for your help!
Lars Erik Wik
unread,
Jan 20, 2025, 7:18:09 AMJan 20
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to help-cfengine
Hi, try changing the name of `"auto-upgrade"` to use underscore instead. I.e., `"auto_upgrade"`. I hope that solves your problem :)
thierry thunot
unread,
Jan 20, 2025, 8:14:20 AMJan 20
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to help-cfengine
pffffff!!!! ho thank's i'm so stupid!!
I focused on the table variables not the name of the table itself
Thank's again for your help
Lars Erik Wik
unread,
Jan 20, 2025, 9:25:29 AMJan 20
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message