From 6562dba5c9fb08b4cf37eac2418bc43aeb1d9fa8 Mon Sep 17 00:00:00 2001 From: Sven Velt Date: Wed, 25 Nov 2020 10:41:02 +0100 Subject: [PATCH] Inital commit from slides --- defaults/main.yml | 4 ++++ dokuwiki_inventory.yml | 5 +++++ tasks/main.yml | 22 ++++++++++++++++++++++ templates/host.j2 | 32 ++++++++++++++++++++++++++++++++ templates/start.j2 | 4 ++++ 5 files changed, 67 insertions(+) create mode 100644 defaults/main.yml create mode 100644 dokuwiki_inventory.yml create mode 100644 tasks/main.yml create mode 100644 templates/host.j2 create mode 100644 templates/start.j2 diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..ef33bfb --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,4 @@ +--- +#doku_path: /var/lib/dokuwiki/data/pages/inventory +doku_path: /tmp/dokuwiki_inventory + diff --git a/dokuwiki_inventory.yml b/dokuwiki_inventory.yml new file mode 100644 index 0000000..0799afd --- /dev/null +++ b/dokuwiki_inventory.yml @@ -0,0 +1,5 @@ +--- +- hosts: all + roles: + - dokuwiki_inventory + diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..3abf5e8 --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,22 @@ +--- +- name: "create inventory folder {{ doku_path }}" + local_action: + module: file + path: "{{ doku_path }}" + state: directory + mode: 0755 + run_once: True + +- name: write wiki page + local_action: + module: template + src: host.j2 + dest: "{{ doku_path }}/{{ inventory_hostname }}.txt" + +- name: write index page + local_action: + module: template + src: start.j2 + dest: "{{ doku_path }}/start.txt" + run_once: True + diff --git a/templates/host.j2 b/templates/host.j2 new file mode 100644 index 0000000..9c05bf2 --- /dev/null +++ b/templates/host.j2 @@ -0,0 +1,32 @@ +====== {{ 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(', ') }} + + +Mountpoints: +| Source | Mountpoint | Filesystem | +{% for m in ansible_mounts %} +| ''{{ 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") }}'' + +---- +//{{ ansible_managed }}// diff --git a/templates/start.j2 b/templates/start.j2 new file mode 100644 index 0000000..8e9a294 --- /dev/null +++ b/templates/start.j2 @@ -0,0 +1,4 @@ +{% for h in hostvars|sort %} + * [[ {{ h }} ]] +{% endfor %} +