Problem with data
thierry thunot <[email protected]>
| Newsgroups | gmane.comp.sysutils.cfengine.general |
|---|---|
| Message-ID | <[email protected]> |
Hi there,
I'm telling you about a concern I have regarding the use of data in
variables.
I want to automate (see previous post) the creation of debian sources.list
files for example by creating a json array then using it for the creation
of sources.list .
When an entry is simple, a bed name, a gpg key and a single url everything
works fine. But when I have two url for the same source list (ex mogodb) in
the variable allowing me to create the list remains with the same value
(repos_complet_$(nom)) the reporting does show 4 index entries but uses a
single value for ""le nom de l'url formatee" is the same for both mongodb
entries when they must be different
how can i force cfengine to evaluate the variable for each value???
bundle agent __main__
{
vars:
"clef" string => "toto";
"parametrage_des_sources" data => '{
"mogodb" : {
"nom_de_la_liste" : "mogodb.list",
"nom_clef_brute" : "GPG-KEY-mongodb.gpg.key",
"nom_clef_signee" : "GPG-KEY-mongodb.gpg",
"url_repo" : [
"http://repo.mongodb.org/apt/debian
buster/mongodb-org/4.2 main",
"http://repo.mongodb.org/apt/debian
buster/mongodb-org/4.2 main #####TOTOTOTOTO#####"
]
},
"elasticsearch" : {
"nom_de_la_liste" : "elasticsearch.list",
"nom_clef_brute" :
"GPG-KEY-elasticsearch.gpg.key",
"nom_clef_signee" : "GPG-KEY-elasticsearch.gpg",
"url_repo" :
"https://artifacts.elastic.co/packages/oss-7.x/apt stable main"
},
"graylog" : {
"nom_de_la_liste" : "graylog.list",
"nom_clef_brute" : "graylog-keyring.gpg.key",
"nom_clef_signee" : "graylog-keyring.gpg",
"url_repo" :
"https://packages.graylog2.org/repo/debian/ stable 4.2"
}
}'
;
methods:
"" usebundle => donnees(storejson(parametrage_des_sources));
}
bundle agent donnees(valeurs)
{
vars:
"donnees_store" string => storejson( $(valeurs) );
"donnees_extraites" data => parsejson( $(valeurs) );
"nom" slist => getindices( $(valeurs) );
"repos_complet_$(nom)" string => "deb [signed-by=/etc/apt/trusted.gpg.d/
$(donnees_extraites[$(nom)][nom_clef_brute])] $(donnees_extraites[$(nom)
][url_repo])";
files:
"/root/apt/$(donnees_extraites[$(nom)][nom_de_la_liste])"
create => "true",
edit_line => append_if_no_line("$(donnees_extraites[$(nom)][url_repo]
)");
reports:
#"parsejson $(donnees_store)";
"parsejson $(donnees_extraites)";
"Nom des datas $(nom)";
"Nom_de_la_liste pour l'entre '$(nom)' est : $(donnees_extraites[
$(nom)][nom_clef_brute])
l'adresse est $(donnees_extraites[$(nom)][url_repo])
le fichier est $(donnees_extraites[$(nom)
][nom_de_la_liste])
le nom de l'url formatee $(repos_complet_$(nom))";
"*****************************
deb [signed-by=/etc/apt/trusted.gpg.d/$(donnees_extraites[$(nom)
][nom_clef_brute])] $(donnees_extraites[$(nom)][url_repo])";
}
bundle edit_line append_if_no_line(lines)
# @brief Alias for `lines_present`
# @param lines List or string that should be present in the file
{
insert_lines:
"$(lines)"
comment => "Append lines if they don't exist";
}
body edit_defaults empty
# @brief Empty the file before editing
#
# No backup is made
{
empty_file_before_editing => "true";
edit_backup => "false";
#max_file_size => "300000";
}
root@cfeginetest:/var/cfengine/masterfiles# cf-agent -KIf
./essais_bundle_parametrique_demande_aide.cf
R: Nom des datas elasticsearch
R: Nom des datas graylog
R: Nom des datas mogodb
R: Nom_de_la_liste pour l'entre 'elasticsearch' est :
GPG-KEY-elasticsearch.gpg.key
l'adresse est
https://artifacts.elastic.co/packages/oss-7.x/apt stable main
le fichier est elasticsearch.list
le nom de l'url formatee deb
[signed-by=/etc/apt/trusted.gpg.d/GPG-KEY-elasticsearch.gpg.key]
https://artifacts.elastic.co/packages/oss-7.x/apt stable main
R: Nom_de_la_liste pour l'entre 'graylog' est : graylog-keyring.gpg.key
l'adresse est
https://packages.graylog2.org/repo/debian/ stable 4.2
le fichier est graylog.list
le nom de l'url formatee deb
[signed-by=/etc/apt/trusted.gpg.d/graylog-keyring.gpg.key]
https://packages.graylog2.org/repo/debian/ stable 4.2
R: Nom_de_la_liste pour l'entre 'mogodb' est : GPG-KEY-mongodb.gpg.key
l'adresse est http://repo.mongodb.org/apt/debian
buster/mongodb-org/4.2 main
le fichier est mogodb.list
le nom de l'url formatee deb
[signed-by=/etc/apt/trusted.gpg.d/GPG-KEY-mongodb.gpg.key]
http://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main
#####TOTOTOTOTO#####
R: Nom_de_la_liste pour l'entre 'mogodb' est : GPG-KEY-mongodb.gpg.key
l'adresse est http://repo.mongodb.org/apt/debian
buster/mongodb-org/4.2 main #####TOTOTOTOTO#####
le fichier est mogodb.list
le nom de l'url formatee deb
[signed-by=/etc/apt/trusted.gpg.d/GPG-KEY-mongodb.gpg.key]
http://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main
#####TOTOTOTOTO#####
R: *****************************
deb [signed-by=/etc/apt/trusted.gpg.d/GPG-KEY-elasticsearch.gpg.key]
https://artifacts.elastic.co/packages/oss-7.x/apt stable main
R: *****************************
deb [signed-by=/etc/apt/trusted.gpg.d/graylog-keyring.gpg.key]
https://packages.graylog2.org/repo/debian/ stable 4.2
R: *****************************
deb [signed-by=/etc/apt/trusted.gpg.d/GPG-KEY-mongodb.gpg.key]
http://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main
R: *****************************
deb [signed-by=/etc/apt/trusted.gpg.d/GPG-KEY-mongodb.gpg.key]
http://repo.mongodb.org/apt/debian buster/mongodb-org/4.2 main
#####TOTOTOTOTO#####
Thank's for your help
--
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 on the web visit https://groups.google.com/d/msgid/help-cfengine/573a6587-9e64-4ee6-94b1-c1b855822d84n%40googlegroups.com.