i2_custom_constants for ApiListner creates faulty config
Nokius opened this issue · comments
looks like the template creates a faulty configuration for the api feature.
the variables used as mentioned in the README
i2_custom_features:
ApiListener:
api:
accept_config: true
accept_commands: true
The result ansible creates
# cat features-enabled/ApiListener.conf
// Ansible managed
object ApiListener "api" {
accept_config = "True"
accept_commands = "True"
}
syntax complain
# icinga2 daemon -C
[2020-01-28 16:14:53 +0100] information/cli: Icinga application loader (version: r2.11.2-1)
[2020-01-28 16:14:53 +0100] information/cli: Loading configuration file(s).
[2020-01-28 16:14:53 +0100] information/ConfigItem: Committing config item(s).
[2020-01-28 16:14:53 +0100] critical/config: Error: Error while evaluating expression: Can't convert 'True' to a floating point number.
Location: in /etc/icinga2/features-enabled/ApiListener.conf: 4:4-4:25
/etc/icinga2/features-enabled/ApiListener.conf(2):
/etc/icinga2/features-enabled/ApiListener.conf(3): object ApiListener "api" {
/etc/icinga2/features-enabled/ApiListener.conf(4): accept_config = "True"
^^^^^^^^^^^^^^^^^^^^^^
/etc/icinga2/features-enabled/ApiListener.conf(5): accept_commands = "True"
/etc/icinga2/features-enabled/ApiListener.conf(6): }
[2020-01-28 16:14:53 +0100] critical/config: 1 error
[2020-01-28 16:14:53 +0100] critical/cli: Config validation failed. Re-run with 'icinga2 daemon -C' after fixing the config.
Result expected is
cat features-enabled/ApiListener.conf
// Ansible managed
object ApiListener "api" {
accept_config = true
accept_commands = true
Looks like the api follows a different syntax then the other features.
unfortunately my ansible skill is not enough to make PR. :(
Thanks for your feedback.
Hi @RossBarnie,
I tried it but I got quoted output too.
There are a few suggestions on ansible/ansible#11905:
accept_config: !!str true
accept_config: 'true'
accept_config: {{ true | lower }}
Can you try these and let us know if any fix your issue?
sorry FOSDEM weekend was in between,
vars:
ApiListener:
api:
accept_command: !!str true
accept_config: "{{ true | lower }}"
result is:
object ApiListener "api" {
accept_command = "true"
accept_config = "true"
}
the remaining issue are the double quotes
[2020-02-03 17:56:59 +0100] critical/config: Error: Error while evaluating expression: Can't convert 'true' to a floating point number.
Location: in /etc/icinga2/features-enabled/ApiListener.conf: 4:4-4:27
/etc/icinga2/features-enabled/ApiListener.conf(2):
/etc/icinga2/features-enabled/ApiListener.conf(3): object ApiListener "api" {
/etc/icinga2/features-enabled/ApiListener.conf(4): accept_commands = "true"
^^^^^^^^^^^^^^^^^^^^^^^^
/etc/icinga2/features-enabled/ApiListener.conf(5): accept_config = "true"
/etc/icinga2/features-enabled/ApiListener.conf(6): }
[2020-02-03 17:56:59 +0100] critical/config: 1 error
Looks like there is a bug here in that we do special-case False attributes but not True ones, see https://github.com/Icinga/ansible-icinga2/blob/master/templates/object_attributes.j2#L28.