Skip to content

Instantly share code, notes, and snippets.

@apeyroux
Last active February 3, 2026 12:49
Show Gist options
  • Select an option

  • Save apeyroux/b8536db91b008de6bcdec54463a04223 to your computer and use it in GitHub Desktop.

Select an option

Save apeyroux/b8536db91b008de6bcdec54463a04223 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
from setuphelpers import *
from common import *
DRY_RUN = True # Passer à False pour exécuter réellement
WAPT = Wapt()
# Paquets gérés par ce script
ALL_PACKAGES = [
'stn-active-wua',
'stn-desactive-wua',
'stn-maj-maturite-prod',
'stn-maj-maturite-preprod',
'stn-maj-maturite-dev',
'stn-maj-qualification',
'mi-msprod',
'mi-msqual',
]
def is_cluster_or_vsan():
"""Détecte les différentes solutions de clustering."""
if service_installed('ClusSvc'):
return True
vsan_products = [
"StarWind Virtual SAN",
# "Nutanix",
# "HPE SimpliVity",
]
for product in vsan_products:
if installed_softwares(product):
return True
return False
def print_report():
"""Affiche un état des lieux avant toute action."""
print("--- RAPPORT D'ÉTAT ---")
print("Hostname : %s" % get_hostname())
print("Cluster/vSAN : %s" % ("OUI" if is_cluster_or_vsan() else "NON"))
print("ClusSvc : %s" % ("installé" if service_installed('ClusSvc') else "absent"))
print("")
print("Paquets WAPT :")
for pkg in ALL_PACKAGES:
status = "installé" if WAPT.is_installed(pkg) else "absent"
print(" %-30s %s" % (pkg, status))
print("----------------------")
def ensure_packages(to_install, to_uninstall):
"""Installe/désinstalle les paquets selon l'état souhaité."""
for pkg in to_uninstall:
if WAPT.is_installed(pkg):
if DRY_RUN:
print("[DRY RUN] Désinstallerait %s" % pkg)
else:
WAPT.uninstall(pkg)
for pkg in to_install:
if not WAPT.is_installed(pkg):
if DRY_RUN:
print("[DRY RUN] Installerait %s" % pkg)
else:
WAPT.install(pkg)
def install():
pass
def audit():
if DRY_RUN:
print("=== MODE DRY RUN — aucune action ne sera exécutée ===")
print_report()
if is_cluster_or_vsan():
print("→ Profil : CLUSTER")
ensure_packages(
to_install=['stn-desactive-wua'],
to_uninstall=['stn-active-wua', 'mi-msprod', 'mi-msqual'],
)
return "WARNING"
print("→ Lancement de l'activation WAPT WUA")
if WAPT.is_installed('stn-maj-qualification'):
print("→ Profil : QUALIFICATION")
ensure_packages(
to_install=['stn-maj-maturite-preprod', 'stn-active-wua', 'mi-msqual'],
to_uninstall=['stn-maj-maturite-prod', 'stn-maj-maturite-dev', 'stn-desactive-wua', 'mi-msprod'],
)
return "OK"
else:
print("→ Profil : PRODUCTION")
ensure_packages(
to_install=['stn-maj-maturite-prod', 'stn-active-wua', 'mi-msprod'],
to_uninstall=['stn-maj-maturite-preprod', 'stn-maj-maturite-dev', 'stn-desactive-wua', 'mi-msqual'],
)
return "OK"
if __name__ == '__main__':
audit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment