telekom-mms / ansible-collection-icinga-director

An Ansible collection that contains modules to change objects in Icinga 2 using the director API.
GNU General Public License v3.0
81 stars 30 forks source link

Simplify role variables by removing one layer #234

Closed rndmh3ro closed 11 months ago

rndmh3ro commented 11 months ago

BREAKING CHANGE

previously you could create multiple different objects with the same config:

     icinga_hostgroups:
      - hostgroup_object:
        - "service_abbreviation-environement"
        - "service_abbreviation-environement-web"
        state: present

However internally I don't see any broad adaption of this and it makes it harder to use (the list after the list next to the key-value pairs is confusing) and it is harder to write and maintain.

Compare:

     - name: icinga_hostgroup
       icinga_hostgroup:
         url: "{{ icinga_url }}"
    @@ -11,15 +9,15 @@
         force_basic_auth: "{{ icinga_force_basic_auth | default(omit) }}"
         client_cert: "{{ icinga_client_cert | default(omit) }}"
         client_key: "{{ icinga_client_key | default(omit) }}"
        state: "{{ hostgroup.0.state | default(omit) }}"
        object_name: "{{ hostgroup.1 }}"
        display_name: "{{ hostgroup.0.display_name | default(omit) }}"
        assign_filter: "{{ hostgroup.0.assign_filter | default('host.name=\"' + hostgroup.1 + '-*\"') }}"
       retries: 3
       delay: 3
       register: result
       until: result is succeeded
      loop: "{{ icinga_hostgroups|subelements('hostgroup_object') }}"
       loop_control:
         loop_var: hostgroup
       tags: hostgroup

with:

     - name: icinga_hostgroup
       icinga_hostgroup:
         url: "{{ icinga_url }}"
    @@ -11,15 +9,15 @@
         force_basic_auth: "{{ icinga_force_basic_auth | default(omit) }}"
         client_cert: "{{ icinga_client_cert | default(omit) }}"
         client_key: "{{ icinga_client_key | default(omit) }}"
        state: "{{ hostgroup.state | default(omit) }}"
        object_name: "{{ hostgroup.name }}"
        display_name: "{{ hostgroup.display_name | default(omit) }}"
        assign_filter: "{{ hostgroup.assign_filter | default('host.name=\"' + hostgroup.name + '-*\"') }}"
       retries: 3
       delay: 3
       register: result
       until: result is succeeded
       loop: "{{ icinga_hostgroups }}"
       loop_control:
         loop_var: hostgroup
       tags: hostgroup