Em 11-02-2014 18:09, Michael Friedrich escreveu: > On 11.02.2014 19:00, Carlos Cesario wrote: >> Hello >> >> I would like to know how can I add/override the specifc attribute in a >> exisiting template used by some hosts. >> >> >> eg. >> >> I have a endpoint config >> >> object Endpoint "icinga-node-3" { >> host = "www.damata.ind.br", >> port = 10051, >> config_files = [ "/etc/icinga2/conf.d/*.conf", >> "/etc/icinga2/conf.d/customers/node3/*.conf" ] >> } > > Btw Gunnar implemented cluster recursive includes today so they should > be available in snapshot builds too. The only change is an additional > attribute named 'config_files_recursive' allowing you to specify a dir > which is then sent recursively. Or use a path/pattern dictionary > (details on the updated documentation). > > https://dev.icinga.org/issues/5304 Good... I'll test it! > > >> >> In /etc/icinga2/conf.d/*.conf directory i I have default icinga files >> >> >> In "/etc/icinga2/conf.d/customers/node3/" directory I have >> >> firewall.conf file >> >> >> /** >> * A host definition. You can create your own configuration files >> * in the conf.d directory (e.g. one per host). By default all *.conf >> * files in this directory are included. >> */ >> object Host "Firewall" inherits "linux-server" { >> display_name = "firewall", >> >> services["ping4"] = { >> templates = [ "generic-service" ], >> check_command = "ping4" >> }, >> >> services["http"] = { >> templates = [ "generic-service" ], >> check_command = "http_ip" >> }, >> >> services["ssh"] = { >> templates = [ "generic-service" ], >> check_command = "ssh" >> }, >> >> macros = { >> address = "192.168.0.5", >> }, >> check = "ping4", >> } >> >> >> >> and services.conf >> >> >> object Service "generic-service" { >> authorities = [ "node3" ], >> } > > That should be a template instead of an object, although Icinga 2 > shouldn't mind in that case. > >> >> >> My idea is add the authorities attribute in all services defined in >> file firewall.conf, but it isn't working. > > Do you have the 'generic-service' template defined at a different > location already? The config parser currently doesn't remark > duplicated objects (comparing names is easy, attributes in memory is > heavy) - https://dev.icinga.org/issues/3638 Yes, I was using the same template name 'generic-service'
> I'd guess that a different template (shipped as default config) > already overrides those values. > >> >> How can I do it? What is the better method todo is intead add >> authorities = [ "node3" ] in each service line!? > > Templates are the best way to go. And even if you have inherited > service attributes from templates, you can still override/disable them > locally. > I solved it using Template inheritance as you mentioned. My current /etc/icinga2/conf.d/customers/node3/service.conf has template Service "node3-service" inherits "generic-service" { authorities = [ "icinga-node-3" ], } And in firewall.conf I replaced templates = [ "generic-service" ] by templates = [ "node3-service" ] :) > http://docs.icinga.org/icinga2/snapshot/#disable-override-objects-attributes > > > If the generic-service template doesn't fit, feel free to use more > than one template, and also multiple template levels. They may harm > readability in terms of attribute inheritance, but act as great > benefit for grouping attributes in templates together. > > Kind regards, > Michael > > Thank you Carlos _______________________________________________ icinga-users mailing list icinga-users@lists.icinga.org https://lists.icinga.org/mailman/listinfo/icinga-users