Lazy SysAdmin strikes back

certbot_on_virtu
Alexandre Iooss 2020-07-01 11:17:03 +02:00
parent 6d5cd2a567
commit 1e28c82ca8
No known key found for this signature in database
GPG Key ID: 6C79278F3FCDCC02
4 changed files with 124 additions and 24 deletions

View File

@ -1,7 +1,7 @@
#!/usr/bin/env ansible-playbook
---
# Document servers
- hosts: zamok.adm.crans.org # test only on voyager for now
- hosts: server
vars:
moinmoin_user: "{{ vault_moinmoin_user }}"
moinmoin_password: "{{ vault_moinmoin_password }}"

View File

@ -0,0 +1,68 @@
#!/usr/bin/python
# Written By - Rishabh Das <rishabh5290@gmail.com>
# Modified By - Alexandre Iooss <erdnaxe@crans.org>
#
# This program is a free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 2 of the license, or(at your option) any
# later version. See http://www.gnu.org/copyleft/gpl.html for the full text of
# the license.
##############################################################################
DOCUMENTATION = '''
---
module: dmidecode
version_added: "0.1"
short_description: Get dmidecode information for your infrastructure.
description:
- Get the dmidecode information of your infrastructure.
'''
EXAMPLES = '''
# dmidecode module takes in 'save' as a paramter. If set True,
# this stores the dmidecode JSON output on the target machine.
# This by default is set to False.
# Usage Examples -
- name: Get dmidecode data
action: dmidecode
'''
import dmidecode
import json
from ansible.module_utils.basic import AnsibleModule
def decode_dict(data):
data_type = type(data)
if data == None: return ""
if data_type == bytes: return data.decode()
if data_type in (str, int, bool): return str(data)
if data_type == dict: data = data.items()
return data_type(map(decode_dict, data))
def run_module():
module = AnsibleModule(
argument_spec = {}
)
dmi_data = decode_dict({
'bios': dmidecode.bios(),
'processor': dmidecode.processor(),
'system': dmidecode.system(),
'memory': dmidecode.memory(),
'slot': dmidecode.slot(),
})
module.exit_json(changed=True, ansible_facts=dmi_data)
def main():
run_module()
if __name__ == '__main__':
main()

View File

@ -1,4 +1,15 @@
---
- name: Install python3-dmidecode
apt:
update_cache: true
name: python3-dmidecode
register: apt_result
retries: 3
until: apt_result is succeeded
- name: get dmidecode facts
dmidecode: {}
- name: "Create wiki page documenting {{ ansible_hostname }} (physical)"
when: ansible_system_vendor != 'QEMU'
moinmoin_page:

View File

@ -14,33 +14,40 @@
'''Domaine''' :
{{ ansible_domain }}
'''CPU''' :
{{ ansible_processor_count }} processeur(s)
avec {{ ansible_processor_cores }} cœur(s)
divisé(s) en {{ ansible_processor_threads_per_core }} thread(s).
=== Processeur ===
'''Mémoire''' :
{{ (ansible_memory_mb.real.total/1024)|round(1) }} GiB de mémoire RAM
et {{ (ansible_memory_mb.swap.total/1024)|round(1) }} GiB de SWAP.
=== Stockage ===
|| Point de montage || Taille || Disque ||
{% for m in ansible_mounts %}
{% if m.fstype == 'ext4' and 'size_total' in m %}
|| {{ m.mount }} || {{ m.size_total|human_readable(unit='G') }} || {{ m.device }} ||
|| '''Socket''' || '''Nombre de cœur(s)''' || '''Nombre de thread(s)''' || '''Modèle''' ||
{% for m in processor.values() %}
{% if m.data["Asset Tag"] %}
|| {{ m.data["Socket Designation"] }} || {{ m.data["Core Count"] }} || {{ m.data["Thread Count"] }} || {{ m.data["Version"] }} ||
{% endif %}
{% endfor %}
=== Interfaces réseau ===
=== Mémoire vive ===
|| Device || IPv4 || IPv6 || MAC ||
{% for i in ansible_interfaces %}
{% set interface = vars["ansible_" + i] %}
{% if interface.active and interface.type == 'ether' and 'ipv4' in interface %}
|| {{ interface.device }} || {{ interface.ipv4.address }} || {# No newline #}
{% for ip in interface.ipv6 %}{{ ip.address }} {% endfor %} || {# No newline #}
{{ interface.macaddress }} ||
{{ (ansible_memory_mb.real.total/1024)|round(1) }} GiB de mémoire RAM
et {{ (ansible_memory_mb.swap.total/1024)|round(1) }} GiB de SWAP.
|| '''Emplacement''' || '''Taille''' || '''Vitesse''' || '''Caractéristiques''' || '''Modèle''' ||
{% for m in memory.values() %}
{% if m.data.Locator is defined and m.data.Size %}
|| {{ m.data["Locator"] }} || {{ m.data["Size"] }} || {{ m.data["Speed"] }} || {{ m.data["Type Detail"] | join(' ') }} || {{ m.data["Manufacturer"] }} {{ m.data["Part Number"] }} ||
{% endif %}
{% endfor %}
=== Cartes PCI ===
|| '''Emplacement''' || '''Taille du bus''' ||
{% for m in slot.values() %}
|| {{ m.data["Designation"] }} || {{ m.data["Type:SlotType"] }} {{ m.data["Type:SlotBusWidth"] }} ||
{% endfor %}
=== Stockage ===
|| '''Point de montage''' || '''Taille''' || '''Disque''' ||
{% for m in ansible_mounts %}
{% if m.fstype == 'ext4' and 'size_total' in m %}
|| {{ m.mount }} || {{ m.size_total|human_readable(unit='G') }} || {{ m.device }} ||
{% endif %}
{% endfor %}
@ -53,5 +60,19 @@ et {{ (ansible_memory_mb.swap.total/1024)|round(1) }} GiB de SWAP.
{{ ansible_kernel }}
'''BIOS installé''' :
{{ ansible_bios_version }} datant du {{ ansible_bios_date }}
{%- for b in bios.values() %}
{{ b.data["Vendor"] }} {{ b.data["Version"] }} {{ b.data["BIOS Revision"] }} ({{ b.data["Release Date"] }})
{%- if b.data["Characteristic x2"]["UEFI is supported"] == "True" %}, UEFI{% endif %}
{% endfor %}
=== Interfaces réseau ===
|| '''Interface''' || '''IPv4''' || '''IPv6''' || '''MAC''' ||
{% for i in ansible_interfaces %}
{% set interface = vars["ansible_" + i] %}
{% if interface.active and interface.type == 'ether' and 'ipv4' in interface %}
|| {{ interface.device }} || {{ interface.ipv4.address }} || {# No newline #}
{% for ip in interface.ipv6 %}{{ ip.address }} {% endfor %} || {# No newline #}
{{ interface.macaddress }} ||
{% endif %}
{% endfor %}