first commit

This commit is contained in:
phil 2023-06-19 15:12:18 +02:00
commit d1e95c0117
28 changed files with 301 additions and 0 deletions

5
templates/all.txt.j2 Normal file
View file

@ -0,0 +1,5 @@
====== Alle Server ======
{% for host in groups['all'] | sort %}
* [[cmdb:servers:all:{{ host }}]]
{% endfor %}

View file

@ -0,0 +1,5 @@
====== Hypervisor ======
{% for host in groups['virt_kvm_host'] %}
* [[cmdb:servers:all:{{ host }}]]
{% endfor %}

60
templates/item.txt.j2 Normal file
View file

@ -0,0 +1,60 @@
{% set host_short = inventory_hostname.split('.')[0] %}
{%- 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 %}
====== {{ inventory_hostname }} =======
{% include 'section_header.txt.j2' %}
{% if cmdb_customer is defined %}
{% include 'section_customer.txt.j2' %}
{% endif %}
{% include 'section_general.txt.j2' %}
{% include 'section_os-software.txt.j2' %}
{% if ansible_virtualization_role is undefined or ansible_virtualization_role == "host" %}
{% include 'section_block_devices.txt.j2' %}
{% endif %}
{% include 'section_mounted_fs.txt.j2' %}
{% include 'section_networking.txt.j2' %}
{% if "qemu-system-x86" in ansible_facts.packages %}
===== KVM =====
==== Virtual machines ====
{% if qemu_vms is defined %}
<code>
{{ qemu_vms }}
</code>
{% endif %}
==== Virtual networks ====
{% if qemu_network is defined %}
<code>
{{ qemu_network }}
</code>
{% endif %}
==== Storage pools ====
{% if qemu_pool is defined %}
<code>
{{ qemu_pool }}
</code>
{% endif %}
{% endif %}

View file

@ -0,0 +1,8 @@
===== Block devices =====
^ Model ^ Type ^ Size ^
{% for device_name, device_info in ansible_facts.devices.items() %}
{% if "nvme" in device_name or "sd" in device_name or "sr" in device_name %}
| {{ device_info.model }} | {% if "nvme" in device_name %}NVMe{% else %}SSD/HDD{% endif %} | {{ device_info.size }} |
{% endif %}
{% endfor %}

View file

@ -0,0 +1,6 @@
===== Customer =====
* Customer: {{ cmdb_customer }}
{% if cmdb_customer_service_agreement is defined %}
* Service Agreement: {{ cmdb_customer_service_agreement }}
{% endif %}

View file

@ -0,0 +1,9 @@
===== General =====
* Server Type: {% if ansible_virtualization_role == "guest" %} virtual {% else %} bare metal ({{ ansible_chassis_vendor }}){% endif %}
* Virtualization: {{ ansible_virtualization_type }}
* Architecture: ''{{ ansible_machine }}''
* RAM: ''{{ (ansible_memtotal_mb / 1024) | round(2) }} GB''
* CPU: {{ ansible_processor_vcpus }} calc units ({{ ansible_processor_count }} processors with {{ ansible_processor_cores }} cores and {{ ansible_processor_threads_per_core }} threads/core)
* CPU model: {% for line in ansible_processor %}{% if loop.index is not divisibleby 2 %}{{ line }}, {% endif %}{% endfor %}

View file

@ -0,0 +1,2 @@
* CMDB-Eintrag aktualisiert am: {{ ansible_date_time.date }} {{ ansible_date_time.time }}
* [[{{ cmdb.wiki_server_documentation_path }}:{{ inventory_hostname }}|Dokumentation]]

View file

@ -0,0 +1,6 @@
===== Mounted file systems =====
^ Device ^ Mount point ^ File system ^ Size ^
{% for item in ansible_mounts %}
| {{ item.device }} | {{ item.mount }} | {{ item.fstype }} | {{ item.size_total | human_readable(unit="G") }} |
{% endfor %}

View file

@ -0,0 +1,47 @@
===== Networking =====
==== Uplink ====
{% if ansible_facts['default_ipv6']['address'] is defined %}
**IPv6:**
* Address: ''{{ ansible_facts['default_ipv6']['address'] }}''
* Prefix: ''{{ ansible_facts['default_ipv6']['prefix'] }}''
* Gateway: {% if ansible_facts['default_ipv6']['gateway'] is defined %}''{{ ansible_facts['default_ipv6']['gateway'] }}''{% else %}no gateway{% endif %}
* Interface: ''{{ ansible_facts['default_ipv6']['interface'] }}''
* MTU: ''{{ ansible_facts['default_ipv6']['mtu'] }}''
{% endif %}
{% if ansible_facts['default_ipv4']['address'] is defined %}
**IPv4:**
* Network type: {% if (ansible_facts['default_ipv4']['address'] | ansible.utils.ipaddr('public')) %}//public//{% else %}//private//{% endif %}
* Address: ''{{ ansible_facts['default_ipv4']['address'] }}''
* Gateway: {% if ansible_facts['default_ipv4']['gateway'] is defined %}''{{ ansible_facts['default_ipv4']['gateway'] }}''{% else %}no gateway{% endif %}
* Interface: ''{{ ansible_facts['default_ipv4']['interface'] }}''
* MTU: ''{{ ansible_facts['default_ipv4']['mtu'] }}''
{% endif %}
==== Other ====
**IPv6 addresses:**
{% for address in ansible_facts['all_ipv6_addresses'] %}
* ''{{ address }}'' {% if (address | ansible.utils.ipaddr('public')) %}//public//{% else %}//private//{% endif %}
{% endfor %}
**IPv4 addresses:**
{% for address in ansible_facts['all_ipv4_addresses'] %}
* ''{{ address }}'' {% if (address | ansible.utils.ipaddr('public')) %}//public//{% else %}//private//{% endif %}
{% endfor %}
**network interfaces:**
{% for interface in ansible_facts['interfaces'] %}
* ''{{ interface }}''
{% endfor %}

View file

@ -0,0 +1,7 @@
===== OS/Software =====
* Distribution: {{ ansible_distribution }}
* Version: ''{{ ansible_distribution_version }}'' ({{ ansible_distribution_release }})
* Kernel: ''{{ ansible_kernel }}''
* Apparmor: ''{{ ansible_facts.apparmor.status }}''
* Main python version: ''{{ ansible_python_version }}''

4
templates/servers.txt.j2 Normal file
View file

@ -0,0 +1,4 @@
===== Server =====
* [[cmdb:servers:all|Alle Server]]
* [[cmdb:servers:hypervisor|Hypervisor]]