Hi all,

The slist I put into the array doesn't expand. Can anybody tell me how to
get this right? Please review the code below. Many thanks in advance.


bundle agent manage_services {
  vars:
    "services[ntp][service]"     string => "ntp";
    "services[ntp][config]"      string => "/etc/ntp.conf";
    "services[ntp][package]"     string => "ntp";
    "services[postfix][service]" string => "postfix";
    "services[postfix][config]"  slist => {
      "/etc/postfix/main.cf",
      "/etc/postfix/virtual"
    };
    "services[postfix][package]" string => "postfix";

  methods:
    "services" usebundle => fix_services("manage_services.services");
}


# Fix services
bundle agent fix_services(service) {
  vars:
    "index" slist => getindices("$(service)");

  packages:
    debian::
      "$($(service)[$(index)][package])"
      package_policy => "add",
      package_method => apt,
      classes => if_ok("install_$(index)");

  files:
    "$($(service)[$(index)][config])"
    copy_from =>
secure_cp("$(def.dir_masterfiles)$($(service)[$(index)][config])",
"$(sys.policy_hub)"),
    perms     => mog("644","root","root"),
    comment   => "Copy $(config) to sys.fqhost",
    classes   => if_repaired("config_$(index)");

  commands:
    "/usr/sbin/service $($(service)[$(index)][service]) restart"
    ifvarclass => and("install_$(index)", "config_$(index)");
}


Kind regards,

Dennis
_______________________________________________
Help-cfengine mailing list
Help-cfengine@cfengine.org
https://cfengine.org/mailman/listinfo/help-cfengine

Reply via email to