From e5e1fd1b167ec78950a9e95f5e85e5c8308c8f2c Mon Sep 17 00:00:00 2001 From: phil Date: Wed, 1 Nov 2023 15:21:27 +0100 Subject: [PATCH] WIP: Create page for storage boxes --- tasks/main.yml | 12 +++++++++++- templates/item.txt.j2 | 33 +++++++++++++++++---------------- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/tasks/main.yml b/tasks/main.yml index 522df86..b6af909 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -8,10 +8,20 @@ ansible.builtin.package_facts: manager: auto tags: facts + when: inventory_hostname not in groups.storage_boxes + +- name: Set facts for storage storage boxes + ansible.builtin.set_fact: + ansible_date_time: + date: "{{ '%Y-%m-%d' | strftime }}" + time: "{{ '%H:%M:%S' | strftime }}" + when: inventory_hostname in groups.storage_boxes - name: Create hypervisor items ansible.builtin.import_tasks: hypervisor.yml - when: "'qemu-system-x86' in ansible_facts.packages" + when: + - "'qemu-system-x86' in ansible_facts.packages" + - "inventory_hostname not in groups.storage_boxes" tags: - hypervisor - server diff --git a/templates/item.txt.j2 b/templates/item.txt.j2 index 32bcc21..8af9dfd 100644 --- a/templates/item.txt.j2 +++ b/templates/item.txt.j2 @@ -1,15 +1,17 @@ {% set host_short = inventory_hostname.split('.')[0] %} +{% if inventory_hostname not in groups.storage_boxes %} -{%- if ansible_virtualization_role is defined %}{{'{{:cmdb:kvm.png?0x50|}}'}}{% endif %} -{%- if 'nginx' in ansible_facts.packages %}{{'{{:cmdb:nginx.png?0x50|}}'}}{% endif %} -{%- if 'apache2' in ansible_facts.packages %}{{'{{:cmdb:apache.png?0x50|}}'}}{% endif %} -{%- if 'docker' in ansible_facts.packages %}{{'{{:cmdb:docker.png?0x50|}}'}}{% endif %} -{%- if 'php' in ansible_facts.packages %}{{'{{:cmdb:php.png?0x50|}}'}}{% endif %} -{%- if 'ruby' in ansible_facts.packages %}{{'{{:cmdb:rails.png?0x50|}}'}}{% endif %} -{%- if 'mariadb-server' in ansible_facts.packages %}{{'{{:cmdb:mariadb.png?0x50|}}'}}{% endif %} -{%- if 'postgresql' in ansible_facts.packages %}{{'{{:cmdb:postgresql.png?0x50|}}'}}{% endif %} -{%- if 'tinc' in ansible_facts.packages %}{{'{{:cmdb:tinc.png?0x50|}}'}}{% endif %} -{%- if 'tor' in ansible_facts.packages %}{{'{{:cmdb:tor.png?0x50|}}'}}{% endif %} +{%- if ansible_virtualization_role is defined %}{{'{{:cmdb:kvm.png?0x50|}}'}}{% endif %} +{%- if 'nginx' in ansible_facts.packages %}{{'{{:cmdb:nginx.png?0x50|}}'}}{% endif %} +{%- if 'apache2' in ansible_facts.packages %}{{'{{:cmdb:apache.png?0x50|}}'}}{% endif %} +{%- if 'docker' in ansible_facts.packages %}{{'{{:cmdb:docker.png?0x50|}}'}}{% endif %} +{%- if 'php' in ansible_facts.packages %}{{'{{:cmdb:php.png?0x50|}}'}}{% endif %} +{%- if 'ruby' in ansible_facts.packages %}{{'{{:cmdb:rails.png?0x50|}}'}}{% endif %} +{%- if 'mariadb-server' in ansible_facts.packages %}{{'{{:cmdb:mariadb.png?0x50|}}'}}{% endif %} +{%- if 'postgresql' in ansible_facts.packages %}{{'{{:cmdb:postgresql.png?0x50|}}'}}{% endif %} +{%- if 'tinc' in ansible_facts.packages %}{{'{{:cmdb:tinc.png?0x50|}}'}}{% endif %} +{%- if 'tor' in ansible_facts.packages %}{{'{{:cmdb:tor.png?0x50|}}'}}{% endif %} +{% endif %} ====== {{ inventory_hostname }} ======= @@ -19,7 +21,7 @@ {% include 'section_customer.txt.j2' %} {% endif %} -{% if inventory_hostname not in storage_boxes %} +{% if inventory_hostname not in groups.storage_boxes %} {% include 'section_general.txt.j2' %} {% include 'section_os-software.txt.j2' %} @@ -31,11 +33,6 @@ {% include 'section_mounted_fs.txt.j2' %} {% include 'section_networking.txt.j2' %} -{% endif %} - -{% if inventory_hostname in storage_boxes %} -{% include 'section_storage_boxes.txt.j2' %} -{% endif %} {% if "qemu-system-x86" in ansible_facts.packages %} ===== KVM ===== @@ -64,3 +61,7 @@ {% endif %} {% endif %} + +{% elif inventory_hostname in groups.storage_boxes %} +{% include 'section_storage_boxes.txt.j2' %} +{% endif %}