Alletra - Ansible

This playbook runs a series of HPE 3paradm commands on Alletra storage for weekly monitoring purposes. A separate file will be created for each host and a separate email will be sent with the attached file.

Lauch the playbook

You can launch the weekly script using the following command:

# ansible-playbook -i myhost1.org,myhost2.org, /path/to/Check_Storages.yml -u 3paradm --ask-pass

You will receive separate mails in your mailbox with attached file.

The playbook

The full script:

---
- name: Run a command on Alletra storage
hosts: all
gather_facts: no

tasks:
#=======================================================
# Basics definitions
#=======================================================
- name: Get the current date
set_fact:
current_date: "{{ lookup('pipe', 'date +%Y-%m-%d') }}"

- name: Define the output path file
set_fact:
path_OF: "/my/File/Path/ALLETRA-{{ inventory_hostname }}-{{ current_date }}.txt"

#=======================================================
# ▉ ALLETRA COMMANDS
#=======================================================

#==========================
## GENERAL
- name: Display certificates
raw: "showcert"
register: showcert_output

- name: Display a list of domains in a system
raw: "showdomain -d"
register: showdomain_output

- name: Display information about defined hosts and host paths in the system
raw: "showhost -d"
register: showhost_output

- name: Display information about WSAPI
raw: "showwsapi"
register: showwsapi_output

#==========================
## HARDWARE
- name: Displays information about drive cages
raw: "showcage -i"
register: showcage_output

- name: Displays estimated free space for logical disk creation
raw: "showspace"
register: showspace_output

- name: Displays the system table of contents summary that provides a summary of the system's resources
raw: "showtoc"
register: showtoc_output

- name: Displays information about the nodes
raw: "shownode"
register: shownode_output

- name: Displays information about all the hardware components in the system
raw: "showinventory"
register: showinventory_output

- name: Displays configuration information about a system's physical disks
raw: "showpd"
register: showpd_output

- name: Displays configuration information about the system's LDs
raw: "showld"
register: showld_output

- name: Displays information about all Virtual Volumes (VVs)
raw: "showvv"
register: showvv_output

- name: Displays the Virtual Volume(VV) sets defined on the storage system and their members
raw: "showvvset -d"
register: showvvset_output

- name: Displays information about Virtual Logical Unit Numbers (VLUNs) in the system
raw: "showvlun"
register: showvlun_output
register: showvvset_output

- name: Displays details of the Remote Copy configuration
raw: "showrcopy -d"
register: showrcopy_output

#==========================
## LOGS AND ALERTS
- name: Displays the status of system alerts
raw: "showalert -n"
register: showalert_output

- name: Displays component reset reason details
raw: "showreset"
register: showreset_output

- name: Displays the current system event log
raw: "showeventlog -min 10080 -oneline -sev Fatal"
register: showeventlogfatal_output

- name: Displays the current system event log
raw: "showeventlog -min 10080 -oneline -sev Critical"
register: showeventlogcrit_output

- name: Displays the current system event log
raw: "showeventlog -min 10080 -oneline -sev Major"
register: showeventlogmaj_output

- name: Displays the current system event log
raw: "showeventlog -min 10080 -oneline -sev Degraded"
register: showeventlogdeg_output

#=======================================================
## OUTPUT
#=======================================================
- name: Write the OUTPUT to a file on the local machine
local_action:
module: shell
cmd: |
echo "╔══════════════════════════════════════════════════════════════════════════════════════════════════════════╗" > {{ path_OF }}
echo "║ ALLETRA STORAGE CHECK " >> {{ path_OF }}
echo "║ HOSTNAME: {{ inventory_hostname }} " >> {{ path_OF }}
echo "║ DATE: {{ lookup('pipe', 'date +%Y-%m-%d') }} " >> {{ path_OF }}
echo "╚══════════════════════════════════════════════════════════════════════════════════════════════════════════╝" >> {{ path_OF }}
echo "╔══════════════════════════════════════════════════════════════════════════════════════════════════════════╗" >> {{ path_OF }}
echo "║ ▉ 1 - GENERAL " >> {{ path_OF }}
echo "╚══════════════════════════════════════════════════════════════════════════════════════════════════════════╝" >> {{ path_OF }}
echo "" >> {{ path_OF }}
echo "┌──────────────────────────────────────────────────────────────────────────────────────────────────────────" >> {{ path_OF }}
echo "│ Display certificates (showcert)" >> {{ path_OF }}
echo "└──────────────────────────────────────────────────────────────────────────────────────────────────────────" >> {{ path_OF }}
echo "{{ showcert_output.stdout }}" >> {{ path_OF }}
echo "" >> {{ path_OF }}
echo "┌──────────────────────────────────────────────────────────────────────────────────────────────────────────" >> {{ path_OF }}
echo "│ Displays a list of domains in a system (showdomain -d)" >> {{ path_OF }}
echo "└──────────────────────────────────────────────────────────────────────────────────────────────────────────" >> {{ path_OF }}
echo "{{ showdomain_output.stdout }}" >> {{ path_OF }}
echo "" >> {{ path_OF }}
echo "┌──────────────────────────────────────────────────────────────────────────────────────────────────────────" >> {{ path_OF }}
echo "│ Display information about defined hosts and host paths in the system (showhost -d)" >> {{ path_OF }}
echo "└──────────────────────────────────────────────────────────────────────────────────────────────────────────" >> {{ path_OF }}
echo "{{ showhost_output.stdout }}" >> {{ path_OF }}
echo "" >> {{ path_OF }}
echo "┌──────────────────────────────────────────────────────────────────────────────────────────────────────────" >> {{ path_OF }}
echo "│ Display information about WSAPI (showwsapi)" >> {{ path_OF }}
echo "└──────────────────────────────────────────────────────────────────────────────────────────────────────────" >> {{ path_OF }}
echo "{{ showwsapi_output.stdout }}" >> {{ path_OF }}
echo "" >> {{ path_OF }}
echo "╔══════════════════════════════════════════════════════════════════════════════════════════════════════════╗" >> {{ path_OF }}
echo "║ ▉ 2 - HARDWARE " >> {{ path_OF }}
echo "╚══════════════════════════════════════════════════════════════════════════════════════════════════════════╝" >> {{ path_OF }}
echo "" >> {{ path_OF }}
echo "┌──────────────────────────────────────────────────────────────────────────────────────────────────────────" >> {{ path_OF }}
echo "│ Displays information about drive cages (showcage -i)" >> {{ path_OF }}
echo "└──────────────────────────────────────────────────────────────────────────────────────────────────────────" >> {{ path_OF }}
echo "{{ showcage_output.stdout }}" >> {{ path_OF }}
echo "" >> {{ path_OF }}
echo "┌──────────────────────────────────────────────────────────────────────────────────────────────────────────" >> {{ path_OF }}
echo "│ Displays estimated free space for logical disk creation (showspacei)" >> {{ path_OF }}
echo "└──────────────────────────────────────────────────────────────────────────────────────────────────────────" >> {{ path_OF }}
echo "{{ showspace_output.stdout }}" >> {{ path_OF }}
echo "" >> {{ path_OF }}
echo "┌──────────────────────────────────────────────────────────────────────────────────────────────────────────" >> {{ path_OF }}
echo "│ Display information about the nodes (shownode)" >> {{ path_OF }}
echo "└──────────────────────────────────────────────────────────────────────────────────────────────────────────" >> {{ path_OF }}
echo "{{ shownode_output.stdout }}" >> {{ path_OF }}
echo "" >> {{ path_OF }}
echo "┌──────────────────────────────────────────────────────────────────────────────────────────────────────────" >> {{ path_OF }}
echo "│ Displays information about all the hardware components in the system (showinventory)" >> {{ path_OF }}
echo "└──────────────────────────────────────────────────────────────────────────────────────────────────────────" >> {{ path_OF }}
echo "{{ showinventory_output.stdout }}" >> {{ path_OF }}
echo "" >> {{ path_OF }}
echo "┌──────────────────────────────────────────────────────────────────────────────────────────────────────────" >> {{ path_OF }}
echo "│ Displays configuration information about a system's physical disks (showpd)" >> {{ path_OF }}
echo "└──────────────────────────────────────────────────────────────────────────────────────────────────────────" >> {{ path_OF }}
echo "{{ showpd_output.stdout }}" >> {{ path_OF }}
echo "" >> {{ path_OF }}
echo "┌──────────────────────────────────────────────────────────────────────────────────────────────────────────" >> {{ path_OF }}
echo "│ Displays configuration information about the system's LDs (showld)" >> {{ path_OF }}
echo "└──────────────────────────────────────────────────────────────────────────────────────────────────────────" >> {{ path_OF }}
echo "{{ showld_output.stdout }}" >> {{ path_OF }}
echo "" >> {{ path_OF }}
echo "┌──────────────────────────────────────────────────────────────────────────────────────────────────────────" >> {{ path_OF }}
echo "│ Displays information about all Virtual Volumes (VVs) (showvv)" >> {{ path_OF }}
echo "└──────────────────────────────────────────────────────────────────────────────────────────────────────────" >> {{ path_OF }}
echo "{{ showvv_output.stdout }}" >> {{ path_OF }}
echo "" >> {{ path_OF }}
echo "{{ showvvset_output.stdout }}" >> {{ path_OF }}
echo "" >> {{ path_OF }}
echo "┌──────────────────────────────────────────────────────────────────────────────────────────────────────────" >> {{ path_OF }}
echo "│ Displays information about Virtual Logical Unit Numbers (VLUNs) in the system (showvlun)" >> {{ path_OF }}
echo "└──────────────────────────────────────────────────────────────────────────────────────────────────────────" >> {{ path_OF }}
echo "{{ showinventory_output.stdout }}" >> {{ path_OF }}
echo "" >> {{ path_OF }}
echo "┌──────────────────────────────────────────────────────────────────────────────────────────────────────────" >> {{ path_OF }}
echo "│ Displays details of the Remote Copy configuration (showrcopy -d)" >> {{ path_OF }}
echo "└──────────────────────────────────────────────────────────────────────────────────────────────────────────" >> {{ path_OF }}
echo "{{ showrcopy_output.stdout }}" >> {{ path_OF }}
echo "" >> {{ path_OF }}
echo "╔══════════════════════════════════════════════════════════════════════════════════════════════════════════╗" >> {{ path_OF }}
echo "║ ▉ 3 - LOGS AND ALERTS " >> {{ path_OF }}
echo "╚══════════════════════════════════════════════════════════════════════════════════════════════════════════╝" >> {{ path_OF }}
echo "" >> {{ path_OF }}
echo "┌──────────────────────────────────────────────────────────────────────────────────────────────────────────" >> {{ path_OF }}
echo "│ Displays the status of system alerts (showalert -all -oneline)" >> {{ path_OF }}
echo "└──────────────────────────────────────────────────────────────────────────────────────────────────────────" >> {{ path_OF }}
echo "{{ showalert_output.stdout }}" >> {{ path_OF }}
echo "" >> {{ path_OF }}
echo "┌──────────────────────────────────────────────────────────────────────────────────────────────────────────" >> {{ path_OF }}
echo "│ Displays component reset reason details (showreset)" >> {{ path_OF }}
echo "└──────────────────────────────────────────────────────────────────────────────────────────────────────────" >> {{ path_OF }}
echo "{{ showreset_output.stdout }}" >> {{ path_OF }}
echo "" >> {{ path_OF }}
echo "┌──────────────────────────────────────────────────────────────────────────────────────────────────────────" >> {{ path_OF }}
echo "│ Displays the current system event log (showeventlog -min 10080 -oneline //10080=7days)" >> {{ path_OF }}
echo "└──────────────────────────────────────────────────────────────────────────────────────────────────────────" >> {{ path_OF }}
echo "" >> {{ path_OF }}
echo "────── FATAL Events ────────────" >> {{ path_OF }}
echo "{{ showeventlogfatal_output.stdout }}" >> {{ path_OF }}
echo "────── CRITICAL Events ─────────" >> {{ path_OF }}
echo "{{ showeventlogcrit_output.stdout }}" >> {{ path_OF }}
echo "────── MAJOR Events ────────────" >> {{ path_OF }}
echo "{{ showeventlogmaj_output.stdout }}" >> {{ path_OF }}
echo "────── DEGRADED Events ─────────" >> {{ path_OF }}
echo "{{ showeventlogdeg_output.stdout }}" >> {{ path_OF }}

#=======================================================
# SEND ATTACHED FILE VIA MAIL
#=======================================================
- name: Send the output file by email
local_action:
module: mail
host: "localhost"
port: 25
to: "[email protected]"
subject: "[ ALLETRA - {{ inventory_hostname }} ] - Weekly check storages - {{ current_date }}"
body: |
Please find attached the outputs of the commands executed on Alletra storages.
attach: "{{ path_OF }}"

Documentation

Internet
Ansible documentation

🡅 Partager