Fix for non-existing Ansible group

This commit is contained in:
phil 2024-12-03 19:00:17 +01:00
parent 2aa8fc8981
commit 1e6f6056b7
2 changed files with 7 additions and 6 deletions

View file

@ -8,12 +8,12 @@
ansible.builtin.package_facts:
manager: auto
tags: facts
when: inventory_hostname not in groups.storage_boxes
when: inventory_hostname not in groups.storage_boxes | default([])
- name: Create hypervisor items
ansible.builtin.import_tasks: hypervisor.yml
when:
- "inventory_hostname not in groups.storage_boxes"
- "inventory_hostname not in groups.storage_boxes | default([])"
- "'qemu-system-x86' in ansible_facts.packages"
tags:
- hypervisor
@ -22,7 +22,7 @@
- name: Gather storage box facts
ansible.builtin.import_tasks: storage_box.yml
tags: storage_box
when: inventory_hostname in groups.storage_boxes
when: inventory_hostname in groups.storage_boxes | default([])
- name: Create server items
ansible.builtin.import_tasks: server.yml
@ -33,6 +33,7 @@
ansible.builtin.file:
path: "{{ cmdb.wiki_conf_file_path }}"
state: touch
mode: "0644"
run_once: true
delegate_to: "{{ cmdb.wiki_server }}"
tags: purge_cache

View file

@ -1,5 +1,5 @@
{% set host_short = inventory_hostname.split('.')[0] %}
{% if inventory_hostname not in groups.storage_boxes %}
{% if inventory_hostname not in groups.storage_boxes | default([] )%}
{%- if ansible_virtualization_role is defined %}{{'{{:cmdb:kvm.png?0x50|}}'}}{% endif %}
{%- if 'nginx' in ansible_facts.packages %}{{'{{:cmdb:nginx.png?0x50|}}'}}{% endif %}
@ -21,7 +21,7 @@
{% include 'section_customer.txt.j2' %}
{% endif %}
{% if inventory_hostname not in groups.storage_boxes %}
{% if inventory_hostname not in groups.storage_boxes | default([]) %}
{% include 'section_general.txt.j2' %}
{% include 'section_os-software.txt.j2' %}
@ -62,6 +62,6 @@
{% endif %}
{% elif inventory_hostname in groups.storage_boxes %}
{% elif inventory_hostname in groups.storage_boxes | default([]) %}
{% include 'section_storage_boxes.txt.j2' %}
{% endif %}