bisontim
(Mario)
November 29, 2022, 8:08am
1
Hello,
I would like to implement virtual host as explained here:
Icinga 2 Config Language (DSL): Advanced Apply Rules
I don’t understand if could I create it from Director.
Could anyone suggest me how to create it?
How to create http_vhosts by means of Director?
Is it an array?
Thanks a lot
Mario
cinga Web 2 Version
2.9.3
Git commit
c757a17530c326c7d6daebd6171486cb8167a8a1
PHP Version
7.2.24-0ubuntu0.18.04.10
Git commit date
2021-08-10
Director 1.8.1
rivad
(Dominik)
November 29, 2022, 7:12pm
2
If I understand correctly, this is currently not possible with the director.
The problem is not the applied service but the “apply for”.
There is a issue for this, but without any recent updates and it has been moved from milestone to milestone over the years.
Overrides for “normal” applied services (coming from a single apply rule or a service set) work without problems
opened 10:17AM - 03 Mar 17 UTC
ref/NC
area/apply-assign
I'm trying to override a service variable in the host to set a threshold for eac… h partition.
The generated override only matches the Name of the Apply Rule - not the individual generated services of the apply rule - as you can't select the generated service I guess overriding apply for services isn't possible (yet)?
```
object Host "BAPM0" {
import "OurLinuxHost"
address = "172.31.15.43"
groups = [ "linux", "sysE" ]
vars.disks = [ "/home" ]
vars._override_servicevars = {
"Disk Mountpoint " = {
disk_crit = "5%"
}
}
}
```
Service Template + Apply For
```
template Service "Disk Mountpoint" {
import "[Template] ssh-service (active)"
vars.by_ssh_command = "~/libexec/check_disk.lin -w $disk_warn$ -c $disk_crit$ -p $disk$"
vars.disk_crit = "10%"
vars.disk_warn = "15%"
}
apply Service "Disk Mountpoint " for (config in host.vars.disks) {
import "Disk Mountpoint"
assign where "linux" in host.groups && host.name == "BAPM0"
vars.disk = config
import DirectorOverrideTemplate
}
```
Cool would be to have the possibilty to create an override like this
```
vars._override_servicevars = {
"Disk Mountpoint /home" = {
disk_crit = "5%"
}
}
```
I couldn't find any open bugreport regarding this.
bisontim
(Mario)
November 30, 2022, 7:39am
3
Hi,
I read about the “Service apply rule” but my problem is the object “reverse-proxy-1”
How to create it from Director
object Host "reverse-proxy-1" {
import "generic-host"
address = "10.0.10.5"
vars.http_vhosts = {
"icingaweb2" = {
vhost = "icinga.domain.com"
ssl = true
}
"grafana" = {
vhost = "grafana.domain.com"
ssl = true
}
"api_v1" = {
vhost = "api.domain.com"
ssl = true
uri = "/v1"
}
"api_v2" = {
vhost = "api.domain.com"
ssl = true
uri = "/v2"
}
"status" = {
vhost = "status.domain.com"
}
}
}
I don’t understand how to create the vars mentioned there
log1c
November 30, 2022, 1:52pm
4
You can’t (afaik).
The Director does not cover 100% of the Icinga DSL, the configuration language, used in the config files.
If you want advanced service configuration or functions you will have to define them in the config files and put them somewhere under /etc/icinga2/zones.d
1 Like
bisontim
(Mario)
December 1, 2022, 3:27pm
5
I created inside:
/etc/icinga2/conf.d
a file:
myobject_service.conf with inside the specification vhost and service apply and they work.
Is it possible to import into Director so I could manage them from Director?
Thanks a lot
Mario
rivad
(Dominik)
December 2, 2022, 9:12am
6
AFAIK, not at the moment but you could manage the service template and utilized check command that is imported in your service apply rule via director.
bisontim
(Mario)
December 2, 2022, 9:54am
7
But the service template needs to have the array host.vars.http_vhosts populated with vhost and ssl but the populated field can’t be read by Director because the object Host “reverse-proxy-1” is not inside it.
So it seems that I can’t use the “Service Template” from Director too.
rivad
(Dominik)
December 2, 2022, 10:13am
8
The director has no knowledge of you service apply config and your hosts but your service apply config and your host can use stuff in director global. So you can manage some stuff in the director and use it in your handwritten config.
1 Like
bisontim
(Mario)
December 2, 2022, 10:28am
9
I understood bad, because I thought you said the opposite.
yes, my handwritten config already use object inside the Director (gropus, generic-host template, notification)
Thanks a lot
1 Like
rivad
(Dominik)
December 2, 2022, 10:58am
10
Maybe I’m out of date, have a look at why it isn’t a good idea and follow the rabbit hole:
opened 11:05AM - 04 Jul 16 UTC
closed 10:52AM - 15 Jan 21 UTC
enhancement
queue/wishlist
This issue has been migrated from Redmine: https://dev.icinga.com/issues/12093
… **Created by lebvanih on 2016-07-04 11:05:38 +00:00**
Assignee: _(none)_
Status: _New_
Target Version: _(none)_
Last Update: _2016-08-10 19:27:13 +00:00 (in Redmine)_
---
Hello,
We are currently trying to import our running configuration in Icinga Director (1.1.0). Our configuration rely on dictionaries and "nested variables" in our hosts. These are used in our "apply for" rules.
The issue is, that as from what we saw (I checked on this tracker and in the example), there is at the moment no options to reflect this kind of configuration in Director. The example provided in the documentation of Director only refer to Array.
Our configuration is mostly based on the following example from the official documentation (see \[\[http://docs.icinga.org/icinga2/latest/doc/module/icinga2/toc\#!/icinga2/latest/doc/module/icinga2/chapter/monitoring-basics#using-apply-for-custom-attribute-override\]\]):
vars.interfaces["GigabitEthernet0/2"] = {
iftraffic_units = "g"
iftraffic_community = IftrafficSnmpCommunity
iftraffic_bandwidth = 1
vlan = "internal"
qos = "disabled"
}
We also use this kind of structure:
vars.an_ncpa = {
token = "secret"
load = { warning=10, critical=20 }
cpuload = { warning=80, critical=85 }
disk["/"] = { disk_warning="15%", disk_critical="10%" }
disk["/home"] = { disk_warning="15%", disk_critical="10%" }
}
The structure above was used for three reasons in our configuration:
1. Easy to ready (for us at least)
2. No need to prefix all variable
3. Valid with Apply For.
I tried to workaround with a data field named like this: "an\_ncpa.token", but it get renamed to "an\_npcatoken" as soon as the configuration is rendered.
Is there any plan to allow dictionary creation in Icinga Director and same question for the "nested variable" (dictionary inside a dictionary for example) ?
If this kind of data structure is not "valid" could you please guide us on what we should use instead?
**Attachments**
* [filter_form_playground.png](https://dev.icinga.com/attachments/download/3563/filter_form_playground.png) tgelf - _2016-08-09 14:57:19 +00:00_
---
**Relations**:
* blocks [#11849](https://dev.icinga.com/issues/11849)
1 Like