diff --git a/tasks/main.yml b/tasks/main.yml index a1c3d8a..7004b87 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -7,6 +7,12 @@ mode: 0755 run_once: True +- package_facts: + ignore_errors: True + +- service_facts: + ignore_errors: True + - name: write wiki page local_action: module: template diff --git a/templates/host.j2 b/templates/host.j2 index 9c05bf2..458ff84 100644 --- a/templates/host.j2 +++ b/templates/host.j2 @@ -1,32 +1,48 @@ ====== {{ inventory_hostname }} ====== - * FQDN: {{ ansible_fqdn }} -- {{ ansible_default_ipv4.address }} - * Product: **{{ ansible_system_vendor|default("N/A") }}** {{ ansible_product_name|default("N/A") }} (S/N: {{ ansible_product_serial }}), {{ ansible_form_factor }} - * Virtualization: {{ ansible_virtualization_role }} / {{ ansible_virtualization_type }} - * CPUs: {{ ansible_processor_vcpus }} ( {{ ansible_processor_count }} x {{ ansible_processor_cores }} Cores x {{ ansible_processor_threads_per_core }} Threads ) - * CPU-Type: {{ ansible_processor[2] }} - * RAM: {{ ansible_memtotal_mb }} MB - * Swap: {{ "%0.2f" % (ansible_swaptotal_mb / 1024) }} GB - * OS: {{ ansible_distribution }} {{ ansible_distribution_version }} - * Kernel: {{ ansible_kernel }} - * Init: {{ ansible_service_mgr }} - * IPs: - * IPv4: {{ ansible_all_ipv4_addresses|join(', ') }} - * IPv6: {{ ansible_all_ipv6_addresses|join(', ') }} - +^ FQDN | {{ ansible_fqdn }} | +^ Product | **{{ ansible_system_vendor|default("N/A") }}** {{ ansible_product_name|default("N/A") }} | +^ S/N | {{ ansible_product_serial|default('N/A') }} | +^ Form factor | {{ ansible_form_factor|default('-') }} | +^ Virtualization | {{ ansible_virtualization_type|default('-')|upper }} - {{ ansible_virtualization_role|default('-')|capitalize }} | +^ CPUs | {{ ansible_processor_vcpus|default('N/A') }} ( {{ ansible_processor_count|default('N/A') }} Socket/s x {{ ansible_processor_cores|default('N/A') }} Core/s x {{ ansible_processor_threads_per_core|default('N/A') }} Thread/s ) | +^ CPU-Type | {{ ansible_processor[2]|default(ansible_processor[1])|default('N/A') }} | +^ RAM | {{ "%0.2f" % (ansible_memtotal_mb|default(0) / 1024) }} GB ({{ ansible_memtotal_mb|default(0) }} MB) | +^ Swap | {% if ansible_swaptotal_mb|default(False) %}{{ "%0.2f" % (ansible_swaptotal_mb / 1024) }} GB ({{ansible_swaptotal_mb}} MB){% else %}N/A{% endif %} | +^ OS | {{ ansible_distribution }} {{ ansible_distribution_version }} "//{{ ansible_distribution_release|default('-') }}//" | +^ Kernel | {{ ansible_kernel }} | +^ Init | {{ ansible_service_mgr }} | +^ Default IP | {{ ansible_default_ipv4.address|default('') }} \\ {{ ansible_default_ipv6.address|default(False) }} | +^ IPv4 | {% if ansible_all_ipv4_addresses %}{{ ansible_all_ipv4_addresses|join(' \\\\ ') }}{% endif %} | +^ IPv6 | {% if ansible_all_ipv6_addresses %}{% for ip in ansible_all_ipv6_addresses %}{% if not ip.startswith('fe80') %}{{ ip }} \\ {% endif %}{% endfor %}{% endif %} | Mountpoints: | Source | Mountpoint | Filesystem | -{% for m in ansible_mounts %} +{% for m in ansible_mounts|default([]) %} | ''{{ m.device }}'' | ''{{ m.mount }}'' | ''{{ m.fstype }}'' | {% endfor %} * AppArmor: {{ ansible_apparmor.status }} * SE-Linux: {{ ansible_selinux.status }} * SSH-Host-Keys: - * DSA: ''{{ ansible_ssh_host_key_dsa_public|default("N/A") }}'' - * RSA: ''{{ ansible_ssh_host_key_rsa_public|default("N/A") }}'' - * ECDSA: ''{{ ansible_ssh_host_key_ecdsa_public|default("N/A") }}'' - * Ed25519: ''{{ ansible_ssh_host_key_ed25519_public|default("N/A") }}'' + * DSA: {{ ansible_ssh_host_key_dsa_public|default("N/A") }} + * RSA: {{ ansible_ssh_host_key_rsa_public|default("N/A") }} + * ECDSA: {{ ansible_ssh_host_key_ecdsa_public|default("N/A") }} + * Ed25519: {{ ansible_ssh_host_key_ed25519_public|default("N/A") }} + +===== Packages ===== + +{% if ansible_facts.packages is defined %}^ Package ^ Version ^ +{% for pkg in ansible_facts.packages | dictsort %}^ {{ pkg.0 }} | {{ pkg.1.0.version }}{% if pkg.1.0.release|default(False)|bool %}-{{ pkg.1.0.release }}{% endif %} | +{% endfor %} +{% endif %} + +===== Services ===== + +{% if ansible_facts.services is defined %}^ Service ^ State ^ +{% for svc in ansible_facts.services %}{% if ansible_facts.services[svc]['state'] == "running" %}^ {{ svc }} | {{ ansible_facts.services[svc]['state'] }} | +{% endif %}{% endfor %} +{% endif %} ---- + //{{ ansible_managed }}// diff --git a/templates/start.j2 b/templates/start.j2 index 8e9a294..cbaed42 100644 --- a/templates/start.j2 +++ b/templates/start.j2 @@ -1,4 +1,16 @@ -{% for h in hostvars|sort %} - * [[ {{ h }} ]] +^ Host \\ IP ^ Hardware ^ Distribution \\ Version ^ Package Mgr \\ Installed ^ Service Mgr ^ +{% for h in hostvars|sort %}^ [[ {{ h }} ]] \\ {{ hostvars[h]['ansible_default_ipv4']['address']|default('-') }} {# +#}{% if 'ansible_distribution' in hostvars[h] %} {# + #}|{% if hostvars[h]['ansible_virtualization_type']|default('-') == "lxc" + %}LXC{% else + %}{% if hostvars[h]['ansible_virtualization_role']|default('-') == 'guest' + %}({{ hostvars[h]['ansible_virtualization_type']|default('-')|upper}}) {% endif + %}**{{ hostvars[h]['ansible_system_vendor']|default('-') }}** \\ {{ hostvars[h]['ansible_product_name']|default('-') }}{# + #}{% endif + %}| **{{ hostvars[h]['ansible_distribution'] }}** \\ {{ hostvars[h]['ansible_distribution_version'] }} - {{ hostvars[h]['ansible_distribution_release']|default('-') }}{# + #}| {{ hostvars[h]['ansible_pkg_mgr'] }} / {{ (hostvars[h]['ansible_facts']['packages'])|default([])|length }} {# + #}| {{ hostvars[h]['ansible_service_mgr'] }} | +{% else %}|||||| +{% endif %} {% endfor %}