Conversation
dd916d4 to
f19501d
Compare
2ddc75b to
3583514
Compare
e818e3e to
3260c35
Compare
01bbc41 to
e1fac6d
Compare
6493a77 to
0807528
Compare
afa36bc to
57bf362
Compare
f7cac18 to
8f85549
Compare
4c6962e to
7aba001
Compare
|
Unfortunately, I had to revert automatic form element escaping in ipl-html: Icinga/ipl-html#196 So you have to protect against invalid form element names here on your own. A viable and easy alternative might be hashing the names using md5. |
Thanks for the info! However, the implementation has changed since then and custom variable names are no longer used as form element names. Hence, reverting those changes will not affect this PR. |
Introduce a first-class DirectorProperty concept that extends the existing
data-fields model with rich, structured variable types. Custom variables can
now be defined globally under a new "Custom Variables" section and assigned
to Icinga objects (hosts, services, commands, etc.).
Supported types: string, number, boolean, fixed-array, dynamic-array,
datalist-strict, datalist-non-strict, fixed-dictionary, and
dynamic-dictionary (one level of nesting allowed).
Key changes:
- DirectorProperty object with CRUD, inheritance, and apply-for rule support
- New form elements: Dictionary, DictionaryItem, NestedDictionary,
NestedDictionaryItem, ArrayElement, IplBoolean
- CustomvarController for managing global property definitions
- VariablesController for per-object variable assignment
- BasketSnapshotCustomVariableResolver for basket import/export of properties
- REST API: IcingaObjectHandler extended to expose and accept structured vars
- IcingaConfigHelper: renders dictionaries/arrays to valid Icinga 2 DSL
- CustomVarRenderer updated for icingadb hook display
- DB migration upgrade_192.sql: new director_property and related tables
- CLI: MigrateCommand for migrating legacy vars to properties;
HostsCommand for bulk host custom variable management
Constraints follow the pattern `<table>_<column>`.
There was a problem hiding this comment.
Test
Director with autodiscovery
(I guess this is my next blogpost topic...)
- Install Fedora 42
- Apply https://github.com/Al2Klimov/ansible-icinga-fedora
dnf install nmapgit clone https://github.com/Thomas-Gelf/icingaweb2-module-nmap.git /usr/share/icingaweb2/modules/nmapicingacli mod en nmap- Add nmap import source and a job for it to run regularly
- Add sync rule and a job for it to run regularly
- Add service apply rule
- Deploy once you got new hosts
nmap import source
- Key column: host
- Subnet: 10.27.0.0/16
Modifier
- Property: host
- Modifier: Skip row if...
Sync rule
- Type: Host
- Update: merge
- Purge: no
Sync property
- Source: nmap
- Field: address
- Source: ip
Sync property
- Source: nmap
- Field: check_command
- Source: custom
- Expression: ping
Jobs
- Run import: yes
- Apply changes: yes
Service apply rule
You must add a service template first. #3068
- Check command: ssh
- Assign where: host.address is set
Add existing data fields
https://github.com/Thomas-Gelf/icingaweb2-module-nmap doesn't import open ports, so latter are the perfect use case.
- Start
nmap -T5 10.27.0.0/16 - Add array data field
- Add host template
- Add data field to host template as optional
- Add property to your sync rule
- Add service apply rule
- Once nmap(1) is done, add open ports to individual hosts
- Deploy
Sync property
- Source: nmap
- Field: import
- Source: your template
Service apply rule
You must add a service template first. #3068
That template must also provide a data field tcp_port.
See also https://icinga.com/docs/icinga-director/latest/doc/15-Service-apply-for-example/
- Apply for: your data field (Edit: #3072 🙈)
- Check command: tcp
- Assign where: your data field is set (#3069)
- Custom property "TCP port":
$config$
Migrate
=> #2972
mysqldump director > director.sqlJust to be sure. :-)- Downgrade to https://git.icinga.com/packages/icinga-director/-/jobs/887605
- Apply DB migration (Director overview page)
icingacli director migrate datafields --dry-run --verbose
Result:
ERROR: Zend_Db_Statement_Exception in /usr/share/icinga-php/vendor/vendor/icinga/zf1/library/Zend/Db/Statement/Pdo.php:235 with message: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ')) ) GROUP BY varname' at line 1, query was: SELECT dd.id, dd.varname, dd.caption, dd.description, dd.datatype, dd.category_id, COUNT(varname) AS count FROM director_datafield AS dd WHERE ( NOT (()) ) GROUP BY varname
This is bad.
Good catch. Should be resolved now :) |
Requires:
Icinga/ipl-web#355