feat: add options in hosts
This commit is contained in:
parent
a0efb0d8db
commit
eaf0b7e0c7
2 changed files with 27 additions and 0 deletions
|
@ -8,6 +8,7 @@ Which is based on [Keep A Changelog](http://keepachangelog.com/)
|
|||
### Added
|
||||
|
||||
- add dependencies
|
||||
- add options in host
|
||||
|
||||
### Fixed
|
||||
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
{% for name, host in icinga2_hosts.items() %}
|
||||
|
||||
object Host "{{ name }}" {
|
||||
{% if host.template is defined %}
|
||||
import "{{ host.template }}"
|
||||
{% endif %}
|
||||
{% if host.address is defined %}
|
||||
address = "{{ host.address }}"
|
||||
{% endif %}
|
||||
|
@ -12,6 +14,30 @@ object Host "{{ name }}" {
|
|||
{% if host.zone is defined %}
|
||||
zone = "{{ host.zone }}"
|
||||
{% endif %}
|
||||
{% if host.options is defined %}
|
||||
{% for var, value in host.options.items() %}
|
||||
{% if value is sameas True %}
|
||||
{{ var }} = true
|
||||
{% elif value is sameas False %}
|
||||
{{ var }} = false
|
||||
{% elif value is mapping %}
|
||||
{% for name, config in value.items() %}
|
||||
{{ var }}["{{ name }}"] = {
|
||||
{% for option, v in config.items() %}
|
||||
{{ option }} = {% if v is number %}{{ v }}{% else %}"{{ v }}"{% endif %}
|
||||
|
||||
{% endfor %}
|
||||
}
|
||||
{% endfor %}
|
||||
{% elif value is iterable and not value is string %}
|
||||
{{ var }} = [ "{{ value|join(', "') }}" ]
|
||||
{% elif value is number or value|regex_search('^[0-9]+(s|m|h|d)$') %}
|
||||
{{ var }} = {{ value }}
|
||||
{% else %}
|
||||
{{ var }} = "{{ value }}"
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if host.vars is defined %}
|
||||
|
||||
{% for var, value in host.vars.items() %}
|
||||
|
|
Loading…
Reference in a new issue