Skip to content

Commit

Permalink
Merge pull request #311 from Icinga/fix/308-icinga2_objects-treated-a…
Browse files Browse the repository at this point in the history
…s-list

Properly check if vars['icinga2_objects'] is list
  • Loading branch information
Donien authored Jul 29, 2024
2 parents 55e56b3 + 55f0e45 commit cf33636
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/fix_issue_308.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- "The type of :code:`vars['icinga2_objects']` was wrongly tested for. This should be a list. The type is now `properly checked <https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_tests.html#type-tests>`_ for (#308)."
17 changes: 15 additions & 2 deletions roles/icinga2/tasks/objects.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
---
- name: collect all config objects for myself
- name: collect all config objects for myself (from all inventory hosts)
set_fact:
tmp_objects: "{{ tmp_objects| default([]) + lookup('list', hostvars[item]['icinga2_objects'][icinga2_config_host]) }}"
with_items: "{{ groups['all'] }}"
when: hostvars[item]['icinga2_objects'][icinga2_config_host] is defined

- name: collect all config objects for myself (from myself if list)
set_fact:
tmp_objects: "{{ tmp_objects | default([]) + lookup('list', hostvars[inventory_hostname]['icinga2_objects']) }}"
when:
- hostvars[inventory_hostname]['icinga2_objects'] is defined
- hostvars[inventory_hostname]['icinga2_objects'] is iterable
- hostvars[inventory_hostname]['icinga2_objects'] is not string
- hostvars[inventory_hostname]['icinga2_objects'] is not mapping

- name: collect all config objects in play vars
set_fact:
tmp_objects: "{{ tmp_objects| default([]) + lookup('list', icinga2_objects) }}"
when: icinga2_objects is defined and vars['icinga2_objects'][icinga2_config_host] is not defined
when:
- icinga2_objects is defined
- icinga2_objects is iterable
- icinga2_objects is not string
- icinga2_objects is not mapping

- icinga2_object:
args: "{{ item }}"
Expand Down

0 comments on commit cf33636

Please sign in to comment.