diff --git a/tasks/main.yml b/tasks/main.yml index 801c04d..811051f 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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 diff --git a/templates/item.txt.j2 b/templates/item.txt.j2 index 8af9dfd..54108c1 100644 --- a/templates/item.txt.j2 +++ b/templates/item.txt.j2 @@ -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 %}