Thanks for your post. However, I am unsure which variable are you actually trying to access. I am assuming you want to use mailgroup from the host’s vars.by_ssh_file_age["/var/run/file_check/lastRun"]. If so, would you try:
apply Service for (file => config in host.vars.by_ssh_file_age) {
// SNIP
vars.notification["mail"] = {
groups = config.mailgroup
}
}
Btw, the assign where host.vars.by_ssh_file_age is not needed as you are already using an apply for rule for this exact variable.
I am glad to hear this. Please feel free to mark the thread as being solved.
As you defined your Service via an Apply For Rule over (file => config in host.vars.by_ssh_file_age), the two variables file and config are being available in your Service definition. For each entry in host.vars.by_ssh_file_age, a Service objects gets created, where file is always the dictionary key and config is its value.
Taking your configuration snippet from your host.conf in the initial post, there is one entry in the host.vars.by_ssh_file_age dictionary. Its dictionary key is "/var/run/file_check/lastRun", getting assigned to the file variable while its value - that’s your dictionary of host, login, key, command, descr and mailgroup - getting assigned to the config variable, to be used in the Service definition scope.
However, there is also the possibility to take a real look into what’s available with by using the Script Debugger. While this might be a bit more complex, it allows you an interactive debugging.