Icinga / ansible-icinga2

Ansible Role for Icinga 2
Apache License 2.0
50 stars 23 forks source link

i2_features not working #45

Closed NeverUsedID closed 4 years ago

NeverUsedID commented 4 years ago

When executing this Playbook:

- name: icinga Package
  hosts: icingaagents
  roles:
    - icinga2
  vars:
    - i2_custom_features:
      ApiListener:
        api:
          accept_command: true
          accept_config: true
    - i2_confd: []

I get this Error:

TASK [icinga2 : include icinga2-features.yml] ****************************************************************************************************************************************************************
fatal: [1.1.1.1]: FAILED! => {"msg": "The conditional check 'i2_features|flatten|length > 0' failed. The error was: Unexpected templating type error occurred on ({% if i2_features|flatten|length > 0 %} True {% else %} False {% endif %}): 'NoneType' object is not iterable\n\nThe error appears to be in '/etc/ansible/roles/icinga2/tasks/main.yml': line 21, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: include icinga2-features.yml\n  ^ here\n"}

When i change this task to "is defined":

- name: include icinga2-features.yml
  include_tasks: icinga2-features.yml
  #when: i2_features|flatten|length > 0
  when: i2_features is definded

i get:

`TASK [icinga2 : generate enabled feature configuration] ** fatal: [1.1.1.1]: FAILED! => {"msg": "with_dict expects a dict"}

`

It looks like variable i2_features is empty when the task is executed, but i can't find a solution for that.

The Release package without i2_features works, but can't enable features. I also had some problems to understand why there is i2_features and i2_custom_features at the beginning. Why not use only one variable for both and add switches to custom_features like enable: true

NeverUsedID commented 4 years ago

Found it. I'am rather new to ansible and iu just copied the example from the doc with the "-". The working version witzhout the "-" in vars: :

- name: icinga Package
  hosts: icingaagents
  roles:
    - icinga2
  vars:
    i2_custom_features:
      ApiListener:
        api:
          accept_command: true
          accept_config: true
    i2_confd: []