Forum: CFEngine Help
Subject: Re: Don't know how to do for having only links that i want
Author: stchesmeli
Link to topic: https://cfengine.com/forum/read.php?3,24769,24781#msg-24781
Thanks for your answers.
But in fact in my post i have simplify my problem and i can't use this solution.
My "real" problem: i try to manage apache on debian/ubuntu. On this
distribution you activate modules by linking .load et .conf file from
/etc/apache2/mods_available to /etc/apache2/mods_enabled.
For example you want to activate "alias" modules, you have to link :
/etc/apache2/mods-enabled/alias.load -> /etc/apache2/mods-available/alias.load
Here my code:
bundle common goldorak_conf
{
vars:
"pkg_apache" slist => { "apache2", "apache2-mpm-worker",
"apache2-suexec-custom", "apache2-utils", "apache2.2-bin", "apache2.2-common",
"libapache-mod-security", "libapache2-mod-fastcgi", "libapache2-mod-macro" };
"apache_mods" slist => { "alias", "actions", "auth_basic", "authn_file",
"authz_default", "authz_groupfile", "authz_host", "authz_user", "autoindex",
"cgid", "cgi", "deflate", "dir", "env", "fastcgi", "macro", "mime",
"mod-security", "negotiation", "reqtimeout", "setenvif", "status", "suexec",
"unique_id" };
}
bundle agent set_apache
{
vars:
"pkg_apa" slist => { @(goldorak_conf.pkg_apache) };
"ex_file" slist => {".*\.swp", ".*\.back", ".*\.old", ".*\.~"};
"mods" slist => { @(goldorak_conf.apache_mods) };
classes:
"c_$(mods)" expression => fileexists
("/etc/apache2/mods-available/$(mods).conf");
# Some modules doesn't have a .conf file
packages:
"$(pkg_apa)"
package_policy => "addupdate",
package_method => generic,
classes => if_repaired("apache_installed");
files:
"/etc/apache2"
comment => "Set apache configuration",
copy_from =>
local_cp_nobackup("/var/cfengine/inputs/conf_files/apache2/"),
file_select => ex_list("@(ex_files)"),
depth_search => recurse("inf"),
perms => mog("644","root","root"),
classes => if_repaired("apache_conf_updated");
"/etc/apache2/mods-enabled/$(mods).load"
comment => "Activate apache modules",
link_from => ln_s("/etc/apache2/mods-available/$(mods).load"),
classes => if_repaired ("load_$(mods)");
"/etc/apache2/mods-enabled/$(mods).conf"
ifvarclass => canonify ("c_$(mods)"),
comment => "Activate apache modules configuration",
link_from => ln_s("/etc/apache2/mods-available/$(mods).conf"),
classes => if_repaired("conf_$(mods)");
reports:
cfengine_3::
"Module $(mods) have been activated",
ifvarclass => canonify ("load_$(mods)");
"Module $(mods) have been configurated",
ifvarclass => canonify ("conf_$(mods)");
}
As you see, my list is module names (deflate, alias, ..) not real links names
(deflate.load, deflate.conf, alias.load, alias.conf, ..). I don't know how to
build one list from another list (list of real links names from the module
list). In reference manual, the "maplist" function would do that, but this
function doesn't exist on community version :(
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine